I am using SVN for revision control and atlassian JIRA as the issue tracker for my LAMP website. I want to restrict SVN commit if any of my team member commits without mentioning the Jira Issue key for the same. I am using JIRA standalone and have installed it on my server. Google search gave me Subversion Jira Plugin (https://ecosystem.atlassian.net/wiki/display/SVN/Subversion+JIRA+plugin) but it can only help me out in tracking the commits that had a JIRA key, not in restricting them.
Please let me know, if I should post any more specifics about the issue.
Regards,
Use the Commit Policy Plugin.
Learn more about the Subversion-specific parts and use this recipe. If you want to limit which issues you allow to commit against, then also use these recipes.
Hello Team,
I tried placing the script in pre-commit , but it is throwing error in the first line. Could you please help me with the exact workaround where to place the script.
#Check first line contains JiraId firstline =lines[0].lstrip() if firstline.find(":")==-1: sys.stderr.write(stdErrMsg) sys.exit(1) prefix= firstline.split(":")[0] if prefix.strip()=="": sys.stderr.write(stdErrMsg) sys.exit(1) jiraIDpattern = re.compile(r"(\A[A-Z]{2,}-\d+)") IDs=prefix.split(",") invalidMessage=0 for rawID in IDs: ID=rawID.strip() result=jiraIDpattern.match(ID) if not result: sys.stderr.write("\n '"+ID+"' is not a valid JIRA issue ID") invalidMessage=1 if invalidMessage: sys.exit(1)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Snehal
You will have to write pre-commit hook in SVN to check if the comment has the JIRA key. You can additionally verify if the JIRA key is valid and is not closed. Here is extract from my pre-commit hook.
#Check first line contains JiraId firstline =lines[0].lstrip() if firstline.find(":")==-1: sys.stderr.write(stdErrMsg) sys.exit(1) prefix= firstline.split(":")[0] if prefix.strip()=="": sys.stderr.write(stdErrMsg) sys.exit(1) jiraIDpattern = re.compile(r"(\A[A-Z]{2,}-\d+)") IDs=prefix.split(",") invalidMessage=0 for rawID in IDs: ID=rawID.strip() result=jiraIDpattern.match(ID) if not result: sys.stderr.write("\n '"+ID+"' is not a valid JIRA issue ID") invalidMessage=1 if invalidMessage: sys.exit(1) #Check JIRA is up try: soap = SOAPpy.WSDL.Proxy(jiraWSDL) auth = soap.login(jirauser, jirapasswd) except Exception, err: # If JIRA is down then except commit message as is. sendMail(firstline + " " + author ) sys.exit(0) #Check JIRA issues exist invalidJIRAissue=0 for rawID in IDs: issueid=rawID.strip() try: issue = soap.getIssue(auth, issueid) except SOAPpy.faultType,e : #issue does not exist soapError = issueid+": "+ str(e) sys.stderr.write("\n"+ issueid + " does not exist in JIRA") invalidJIRAissue=1 else: #Check JIRA status is not closed if int(issue.status) == 6: sys.stderr.write("\nYou cannot commit against "+issueid+ " as it is in a resolved state (CLOSED) ! ") invalidJIRAissue=1 if invalidJIRAissue: sys.exit(1)
Here user is required to put the commit message in format "JIRA-1234 : <message goes here>"
Vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Let me note that you are relying on the SOAP API in your code, which will be removed in JIRA 7.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.