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!
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: https://groovy-lang.org/syntax.html#_string_interpolation
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.