Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Require commits to be associated with a JIRA issue

Vijay Kene February 12, 2018

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

2 answers

1 vote
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 14, 2018

Commit Policy is a Bitbucket app that allows enforcing issue keys that match the result of a certain JQL query!

It means that you can check if the key is existing, if the issue is in "In progress", if that is in the right project and everything else that JQL allows for.

0 votes
Vijay Kene February 14, 2018

Thanks for your suggestion Aron,

Is there any other way can do ? as we dont want use plugin at this moment ?

Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 14, 2018

I do not think you can do this without add-ons.

Please note that even your original half-solution in the question requires an add-on to execute the Groovy script.

Vijay Kene February 16, 2018

Thanks Aron , appreciate your suggestion !!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events