Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,643
Community Members
 
Community Events
185
Community Groups

How to fix syntax error on Groovy Jira post function containing it.label

In preparation for a Jira upgrade from 6.4.13 to 7.0.11, I am trying to remove all deprecation and error messages displayed in the post function groovy scripts, as recommended by ScriptRunner vendor Adaptavist.  The Script Runner plugin is being upgraded after the Jira upgrade from 4.1.3.24 to 5.1.6.2.

I am seeing this error in the 5.1.6.2 version of Script Runner in Jira 7.0.11:

[Static Type Checking] No Such Property: label for class:  java.lang.Object

This is for it.label on the else if line of code.  What do I need to do to make that line of code compliant with the syntax checking?  

Code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.util.JiraUtils
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl

import java.io.FileInputStream
import java.util.Properties

def log = org.apache.log4j.Category.getInstance('com.onresolve.jira.groovy.PostFunction')
log.setLevel(org.apache.log4j.Level.DEBUG)

def config = new Properties()
def configFile = new File("/usr/local/jira_app/scripts/config/${transientVars['pkey']}.properties")

config.load(new FileInputStream(configFile))

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def applicableStepsField = customFieldManager.getCustomFieldObjectByName(config.getProperty('fields.steps'))
def applicableSteps = issue.getCustomFieldValue(applicableStepsField)

def actionId = transientVars['actionId']
def step = config.getProperty("actions.${actionId}.step")
def skipTo = config.getProperty("actions.${actionId}.skipTo")

if (!step || !skipTo) {
log.error("#skipUpgradeActionNotConfigured actionId: ${actionId}, step: ${step}, skipTo: ${skipTo}")
} else if (!applicableSteps?.any() { it.label == config.getProperty("steps.${step}") }) {
log.info("Skipping ${step} and transitioning to ${skipTo} on action ${actionId} for upgrade order ${issue}")

def workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)

workflowTransitionUtil.setIssue(issue)
workflowTransitionUtil.setUserkey(config.getProperty('user'))
workflowTransitionUtil.setAction(config.getProperty("transitions.${skipTo}").toInteger())
workflowTransitionUtil.validate()
workflowTransitionUtil.progress()
}

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events