HI, I have the following snippet of code via Groovy ScriptRunner.
Issue currIssue = componentManager.getIssueManager().getIssueObject("TESTDEV-712")
def targetVersion = currIssue.getCustomFieldValue(cf)
log.debug targetVersion
def fixVersion = currIssue.getFixVersions()
log.debug fixVersion
fixInHead = fixVersion.grep('HEAD')
log.debug fixInHead
if (fixVersion.contains(targetVersion))
log.debug "Found match"
else
log.debug "No match"
My test data is:
Target Version = 8102
Fix Version = 8102, HEAD
Expected it to return "Found match" but for some unknown reason, it doesn't see the match. Please help! Thanks!
target version and fix version are both lists.
I would suggest you to change "contains" to "containsAll"
if (fixVersion.containsAll(targetVersion)) log.debug "Found match" else log.debug "No match"
This will work if the target version would be one or multiple selections
Thanks! That works. I have a follow-up question. What's the call that I can make to return the list count? I'm new with groovy scripting.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To retrieve the list count you can use the size() method. So "fixVersion.size()". The answer depends by the purpose of your script. If you are creating a scripted field just take a look at that: https://jamieechlin.atlassian.net/wiki/display/GRV/Scripted+Fields
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.