Last active
November 13, 2018 11:28
Star
You must be signed in to star a gist
JIRA process approval. MyGroovy + Custom select. All process in 1 workflow status.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.atlassian.jira.component.ComponentAccessor | |
import groovy.json.JsonSlurper | |
cfStep = ComponentAccessor.customFieldManager.getCustomFieldObject(10003)//Text Field (single line) | |
cfCustomSelect = ComponentAccessor.customFieldManager.getCustomFieldObject(10004)//Custom Select List | |
def customSelectValue = issue.getCustomFieldValue(cfCustomSelect) | |
def processApproval = parseText(customSelectValue.getData()) | |
def currentStepName = issue.getCustomFieldValue(cfStep) | |
def currentStep | |
if(currentStepName){ | |
currentStep = processApproval.steps.find{it.name == currentStepName} | |
} else { | |
return false | |
} | |
def nextStep = getNextStep(currentStep, processApproval) | |
if(nextStep){ | |
return false | |
} | |
return true | |
def getNextStep(currentStep, processApproval){ | |
int indexCurrentStep = processApproval.steps.lastIndexOf(currentStep) | |
int nextIndex = indexCurrentStep + 1 | |
if(nextIndex >= processApproval.steps.size()){ | |
return null | |
} else { | |
return processApproval.steps.get(nextIndex) | |
} | |
} | |
def parseText(text) { | |
def jsonSlurper = new JsonSlurper() | |
return jsonSlurper.parseText(text) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment