SVN Commit lock for JIRA

We need to have a way to mandate commit information in SVN external for JIRA tickets. For eg: When developer commits a file we need to make sure we mandate some information on the commit comments like JIRA ticket number, description etc.

1 answer

Have you tried to use SVN hook? Try to parse commit message against:

[A-Z]{2,10}-[0-9]{1,6}

If its not in the commit message then reject commit.

This is a bit out of topic but someone may find it useful, therefore I share that with you. If you're working on a branch that is named after Jira issue for example DEMO-10, the script would add some smartcommit info to your commit message which adds comment in your issue and opens code review in Crucible.

#!/bin/sh
#
# Mateusz Harasymczuk
# mateusz@harasymczuk.pl
#
# This hook message should go to .git/hooks/commit-msg
# Remember to add (*nix machines) executable rights: chmod +x .git/hooks/commit-msg
# Hook checks branch you're currenly on and adds its name to commit message.
# It adds commit message as a comment in jira connected with this issue.
# Moreover it creates a Code Review in Crucible.
#
# You'll never forget about this things anymore :}
# The only thing you should do is to create an issue for each branch you have.
# For example if you are working on issue DEMO-123 create a branch called DEMO-123
# Each commit on this branch would have DEMO-123 in the commit message and Code Review process attached to it.
#

issuekey=$(git symbolic-ref HEAD |egrep --only-matching '[A-Z]{2,10}-[0-9]{1,6}')
commitmsgFile="$1"
commitmsg=$(cat "$1")

if [ -z "$issuekey" ]; then
   echo "You're not working on issue branch!"
   echo "Please create a branch named after https://jira.office issue."
   echo "Commit message will be updated accordingly in order to contain branch/issuekey in the commit message."
   exit 1
else
   echo "$issuekey #comment $commitmsg +review" > $commitmsgFile
fi

Hi Matt,

Thanks for your answer. I came across this link in my research: https://ecosystem.atlassian.net/wiki/display/CMMT/JIRA+Commit+Acceptance

Can you please take a look at this Atlassian plugin that allows us to restrict SVN to require a JIRA ticket to commit? Please see if there will be an issue of us putting this into our SVN.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

692 views 6 13
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you