Add fix version to 99 issues

Susanne Harelius [Riada]
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.
August 8, 2013

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?

5 answers

1 accepted

0 votes
Answer accepted
Udo Brand
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.
August 8, 2013

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
Susanne Harelius [Riada]
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.
August 8, 2013

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?

Udo Brand
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.
August 8, 2013

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

Susanne Harelius [Riada]
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.
August 8, 2013

Cool, thanks. I will try this.

Udo Brand
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.
August 8, 2013

Glad I could help.

Susanne Harelius [Riada]
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.
August 8, 2013

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

1 vote
Henning Tietgens
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.
August 8, 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

Susanne Harelius [Riada]
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.
August 8, 2013

Thanks! I will look into this.

0 votes
Archana March 18, 2021

Guys could you please let me know if there is a way to convert CSV file in FIX format?

0 votes
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.
August 8, 2013

JIRA Command Line Interface using something like:

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

Susanne Harelius [Riada]
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.
August 12, 2013

Thanks Bob! This might also be useful.

0 votes
Ivar
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.
August 8, 2013

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.

Susanne Harelius [Riada]
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.
August 8, 2013

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.

Ivar
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.
August 8, 2013

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.

Suggest an answer

Log in or Sign up to answer