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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Bitbucket Scriptrunner Require that a pull request is associated with a valid Jira issue


Hello guys,

I'm trying to prevent pr from merging in release branch if Jira issue fix version is not the same as branch name using Require that a pull request is associated with a valid Jira issue built-in script

Screenshot 2022-01-20 133439.png

Screenshot 2022-01-20 133449.png



fixVersion = '${mergeRequest.pullRequest.toRef.displayId}'


is not working for me, as in Jira issue the names of versions are "2.03", "2.49", and so on and I'm having an error that Edit the PR title (or add commits) to reference an issue from (fixVersion = 'release/5.1'):

Screenshot 2022-01-20 133623.png


This error pops out if in Jira issue fixVer we have "5.1" instead of "release/5.1"

However, we can't rename release versions in Jira, so the only way is to write a validator when fixVer in Jira Issue equals target branch name after release prefix and have this merge check only if target branch is a release branch



So the validation JQL for me should be something like this:

release/JiraIssueFixVer = '${mergeRequest.pullRequest.toRef.displayId}'

(I've tried fixVersion = '${mergeRequest.pullRequest.toRef.displayId}'.split("/")[1]  and that didn't work , and I've also tried substring by index instead of splitting, that didn't work either)

+ condition that target branch is release branch  (run merge check if only merging to release branch, don't run merge check if merging to other branches)


Is there any way to get this working? I haven't written any custom merge checks before and can't understand how it can be achieved.



1 answer

1 accepted

Hi @anovinnikova 

I think your JQL is failing because you need to swap single quotes with double quotes

I believe this script would match a branch named 'release/5.1' with a jira fixVersion = '5.1'

fixVersion in ("${mergeRequest.pullRequest.toRef.displayId.split('/')[1]}")


Hope this helps, please let us know if this works for you!




Thanks for your response and sorry for the late answer.

I've checked the JQL, it works perfect!

Thank you very much for your help.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events