I've created the script below to transition related tickets. I tested it using Script Runner and by adding an issue as a string in .getIssueObject().
def issue = constantsManager.getIssueManager().getIssueObject('AM-1234')
How can I get/pass the current issue that is transitioning into the scope of the Post Function? New to Groovy/JAVA and JIRA. :)
// Transition script to transition an inWardLinked issue status when related link is approved
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
import com.atlassian.jira.util.JiraUtils
def constantsManager = ComponentManager.getInstance()
WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil)JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class )
def issue = constantsManager.getIssueManager().getIssueObject('AM-1234')
def issueLinkManager = constantsManager.getIssueLinkManager()
def relatedLinks = issueLinkManager.getInwardLinks(issue.id)
relatedLinks.each {issueLink ->
def linkedIssue = issueLink.getSourceObject()
// If related linktype is not in ABTEST project and it's status is "in design" transition status to approved
if (issueLink.issueLinkType.name == "Related" && linkedIssue.getProjectObject().getKey() != "ABTEST" && linkedIssue.getStatusObject().getName() == "In Design"){
workflowTransitionUtil.setIssue(linkedIssue)
workflowTransitionUtil.setAction(421) // design approved - see text view of workflow to get transition ids
workflowTransitionUtil.progress()
}}
Community moderators have prevented the ability to post new answers.
It's in the script binding, which means you just refer to it without declaring it. So just comment out your line 15 and it should work.
I removed line 15 and line 17 started to fail. So I then tested in Script Runner with line 17 set t0
def relatedLinks = issueLinkManager.getInwardLinks()
This run without error in Script Runner but did nothing when I ran the transistion Post Function. Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That doesn't make any sense... the line you mention above is not valid. Can you add some logging...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for slow reply.. got torn away for a while. Error log is.
[onresolve.jira.groovy.GroovyCondition] Script condition failed on DWORK-2092: issueLinkManager.getInwardLinks(issue.getId())*.issueLinkType.name.contains('Related')
java.lang.Exception: Cannot find a script engine for extension: "contains('Related')", (make sure it's on the classpath).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sounds like you are pasted this into the text box that is for putting in a path to a file. Can you attach a screenshot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This error occurs when I transition the issue to the approved state and the post function runs. This isn't from running the Script Runner add-on. Is that what you were thinking?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This error occurs when I transition the issue to the approved state and the post function runs. This isn't from running the Script Runner add-on. Is that what you were thinking?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, it is from the script runner plugin... can you upload a screenshot of the config page for the workflow function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is what I see when I run the script in the text box. http://screencast.com/t/jfx04kya2
I get the same error when running from file.
http://screencast.com/t/szBcIAjhaR2
These are different errors to what I get when I transition an issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But it needs to be set up as a post-function. The admin script console is just a REPL for testing or running one-time scripts.
You need to edit a workflow, add a post-function, script function, then put the path to the file there, then publish the workflow, then test by putting an issue through that transition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The original error is from when I add it as a post-function and tested by transitioning an issue through the transition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.