SVN Commit lock for JIRA

Neeraj Tiwari March 20, 2013

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

0 votes
Matt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

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
Neeraj Tiwari March 21, 2013

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