Skip to content

Instantly share code, notes, and snippets.

@KyMidd

KyMidd/asdf.sh Secret

Last active February 19, 2023 20:27
Show Gist options
  • Select an option

  • Save KyMidd/3d0e864014841876bac1ca74bdc522a4 to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/3d0e864014841876bac1ca74bdc522a4 to your computer and use it in GitHub Desktop.
# Check if ticket exists
unset CURL
CURL=$(curl -s --url "https://$JIRA_URL/rest/api/3/search?jql=key=${TICKET_TO_CHECK}" --header 'Accept:application/json' --user ${jira_username}:${jira_api_token} 2>&1)
if [[ "$CURL" == *"Issue does not exist"* ]]; then
echo "❌ Ticket referenced in commit doesn't exist in Jira. You must use real Jira tickets at the start of commit messages"
echo "❌ Recognized ticket in commit: $TICKET_TO_CHECK"
echo "❌ Commit message: \"$(git log --max-count=1 --format=%B $commit)\""
echo "❌ Hash: $commit"
echo "************"
# Set this variable to trigger rejection if any commit fails regex
invalidTicket=true
else
echo "Ticket $TICKET_TO_CHECK is valid"
fi
fi
done <<< $BRANCH_COMMITS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment