Forums

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

Links regex for enforcing commit message not working

siddhesh.harmalkar July 6, 2020

Hello,

We are using Bit bucket cloud for our deployments. We have integrated Bitbucket with Jira Issues. Now we are planning to enforce commit strategies with Workflow Links Regex.

We are using regex value as : ^[KL]{2}-\d{4,9}: .*
Expected commit pattern should strictly follow below pattern as :

KL(hyphen)1655(colon)(space bar)first commit message.

In our case it is not working.
Can someone suggest best way to write regex for the same.

Thanks And Regards

1 answer

0 votes
FrankyG September 1, 2020

I can't help you with Workflow Links, but as for the regex:

Your pattern will match any combination of K or L at the beginning - KK, LL, KL, LK.
If you want a literal "KL" then you can use this instead: ^KL-\d{4,9}: .*

siddhesh.harmalkar September 1, 2020

Hi FrankyG,

Thanks for responding.

In my case, we wanted to enforce users to follow below pattern
KL(hyphen)1655(colon)(space bar)first commit message.

For eg : if a user fails to provide space bar in between colon and commit message(i.e KL-1622:Some Commit Message) it should not be allow as valid commit since we have strictly mentioned/enforced space bar in regex.

In my case, this enforcement is not working.
It would be helpful if  you suggest some regex pattern for the same.

Thanks and Regards,
Siddhesh

FrankyG September 2, 2020

Hi Siddhesh,

That regex should do what you expect. I'm not familiar with Workflow Links, so there might be something going wrong there.

I've tested the regex with some examples here: regexr.com/5bbdk (look at the Tests tab and note which tests are "Match full" and which are "Match none")

The only other thing I'd suggest is that this doesn't enforce a message after the space, which can be done with + (1 or more) instead of * (0 or more)

^KL-\d{4,9}: .+

Sorry I can't be of more help. Good luck!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events