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

Can you concatenate strings in scriptrunner JQL query?

I have a merge check I am trying to setup that prevents a merge from happening if the target branch does not match a field found in an associated JIRA Issue.

I am using the "Require that a pull request is associated with a valid JIRA issue" merge check that comes with scriptrunner and am also using the following JQL which almost gives me what I want.

Target_Baseline ~ '${mergeRequest.pullRequest.toRef.displayId}

Target_Baseline is a free text custom field in JIRA. The problem is that the right side of the equation evaluates to something slightly different than the left (shown below) and it fails the check and does not allow the merge

v1.0.0 ~ 'v1.0.0T'

that extra T at the end of the target branch is throwing a wrench in things. Is there any way to manually concatenate a string to the end of the Target_Baseline or perhaps even remove that character from the target branch?

Any and all help is appreciated!

1 answer

1 accepted

1 vote
Answer accepted

Hi @Omar Morales 

The JQL expression is an GString and it has two phases of execution:

1. In the first one, all Groovy expression are interpolated into String

2. In the second, interpolated string is passed to JIRA for execution

In the first phase in all expression which are in "${}" you have full power of Groovy language to do anything You would like to do, for example:

${mergeRequest.pullRequest.toRef.displayId.substring('T', '')}

more about GString interpolation You can read here:


I think also that You are missing closing ' char or the first one is redundant, it could be just

Target_Baseline ~ ${mergeRequest.pullRequest.toRef.displayId.substring('T', '')}


Kind Regards,

Tomasz Wozniak

Software Engineer - ScriptRunner for Bitbucket

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events