Hello,
I have been attempting to automatically set the fixVersion of a ticket during a transition post function. So that when someone progresses the ticket its set automatically to latest unreleased version.
I have attempted all the suggestions I found googling (largely from this community) but failed.
I scrambled together all the snippets and with some digging in the API docs i managed to get it to a state where it runs successfully but doesnt apply the change. If anyone can help me figure out what I am doing wrong?
Self hosted Jira server 7.13.5
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import org.apache.log4j.Logger
import org.apache.log4j.Level
def versionManager = ComponentAccessor.getVersionManager()
def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectObjByKey(issue.projectObject.key)
def id = issue.getProjectId()
def uversions = versionManager.getVersionsUnreleased(id, false).collect()
def log = Logger.getLogger("UpdateFixVersion")
log.setLevel(Level.DEBUG)
log.info uversions
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
issue.setFixVersions(uversions)
The above produces a successful run after testing it with a ticket but it doesnt update the fix version.
Prints the correct version in the logs:
2020-01-30 16:37:30,151 INFO [UpdateFixVersion]: [COSM-20-05]
Ive tried setting the issue.setFixVersions(uversions) above and below the updateIssue function with the same result
UPDATE: Correct answer was supplied by @Leo in the last few comments. The problem was related to the order in which the post functions were arranged