Require commits to be associated with a JIRA issue
To implement Pre receive hook
We have put condition to enforce developer to have Jira ticket in commit message
def commits = refChanges.getCommits(repository)
def issueKeyRegex = /((?<!([A-Z]{1,10})-?)[A-Z]+-\d+)/
commits.any { commit ->
!(commit.message =~ issueKeyRegex)
}
But 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