i had a script written similar to fast track transition and it was loading properly in JIRA 5.2 version. It was working absolutely fine. But then the system got upgraded to 6.0 and script didnt work mainly because of the new namespace of scriptrunner. But inspite of changing this i cannot find the script along with the other scripts in the script runner. is there any other change to be done?
in JIRA 5.2.5 scripts were deployed at :
jira\webapp\WEB-INF\classes\com\onresolve\jira\groovy\canned\workflow\postfunctions
in JIRA 6.3 it is at
\jira\webapp\WEB-INF\classes\com\onresolve\scriptrunner\canned\jira\workflow\postfunctions
package com.onresolve.scriptrunner.canned.jira.workflow.postfunctions; import groovy.util.logging.Log4j; import java.util.List; import java.util.Map; import com.atlassian.crowd.embedded.api.User import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.config.SubTaskManager import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.MutableIssue import com.onresolve.scriptrunner.canned.CannedScript; import com.onresolve.scriptrunner.canned.util.BuiltinScriptErrors; import com.onresolve.scriptrunner.canned.util.SimpleBuiltinScriptErrors import com.onresolve.scriptrunner.runner.customisers.ScriptListener; import com.onresolve.scriptrunner.canned.jira.utils.ConditionUtils import com.onresolve.scriptrunner.canned.jira.utils.CannedScriptUtils import com.onresolve.scriptrunner.canned.jira.utils.WorkflowUtils @ScriptListener @Log4j public class FasttrackTransition1 implements CannedScript { public final static String FIELD_TRIGGER_CONDITION = "FIELD_TRIGGER_CONDITION" public final static String FIELD_TARGET_ISSUE_ACTION = "FIELD_TARGET_ISSUE_ACTION" public final static String FIELD_TRANSITION_ORDER = "FIELD_TRANSITION_ORDER" public final String FIELD_ADDITIONAL_SCRIPT = "FIELD_ADDITIONAL_SCRIPT" @Override public String getName() { return "FT : Transition issue/s based on transition order & conditions."; } @Override public String getDescription(Map params, boolean forPreview) { getName() + """ If the condition <b><i> ${params[FIELD_TRIGGER_CONDITION]}</b></i> is met, action <b><i> ${params[FIELD_TARGET_ISSUE_ACTION]} </b></i> will be applied based on the transition order <b><i> ${params[FIELD_TRANSITION_ORDER]} </b></i>.""" } @Override public List getCategories() { ["Function"] } @Override public List getParameters(Map<String, String> arg0) { [ ConditionUtils.getConditionParameter(), [ Name:FIELD_TRANSITION_ORDER, Label:"Transition Order", Description:"Choose the transition order for performing the transitions", Type: "list", Values: ["SBI->Parent":"SBI->Parent","Parent->SBI":"Parent->SBI"] ], [ Name:FIELD_TRIGGER_CONDITION, Label:"Trigger Conditions", Description:"Choose the trigger conditions for the issue", Type:"list", Values: ["Any":"Any","All":"All"] ], [ Name:FIELD_TARGET_ISSUE_ACTION, Label:"Workflow Action", Description:"Choose the action to be performed on the task or subtask based on the transition order", Type: "list", Values:CannedScriptUtils.getAllWorkflowActions(false) ], [ Name:FIELD_ADDITIONAL_SCRIPT, Label:"Additional code", Type:"text", Description: """Additional script to run before the issue is stored. Use this to modify fields or add a comment etc.""", Examples: [ "Set comment (4.1 and above)": "issueInputParameters.setComment(\\'Some comment\\')", "Set assignee (4.1 and above)" : "issueInputParameters.setAssigneeId(\\'someuser\\')", ], ], ] } @Override public Map doScript(Map params) { String triggerOption = params[FIELD_TRIGGER_CONDITION] as String String targetAction = params[FIELD_TARGET_ISSUE_ACTION] as String String transitionOrder = params[FIELD_TRANSITION_ORDER] as String String additionalScript = params[FIELD_ADDITIONAL_SCRIPT] as String MutableIssue currentIssue = params['issue'] as MutableIssue log.info("currentissue" + currentIssue) Integer actionId = targetAction?.replaceAll(/ .*/, "") as Integer log.info("actionid" + actionId) if(transitionOrder=="SBI->Parent") { MutableIssue parent = currentIssue.getParentObject() as MutableIssue log.info("parent" + parent) User user = parent.getAssignee() log.info("user "+ user) //Check for condition Boolean doIt = ConditionUtils.processCondition(params[ConditionUtils.FIELD_CONDITION] as String, parent, false,params) log.info("doIt" + doIt) log.info("triggeroption" + triggerOption) if(doIt) { if(triggerOption=="Any") { WorkflowUtils.actionIssue(params[FIELD_ADDITIONAL_SCRIPT] as String, parent, actionId, user, params) } //This code needs to be refined & revisited if(triggerOption=="All") { //boolean allState = parent.getSubTaskObjects().every {Issue issue -> issue.statusObject.getName()=="Execution"} log.info("target action" + targetAction) String result = targetAction.matches(/.{0,3}$/) log.info("result" + result) boolean allState = parent.getSubTaskObjects().every {Issue issue -> issue.statusObject.getName()==issue.statusObject.getName()} if(allState) { WorkflowUtils.actionIssue(params[FIELD_ADDITIONAL_SCRIPT] as String, parent, actionId, user, params) } } } } //Here following scenarios can be identified. //a) If PBI is closed then all SBIs should be closed //b) If PBI is cancelled then all SBIs should be cancelled //c) If PBI moves from cancelled/closed to some other states then SBIs should move to the designated state if(transitionOrder=="Parent->SBI") { log.info("current issue" + currentIssue) SubTaskManager subtaskmgr = ComponentAccessor.getSubTaskManager() Collection<MutableIssue> sbiIssues = subtaskmgr.getSubTaskObjects(currentIssue) Boolean doIt = ConditionUtils.processCondition(params[ConditionUtils.FIELD_CONDITION] as String, currentIssue, false,params) if(doIt) { //If parent issue is not in cancel or closed state. Basically states other than cancel/close when the issue is moved back from the //dead end state to the working state if(!(currentIssue.getStatusObject().name.contains("Cancel")) || !(currentIssue.getStatusObject().name.contains("Close"))) { for(MutableIssue sbiIssue : sbiIssues) { User user = sbiIssue.getAssignee() WorkflowUtils.actionIssue(params[FIELD_ADDITIONAL_SCRIPT] as String, sbiIssue, actionId, user, params) } } //If parent issue gets cancelled, move all sbis to cancel if(currentIssue.getStatusObject().name.contains("Cancel")) { for(MutableIssue sbiIssue : sbiIssues) { if(targetAction.contains("Cancel")) { User user = sbiIssue.getAssignee() WorkflowUtils.actionIssue(params[FIELD_ADDITIONAL_SCRIPT] as String, sbiIssue, actionId, user, params) } } } //If parent issue gets closed, move all sbis to closed if(currentIssue.getStatusObject().name.contains("Close")) { for(MutableIssue sbiIssue : sbiIssues) { if(targetAction.contains("Close")) { User user = sbiIssue.getAssignee() WorkflowUtils.actionIssue(params[FIELD_ADDITIONAL_SCRIPT] as String, sbiIssue, actionId, user, params) } } } } } } @Override public BuiltinScriptErrors doValidate(Map params, boolean forPreview) { def errorCollection = new SimpleBuiltinScriptErrors() if (! params[FIELD_TRIGGER_CONDITION]) { errorCollection.addError(FIELD_TRIGGER_CONDITION, "You must provide a trigger condition: Any/And.") } if (! params[FIELD_TARGET_ISSUE_ACTION]) { errorCollection.addError(FIELD_TARGET_ISSUE_ACTION, "You must provide an action.") } if (! params[FIELD_TRANSITION_ORDER]) { errorCollection.addError(FIELD_TRANSITION_ORDER, "You must provide a transition order: PBI->SBI / SBI->PBI .") } errorCollection } @Override public String getDescription() { return "FT : Transition issue/s"; } @Override public Boolean isFinalParamsPage(Map arg0) { // TODO Auto-generated method stub return null; } }
It needs to go outside of the JIRA installation directory, and into a script root: https://jamieechlin.atlassian.net/wiki/display/GRV/Upgrading+to+3.0#Upgradingto3.0-ScriptRoots
This will make it easier to upgrade JIRA in future.
Thanks Jamie. But even then i cant see my script when i add script postfunction to the workflow.i have made the required namespace change too in the script to support jira 6.3 version.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Placed the script in target\jira\home\scripts
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i have attached the code too
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie.Could you please help me with this script loading?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online 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.