Has anyone found a way to pull a Version's Release Date out of Jira? We have ScripRunner, but I only find the releaseDate(release date query) function.
I need to add a column (using an Expr formula) to structures created with the Structure plugin that lists the Release Date.
The fact that an issue can be associated with multiple fix/affects versions probably complicates matters.
Thanks,
Jozef
There are two solutions to this. The first is to use a Scripted field:
import java.util.Date
Collection versions = issue.getFixVersions()
if (versions==null || versions.size() != 1) {
return null
}
else
{
def version = versions.iterator().next()
new Date(version.releaseDate.time)
}
I had to set the Custom Template to:
$datePickerFormatter.withStyle($dateTimeStyle.DATE).format($value)
However, a Scripted date field does not appear in the Date section. The better solution is to use a Listener (thanks Joe from Adaptavist) that fills out a field of type Date Picker and is linked to the Issue Updated event:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import java.util.Date
def issue = event.issue
def cFieldManager = ComponentAccessor.getCustomFieldManager()
def projectedReleaseDateField = cFieldManager.getCustomFieldObjectsByName("Proj Release Date")[0]
Collection versions = issue.getFixVersions()
if (versions==null || versions.size() != 1) {
projectedReleaseDateField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(projectedReleaseDateField), null), new DefaultIssueChangeHolder())
return null
}
else {
def version = versions.iterator().next()
def releaseDate = new Date(version.releaseDate.time)
projectedReleaseDateField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(projectedReleaseDateField), releaseDate.toTimestamp()), new DefaultIssueChangeHolder())
}
@Derek Fields _RightStar_ Thanks for the response. Apparently, there's more than one way to do this.
I want the Release Date field to show up in the Dates section, so I am using a regular Custom Field of type Date Picker and a Behaviour (a scripted field always appears in the Details section):
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Timestamp
import java.text.DateFormat
import java.util.Date
def releaseDateField = getFieldByName("Release Date")
Collection versions = underlyingIssue.getFixVersions()
if (versions==null || versions.size()!=1) {
return null
}
else {
def version = versions.iterator().next()
def releaseDate = new Date(version.releaseDate.time)
releaseDateField.setFormValue(releaseDate.format("dd/MMM/yyyy"))
}
However, it has 1 serious flaw: the new date value only appears on the View screen after the issue is edited a second time. No change needs to be made to it - just an Edit and Update makes the new date value appear. Any idea why that is? Even a re-index does not make it show up. I must be missing something obvious here...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I opened a ticket with Adaptavist for this, and it appears this does not work because the script reads the fix version of the field, and until the fix version is saved in the update/edit, it cannot read it as a proper fix version (but rather just a form value in the field).
They suggest to use a Listener instead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The Version object has a getReleaseDate() method that returns the release date.
It looks like you should be able to use VersionManager.getFixVersionsFor(issue) to get a collection of Fix Versions associated with the issue. Each of these can be queried using getReleaseDate() for the date.
Does that help?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.