The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Jira issue key in commit message in SourceTree and recognizing it in bamboo build

Andrey Shovkoplyas
October 10, 2014

What the easiest way to add JIRA key in commit message in Source Tree, can SourceTree get the key from the branch name?

Why bamboo doesn't recognize Jira key from merge commit with branch name like "Merge branch/JIRA-KEY-issue"?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Andrey Shovkoplyas
October 22, 2014

I decided to add client commit-msg hook, which automatically adds JIRA Key in commit message from branch name, and checks JIRA Key in message

 

Linux
 
#!/bin/bash
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
if [[ $BRANCH_NAME =~ KEY-[0-9]+ ]]; then
   echo -e "\n"$BASH_REMATCH >> $1
fi
if ! grep -Pq "KEY-[0-9]{4,}" $1; then
    echo "Aborting commit due to commit message without JIRA-key."
    exit 1
fi


Windows
 
#!/bin/bash
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
TR=$(echo $BRANCH_NAME | sed -r 's/.*(KEY-[0-9]{4,}).*/\1/')
if [[ -n $TR ]]; then
echo -e "\n"$TR >> $1
fi
if ! grep -Eq "KEY-[0-9]{4,}" $1; then
    echo "Aborting commit due to commit message without JIRA-key."
    exit 1
fi

 

 

where 

KEY-[0-9]{4,} - JIRA Key with not less than 4 numbers 
TAGS
AUG Leaders

Atlassian Community Events