Add fix version to 99 issues

I have a filter which includes 99 issues. They all have fix versions set (one or more) and now we want to add a common fix version to theses issues. Add - which means that we want to keep the existing fix versions. If I use the bulk edit functionality the old versions will be replaced by the new.

(How )can this be done without doing it manually for each issue?

4 answers

1 accepted

This widget could not be displayed.

you could use the csv-importer to achive this. The file needs to look like this.

id, Summary, FixVersion, FixVersion, FixVersion
xx-1,"First issue", v1, ,
xx-2, "Second issue", v2, ,
xx-3, "Third issue", v1, v2, v3
for details please see here

Udo, do you mean I need to first export and then import? Will that not replace? Can I do this and only get an update of the issue you mean?

Hi Susanne,

yes, export Issuekey, summary and fixVersion and then edit the csv (add your new version) and reimport the csv. It will do updates to the fields (only on fixVersion ) issuekey and summary are not affected but required

Cool, thanks. I will try this.

Glad I could help.

Thank you Udo! This work well in test and now I will do this in production.

This widget could not be displayed.
Henning Tietgens Community Champion Aug 08, 2013

You can use the following Script Runner script to add versions to a JQL search.

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.index.IssueIndexManager
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.project.version.VersionManager
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.web.bean.PagerFilter

String jql = 'project = TIQA and priority = Critical'
String projectKey = 'TIQA'
String newVersion = '1.35'

IssueService issueService = ComponentAccessor.getIssueService()
VersionManager versionManager = ComponentAccessor.getVersionManager()
ProjectManager projectManager = ComponentAccessor.getProjectManager()
IssueIndexManager indexManager = ComponentAccessor.getIssueIndexManager()
User user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
log?.debug "..Got user $user"

issues = getFilterResult(jql,user,log)
projectId = projectManager.getProjectObjByKey(projectKey)?.id
newVersionId = versionManager.getVersion(projectId, newVersion)?.id

if (newVersionId) {
    issues.each{
        iiparams = issueService.newIssueInputParameters()
        iiparams.setRetainExistingValuesWhenParameterNotProvided(true, true)
        iiparams.setApplyDefaultValuesWhenParameterNotProvided(false)
        iiparams.setSkipScreenCheck(true)

        List versionIds = it.getFixVersions()*.id
        versionIds << newVersionId
        iiparams.setFixVersionIds((Long[]) versionIds.toArray())
        vresult = issueService.validateUpdate(user,it.id, iiparams)
        if (vresult.isValid()) {
            uresult = issueService.update(user, vresult, EventDispatchOption.DO_NOT_DISPATCH, false)
            if (uresult.isValid()) {
                boolean wasIndexing = ImportUtils.isIndexIssues();
                ImportUtils.setIndexIssues(true);
                indexManager.reIndex(uresult.getIssue());
                ImportUtils.setIndexIssues(wasIndexing);
            } else {
                log.error uresult.getErrorCollection().getErrors()
            }
        } else {
            log.error vresult.getErrorCollection().getErrors()
        }
    }.size()
}

List<Issue> getFilterResult(String jqlSearch, User user, log = null) {
    SearchService searchService = ComponentAccessor.getComponent(SearchService.class);

    def ctx = new JiraServiceContextImpl(user)
    log?.debug "..Got ServiceContext $ctx"
    List<Issue> issues = null

    SearchService.ParseResult parseResult =  searchService.parseQuery(user, jqlSearch);
    if (parseResult.isValid()) {
        def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
        issues = searchResult.getIssues()
        log?.debug "Found ${issues.size()} issues...\n"
    } else {
        log?.error("Invalid JQL: " + jqlSearch);
    }
    return issues
}

You have to change jql, projectKey and newVersion to match your situation. Please try on a test system first. :-)

Henning

Thanks! I will look into this.

This widget could not be displayed.

I haven't tested this specifically, but let's say you now have sprint 1, 2, 3 and 4 as versions. If you create version 1.0, and make those sprint versions "children" under version 1, I believe all of them will keep the initial sprint (e.g. 1, 2, 3 or 4) and at the same time be tagged with version 1 in the fix verison field.

Thanks for your quick respons. Children? I am not talking about sprints, only versions and as far as I have seen there is no "tree" functionality for versions or have I missed something.

Are you using Greenhopper? In Greenhopper a version can have a "parent" version, see here for some info: https://confluence.atlassian.com/display/GH/Setting+Up+a+Version+Hierarchy.

If you have parent-child hiercarchy, the fix version will automatically include both versions (e.g. both parent and child version).

Sprint was just a example. You could have v.0.1, v.0.2, v.0.3, v.04 and then make version 1.0 the parent of them all.

This widget could not be displayed.

JIRA Command Line Interface using something like:

--action runFromIssueList --search " <some JQL> " --common "--action updateIssue --issue @issue@ --fixVersions v1 --append"

Thanks Bob! This might also be useful.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

155 views 2 0
Join discussion

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