Configuring Pre-Receiving Hook

Hi Team,

I have a requirement where I have to enforce a naming standard to feature branch with an jira issue key. (this is possible via pre hook feature/TEST-\d+.*)
Also it should check whether the issue exist in jira or not. Currently the name standard expression just check the naming, it does not check whether the issue actually exists in jira pr not.

Same should be applicable via UI (like creating a branch via jira or any other git interfaces).

We are trying to acheive this through adaptivist script runner for bit bucket server.

Could you please suggest.

2 answers

1 vote

Hi Akhil,

We already provide a way to do this in ScriptRunner for Bitbucket Server. It's called "Require commits to be associated with a JIRA issue", there is a pre-receive hook and a merge check version.

You'll need a working application link between JIRA and Bitbucket. If you look into the documentation I linked you to above you'll find out more information on how to configure this.

If you use it in conjunction with the "Naming standard enforcement" hook you should have everything you need.

It requires a lot of code to do this yourself so your best off using the one we provide in the product.

The UI is a bit tricky. We have a "Naming standard enforcement" event handler for that but it does not verify the issue exists in JIRA.

Let us know how you get on with the other one first and I'll provide some code for you to check the issue exists in JIRA from the UI.

Thanks,
Adam 

Hi Adam,

I have already tried the above mentioned methods,.Please see the attached screenshots1.PNG2.PNG

 

Please provide the code to check the issue

The condition in "Require commits to be associated with a JIRA issue" looks wrong. It only applies the hook when the condition is true.

You should just remove it completely so the condition always evaluates to true and for every push the branch name is validated with a JIRA issue key.

Please try it again with that approach and you'll see it works, assuming you have a primary JIRA application link setup in Bitbucket.

Let me know how that goes.

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

714 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot