Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I enforce the commit messages to have JIRA ID using pre hooks?

Vignesh Kumar January 27, 2019

 I would like to customize my repository so that if I commit anything without the issue number(JIRA ID), it should not allow me to .

Is there any way to do it using pre hooks?

I see a pre-hook named "Require commits to be associated with a JIRA issue" but I dont know what condition to provide in condition pane.

 What we are looking for is: The commit should not be allowed if the regex does not match 

Except conditions, I have filled all other fields (JQL Query and regex).

Regex which I created follows the below condition:

 Commit should start with 
1. alpha numeric upper case - min 2 char (for example for ABC)
2. hyphen Mandatory
3. Number (0-9) - At least 1 digit
4. No spaces around hyphen.
5. Space required after jira story number. And at least 1 word comment afterward.

ex. ABC-1234 Adding some changes

 

Could anyone please provide me with the correct condition? Thanks in advance.

1 answer

0 votes
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 29, 2019

Hi Vignesh, welcome to the Community!

Are you using Scriptrunner? There was a similar request here, I recommend reading through it as there are several options that might help you.

Alternatively, let us know which plugin are you using (if any) so we can continue helping you.

Kind regards,

Ana

Vignesh Kumar February 7, 2019

Hi Ana,

            Thanks for the information!!  I am not using any scriptrunner. 

In my forked repository, under pre-hooks, I enabled Require commits to be associated with a JIRA issue pre-hook.  I have provided the regex and JQL clause as shown below.

regex_check.pngJQL.png

Now, I have to add a condition in the condition Tab. 

The condition should be like :

1. The commit message should start with ABC8CC followed by hyphen- then followed by numbers(regex check) 

2. If the commit message does not start with ABC8CC ,then it should not allow to commit.

 

It would be great if you can provide me with the condition. Thanks in Advance and Sorry for my late response.

Vignesh Kumar February 18, 2019

The link provided is about forbidding PR get merged without commit ID.

I need a pre-hook which does not allow to commit if the regex is not matched.

Please let me know if  there is any detail needed from my side

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events