Skip to content

Instantly share code, notes, and snippets.

@chuikoaleksandr
Last active November 13, 2018 11:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chuikoaleksandr/057bb90942a5d647c530761d196f5404 to your computer and use it in GitHub Desktop.
JIRA process approval. MyGroovy + Custom select. All process in 1 workflow status.
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