We need to enforce developer to have Jira ticket in commit message. Current build in solution checks that either commit message OR feature branch has Jira. We need to check always commit message
Regardless what branch we push from local to remote – we want to check each commit message and verify that Jira is there
I have tried to use build in option “Require commits to be associated with a JIRA issue”
But this option check that Feature branch OR commit message has Jira. We need to check commit message always. I.e. - I don’t care what is the name of the branch but I want to know that commit has Jira.
We have tried to use other option called “Push check”. But it doesn’t work as well. Because when I commit with commit message having Jira (in proper state) it simply rejects it.
We maintain an add-on, Control Freak for Bitbucket Server, that can help with this:
The free YACC add-on can also block commits that don't contain JIRA references in their commit message.
Hi Vijay,
You could use the protect git references hook in ScriptRunner for Bitbucket Server for this.
If you just want to check the commit messages include a JIRA issue key in them you can use the following condition in that built-in pre-receive hook:
def commits = refChanges.getCommits(repository)
def issueKeyRegex = /((?<!([A-Z]{1,10})-?)[A-Z]+-\d+)/
commits.any { commit ->
!(commit.message =~ issueKeyRegex)
}
This will just check that the message contains a Jira issue key format, not that the issue actually exists in Jira which is what the "Require commits to be associated with a JIRA issue" hook does.
If you need that then it's a bit more complex.
Let us know how you get on with this and if you need something a bit different then feel free to ask.
Hope this helps.
Adam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Adam,
Thanks for suggestion , I tried your suggested condition it is working fine only problem is - it will not validate the JIRA Issue key - means whether the Issue is Open or closed it accept the Issue key & commit - as it shouldn't allow commit if the Issue is closed , cancel , Resolved
Thanks,
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.