• Community
  • Products
  • Jira
  • Questions
  • Bulk Changes: Is there a way to concatenate a new fixVersion when doing a bulk change, as opposed to completely replacing the fixVersion?

Bulk Changes: Is there a way to concatenate a new fixVersion when doing a bulk change, as opposed to completely replacing the fixVersion?

I have a project with hundreds of issues, each of which may have a different "fixVersion" associated with it. I want to do a "Bulk Edit" on all of these issues at once where I simply ADD a new fixVersion to each issue, as opposed to replacing the fixVersions that are already there. Is this possible?

I seem to have done this before at one point, but I don't remember how I was able to do that. Are there certain restrictions or constraints in place which turn this ability on or off when doing bulk changes?

As a simple example, let's say I have 3 issues with the fixVersion = "current". I decide that I would also like to add the fixVersion = "new" to these issues. I query them in the Issue tab and select "Bulk Change". I select all of them from the list, choose to bulk edit them, and select the 'Change fixVersions' option with the value "new".

My hope is that the outcome are 3 issues with the old AND the new fixversion (ie, "current" & "new" are both a fixVersion in the 3 issues).

Hope that makes sense! Let me know if this is possible or if there are any workarounds to do something like this.

2 answers

1 accepted

1 vote
Accepted answer

You can use Script Runner plugin and the following script to add Versions to a JQL search.

import com.atlassian.crowd.embedded.api.User
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.IssueManager
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 = XXX'
String projectKey = 'XXX'
String newVersion = '1.35'

IssueService issueService = ComponentAccessor.getIssueService()
IssueManager issueManager = ComponentAccessor.getIssueManager()
VersionManager versionManager = ComponentAccessor.getVersionManager()
ProjectManager projectManager = ComponentAccessor.getProjectManager()
IssueIndexManager indexManager = ComponentAccessor.getIssueIndexManager()
SearchService searchService = ComponentAccessor.getComponent(SearchService.class);

User user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
List<Issue> issues = null

SearchService.ParseResult parseResult =  searchService.parseQuery(user, jql);
if (parseResult.isValid()) {
    def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
    issues = searchResult.issues.collect {issueManager.getIssueObject(it.id)}
} else {
    log?.error("Invalid JQL: " + jql);

projectId = projectManager.getProjectObjByKey(projectKey)?.id
newVersionId = versionManager.getVersion(projectId, newVersion)?.id

if (newVersionId) {
        iiparams = issueService.newIssueInputParameters()
        iiparams.setRetainExistingValuesWhenParameterNotProvided(true, 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();
            } else {
                log.error uresult.getErrorCollection().getErrors()
        } else {
            log.error vresult.getErrorCollection().getErrors()

You have to adapt the three rows containing the JQL, the project and the version to your needs. The script only works for issues of one project because versions are project specific.

Please test the script on a test environment first, because I put it together by dragging and dropping parts from other scripts :-)


I'm almost sure you can do that with the Script Runner plugin. It's free and you can get it in the Atlassian Market. There's a lot of documentation for the plugin too. Check it out.

Hope this helps.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,173 views 5 10
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