Auto populate fix version when issue is resolved

Rahul Aich [Nagra]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 29, 2013

Hi

I have a requirement on jira.

I want to be able to automatically populate the fix version(s) field with the next unreleased version when the issue is moved to resolved.

How can we achieve this?

Rahul

4 answers

1 accepted

3 votes
Answer accepted
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 30, 2013

Conditioned Workflow Functions for JIRA has a post function to update an issue and you can use the earliestUnreleasedVersion(projectKey) substitution variable to set the fix versions field.

1 vote
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 29, 2013

You can write a Transition post function script for this using scriptRunner plugin.

Lisa Reilly May 7, 2014

If you've done this yourself could I see the script to copy it for myself please?!

Shylah Weber June 26, 2014

The following sets it to a specific version based on the string passed when creating the Version... you should be able to modify this with the function Bob suggested to get what you're looking for.

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.issue.IssueManager

import com.atlassian.jira.project.Project

import com.atlassian.jira.project.version.Version

import com.atlassian.jira.project.version.VersionManager

import com.atlassian.jira.event.type.EventDispatchOption

import org.apache.log4j.Category

Category log = log;

log.setLevel(org.apache.log4j.Level.DEBUG);

VersionManager versionManager = ComponentAccessor.versionManager

IssueManager issueManager = ComponentAccessor.getIssueManager()

Issue issue = issue

Project project = issue.getProjectObject()

Version versionFX = versionManager.getVersion(project.getId(), "no actual code")

issue.setFixVersions([versionFX])

issueManager.updateIssue(componentManager.jiraAuthenticationContext.getLoggedInUser(), issue, EventDispatchOption.DO_NOT_DISPATCH, false)

0 votes
Shylah Weber June 26, 2014

The following sets it to a specific version based on the string passed when creating the Version... you should be able to modify this with the function Bob suggested to get what you're looking for.

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.issue.IssueManager

import com.atlassian.jira.project.Project

import com.atlassian.jira.project.version.Version

import com.atlassian.jira.project.version.VersionManager

import com.atlassian.jira.event.type.EventDispatchOption

import org.apache.log4j.Category

Category log = log;

log.setLevel(org.apache.log4j.Level.DEBUG);

VersionManager versionManager = ComponentAccessor.versionManager

IssueManager issueManager = ComponentAccessor.getIssueManager()

Issue issue = issue

Project project = issue.getProjectObject()

Version versionFX = versionManager.getVersion(project.getId(), "no actual code")

issue.setFixVersions([versionFX])

issueManager.updateIssue(componentManager.jiraAuthenticationContext.getLoggedInUser(), issue, EventDispatchOption.DO_NOT_DISPATCH, false)

0 votes
Bhushan Nagaraj
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 29, 2013

In case, you might have multiple unreleased versions. How will you identify which one?

Suggest an answer

Log in or Sign up to answer