Hello,
I am new to jira and been trying to get this script to run.
Iam working on a Server Installation on Version 7.5.2.
I am trying to achieve the following:
When a issue is created or updated, the dueDate of the issue will be set to the associated fixVersion releaseDate.
It tried a bit, but didn't get to far:
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Category
def Category log = Category.getInstance("com.onresolve.jira.groovy")
log.setLevel(org.apache.log4j.Level.DEBUG)
def issue = event.issue
def project = issue.getProjectObject()
project.getVersions().each {
log.debug it
}
log.debug issue.getFixVersions()
I am stuck at now loading the Versions based on the name, that I got. To then retrieve the release date, if equal to the Issue.fixVersion.
I know the script needs to check if exactly one fixVersion is defined and only then it should run. But Iam far away from this step yet.
I hope somebody can help me with that. It would speedup our workenvironment immensely.
SOLVED
Thanks to @Tarun Sapra here is the complete solution:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
IssueManager issueManager = ComponentAccessor.getComponent(IssueManager.class)
def issue = (MutableIssue)event.issue
def version = (Version)issue.getFixVersions().first()
if(version) {
def releaseDate = version.getReleaseDate()
if(releaseDate) {
issue.setDueDate(new java.sql.Timestamp(releaseDate.getTime()))
issueManager.updateIssue(event.getUser(), issue , EventDispatchOption.ISSUE_UPDATED, false)
}
}