Scriptrunner - Cannot Release and Edit Version in the same Script

Hi all,

I'm having a strange issue when I try to release a Version and edit that Version's release date in the same script (see code below). If I try to do one or the other the change takes place just fine, but if I try to do both, only the second change works.

I've tried using VersionManager.update(version) to no avail, I've tried pausing for 10 seconds between function calls, and I've even tried running the two updates concurrently; no dice.

import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat

def project = ComponentAccessor.getProjectManager().getProjectByCurrentKey("project")
def versionManager = ComponentAccessor.getVersionManager()

def version = versionManager.getVersion(project.getId(), "3.4")

Date date = new SimpleDateFormat("yyyy-MM-dd").parse("2017-07-10")

//these are the updates in question
versionManager.releaseVersion(version, true) //this update will not persist
versionManager.editVersionReleaseDate(version, date) //this update will persist

Any advice would be great, thanks,


1 answer

1 accepted

Accepted Answer
1 vote

Hi Ben,

Your best off using VersionService to do this. It will do the validation for you and tell you exactly why you can't release or update a version.

Your script should look like the following which will release version "3.4" and set the release date as 2017-07-10.


import com.atlassian.jira.bc.project.version.VersionService
import com.atlassian.jira.component.ComponentAccessor

import java.text.SimpleDateFormat

def versionService = ComponentAccessor.getComponent(VersionService)
def projectManager = ComponentAccessor.getProjectManager()

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def project = projectManager.getProjectByCurrentKey("project")
def version = versionService.getVersionByProjectAndName(user, project, "3.4")

def releaseDate = new SimpleDateFormat("yyyy-MM-dd").parse("2017-07-10")

def result = versionService.validateReleaseVersion(user, version, releaseDate)

if (result.isValid()) {
} else {
    log.error "Could not relase version '${}' due to the following errors: $result.errorCollection.errors"

Hope this helps.



Thanks Adam, that worked perfectly for me!


Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

22,369 views 2 7
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