post_functions
This is an old revision of the document!
Table of Contents
Post Functions
Post functions allow you to perform specific actions upon the transition. Following are some useful examples.
Add Comment on Transition
import com.atlassian.jira.component.ComponentAccessor def commentManager = ComponentAccessor.getCommentManager() def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() commentManager.create( issue, currentUser, "This is my comment", false)
Update Fix Version/s field with first Unreleased version
import com.atlassian.jira.component.ComponentAccessor def versionManager = ComponentAccessor.getVersionManager() def projectManager = ComponentAccessor.getProjectManager() def project = projectManager.getProjectObjByKey(issue.projectObject.key) def versions = versionManager.getVersions(project) def firstUnreleasedFound = versions.find{! it.released} //check if there are versions, then update if (firstUnreleasedFound) { issue.setFixVersions([firstUnreleasedFound]) issue.store() } else { UserMessageUtil.error("MANUAL INTERVENTION REQUIRED!!! No Unreleased Fix Version Found. Please add a Fix Version manually to this ticket....") }
post_functions.1515709092.txt.gz · Last modified: (external edit)
