Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

issue.getFixVersions() NOT returning archived fixversions Edited

Hi,

I have this code snipppet:

import com.atlassian.jira.project.version.Version
Collection <Version> fixVersions = issue.getFixVersions()

for (fv in fixVersions) {
    log.debug (String.format('issue=%s fv=%s isArchived=%s isReleased=%s', issue.key, fv.getName(),
                             fv.isArchived(), fv.isReleased()))
  if (fv.isReleased()) {
    log.debug("yes ${fv.getName()} is released.")
  }
}

When i run it using "Groovy Script Tester" from JMWE (Jira Misc Workflow Extensions), i see:

DEBUG: issue=PRJ-90210 fv=foo.1.0 isArchived=true isReleased=true
DEBUG: yes foo.1.0 is released.
DEBUG: issue=PRJ-90210 fv=bar.3.0 isArchived=false isReleased=false

which is the expected results.

Running this code snippet in the Scriptrunner Script Console

IssueManager issueManager = ComponentAccessor.getIssueManager() 
Issue issue = issueManager.getIssueObject('PRJ-90210')
Collection <Version> fixVersions = issue.getFixVersions()

for (fv in fixVersions) {
    log.debug (String.format('issue=%s fv=%s isArchived=%s isReleased=%s', issue.key, fv.getName(),
                             fv.isArchived(), fv.isReleased()))
  if (fv.isReleased()) {
    log.debug("yes ${fv.getName()} is released.")
  }
}
 

gives the expected output as seen in the "Groovy Script Tester".

However, when i run the same exact code snippet as a Scriptrunner Validator, i only see:

issue=PRJ-90210 fv=bar.3.0 isArchived=false isReleased=false

The archived fixversion (foo.1.0) did NOT show up.

What could be the problem?

Thanks

--Andrew

1 answer

Hi, I've found a solution to get the archived fix versions in the scriptrunner validators. Here is my code:

 

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.component.ComponentAccessor;

import com.opensymphony.workflow.InvalidInputException

IssueManager issueManager = ComponentAccessor.getIssueManager()
Issue myIssue = issueManager.getIssueObject(issue.getKey())

// myIssue -> the issue object in the past. 
// issue -> the issue object in validation time
// To avoid false positive when removing all the fixed versions, we are checking if any of these fixed versions of the issue in the past are archived. if (issue.getResolution().name == "Fixed or Completed" && ! (issue.fixVersions || myIssue.fixVersions*.archived.contains(true))) { throw new InvalidInputException("fixVersions", "Fix Version/s is required when specifying Resolution of 'Fixed'") }

 

As you can see, my solution is to instance another issue object with the same key. 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

Share your Confluence Cloud experience for a chance to win $500!

Take our 5-minute survey to win a $500 Visa gift card! Are you currently using Confluence Cloud? We want to hear from you! Fill out this quick survey about your Confluence Cloud experience so we ...

260 views 5 13
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you