You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi! I am looking to create the following with Script Runner Cloud:
I am also looking to create the following validator:
Hi @Rachael Axtman ,
For the first case you'll want an expression like this
issue.comments.filter(c => c.body.plainText.includes("test") ).length > 0
Depending on how exact you want to match, you could also use .match() with a regular expression.
As for the second case, that's even easier you just need to know the custom field's id. Your validator could then look like this:
issue.customfield_10005 != null
There is a pretty good documentation for Jira Expression here.
Hope that helps,
Oliver
Oliver,
For the custom field is there a way for me to write something to detect status of a PR?
The code you wrote on the first answer looks pretty close to what I came up with yesterday. Thanks again!
-Rachael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had to poke around a bit and I am still not 100% sure it will work the same with Github, but here's what I found:
issue["customfield_10000"].includes('state=MERGED')
It's not really all that well documented, but it seems like the information from the "Development" field is always in the custom field with the id 1000. Unfortunately, the content of that field is not syntactically correct JSON, so you cannot just parse it with JSON.parse() and look at the different attributes.
However, you can look for the corresponding "state=MERGED" string, which should work pretty well.
Best regards,
Oliver
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Oliver - there has been an additional condition added to this and I was wondering if you could help. If the custom field is in a merged state then the issue can transition only if there is another custom field (fix version) that isn't empty. If fix version is empty and the PR is merged the user cannot transition their ticket as done.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Rachael Axtman ,
I hope I'm getting this right. So, only if the PR is merged and fix version is not empty, then the validator should return true. That could look like this:
issue["customfield_10000"].includes('state=MERGED') && issue.fixVersions.length > 0
The interesting part here is that you can link different expressions together with && (=AND) or || (=OR).
The above example uses the native fixVersions field; if you are using a different you'll have to change that of course.
Cheers,
Oliver
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're wonderful! Thank you! I will get this setup and tested and let you know what happens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It did end up working, but it is requiring a fix Version even when there is no PR. I checked and the fix version field is not marked as required in our settings.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Rachael Axtman ,
So, if there is no PR you want to be able to just close the issue? In that case we will need to check for that, too. Here's how:
issue["customfield_10000"] == "{}" || (issue["customfield_10000"].includes('state=MERGED') && issue.fixVersions.length > 0)
This adds another check at the beginning: If the development field (where the PR and commits appear) is empty, then pass immediately. If not, then it'll check if there is a merged PR and if there is a fixVersion present.
Cheers,
Oliver
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much, Oliver! You truly are wonderful for helping out. I'll try this out this morning and let you know what happened.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It worked out great! We had a use case that it didn't account for, but just ended up adjusting our error message to guide the users.
Thanks again Oliver!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.