-
-
Save KyMidd/3d0e864014841876bac1ca74bdc522a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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