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

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 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events