Hi
I am not able to figure out what I am doing WRONG.Need help.Basically when JIRA id is not valid the push should fail from local to remote Bitbucket repository.But when I enable the below script for pre receive logic even the correct JIRA id commit is failing and I am not able to push any commits from local repository to Bitbucket repository.Any help is greatly appreciated
REGEX=[BM]±[0-9]
ERROR_MSG=“[POLICY] The commit doesn’t reference a JIRA issue”
while read OLDREV NEWREV REFNAME ; do
for COMMIT in git rev-list $OLDREV..$NEWREV
;
do
MESSAGE=git cat-file commit $COMMIT | sed '1,/^$/d'
|sed ‘1,/^$/d’|grep -o -E “[BM]±[0-9]+”|head -n1 // git cat-file commit df0965c4d564b02d116bb4aadc16a0d267e389c6
if ! echo $MESSAGE | grep -iqE “$REGEX”; then
echo “$ERROR_MSG: $MESSAGE” >&2
exit 1
fi
JSON_RETURN=curl -s http://hcs431brgppa911:8080/rest/api/latest/issue/$MESSAGE?fields=status -u username:password|egrep -o “Open|inprogress|Assigned|errorMessage”
if [-z “$JSON_RETURN”]
then
echo “The specified Jira Issue "$JIRAID" was not found in Jira server.” 1>&2
exit 1
fi
if [“$JSON_RETURN”=“errorMessage”]
then
echo “The specified Jira Issue "$JIRAID" was not found in Jira server.” 1>&2
exit 1
fi
done
done
exit 0