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
However,
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'):
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.
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!
Regards
Yannis
Hi!
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.