Automatically set next unreleased fixVersion for new issues or during a transition?

Hi,

I would like to automatically set next unreleased fixVersion for new issues or during a transition.

I belive "script runner" is my only option?

If so, does anyone have written somthing like that?

How can I get the "next unreleased fixVersion" using jira API?

Any help would be appriciated

2 answers

1 accepted

This widget could not be displayed.

Something like this, not tested:

import com.atlassian.jira.component.ComponentAccessor

def versionManager = ComponentAccessor.getVersionManager()
def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectObjByKey("JRA")

def versions = versionManager.getVersions(project)

versions.sort {it.releaseDate}.reverse().find{! it.released}

works like a charm

As I'm sharing the WL, Can I use somthing like that ?:

import com.atlassian.jira.component.ComponentAccessor;

def versionManager = ComponentAccessor.getVersionManager()
def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectObjByKey(issue.projectObject.key)
 
def versions = versionManager.getVersions(project)
 
versions.sort {it.releaseDate}.reverse().find{! it.released}

The above code didn't work (version 7 maybe?) as it reported UnmodifiableListIterator, so I have managed to find another way.

import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level

def versionManager = ComponentAccessor.getVersionManager()
def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectObjByKey(issue.projectObject.key)

def versions = versionManager.getVersions(project)

def newversions = versions.collect()
  
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
  
//log.debug newversions
//newversions.eachWithIndex { version, i ->
    //log.debug "${version.description} - ${version.name} - ${version.released}"
//}

//versions.sort {it.releaseDate}
newversions = newversions.sort({version1, version2 -> version1.releaseDate<=>version2.releaseDate}).findAll{version -> ! version.released }

log.debug("First element: " + newversions.first())
//newversions.eachWithIndex { version, i ->
    //log.debug "${version.description} - ${version.name} - ${version.released}"
//}

def versionToUse = newversions.first();
This widget could not be displayed.

You can use earliestUnreleasedVersion(projectKey) (see Substitution variables) as a substitution variable on a workflow transition to set the fix version. This is available for Create Issue, Create Subtask, and Update issues post functions.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

513 views 3 18
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you