Hi i had a script in listener that is working fine before suddenly it is failing now after upgrade of my jira vesion 9.4.1
error I am getting is below
Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: null
groovy.lang.MissingMethodException: No signature of method: java.lang.String.getAt() is applicable for argument types: (com.atlassian.jira.issue.label.Label) values: [tesr]
Possible solutions: getAt(groovy.lang.EmptyRange), getAt(int), getAt(groovy.lang.Range), getAt(java.util.Collection), getAt(groovy.lang.Range), getAt(int)
at Script28.run(Script28.groovy:55)
my script is
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.event.type.EventType
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.label.Label
import com.atlassian.jira.issue.label.LabelManager
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.MutableIssue
//If project category is not technology, quit without any checks
if (event.project?.projectCategory?.name != "Technology") {
return
}
def envURL = ComponentAccessor.getApplicationProperties().getString("jira.baseurl")
def issueManager = ComponentAccessor.issueManager
def labelManager = ComponentAccessor.getComponent(LabelManager)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueIndexingService = ComponentAccessor.getComponentOfType(IssueIndexingService.class)
def piCustomField, piLabelCustomField,piHistoryCustomField
if (envURL == "https://jira-preprod.nets.no") {
piCustomField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_18570")
piLabelCustomField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_18870")
piHistoryCustomField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_19770")
}
else if (envURL == "https://jira-dev.nets.no") {
piCustomField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_15783")
piLabelCustomField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_15871")
piHistoryCustomField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_16482")
}
def issue = event.issue as MutableIssue
def changeHolder = new DefaultIssueChangeHolder()
//If issue is created and there is value added to program increment custom field, copy the value
if (event.eventTypeId.equals(EventType.ISSUE_CREATED_ID) && issue.getCustomFieldValue(piCustomField)) {
Issue piIssue = (Issue) issue.getCustomFieldValue(piCustomField)
def summaryText = piIssue.summary.replace(" ", "-")
def summaryLabel = new Label(null, issue.id, piLabelCustomField.idAsLong, summaryText)
piLabelCustomField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(piLabelCustomField), [summaryLabel] as Set), changeHolder)
issueIndexingService.reIndex(issue)
}
//If issue is updated and program increment custom field is in list, copy updated value
else if (event.eventTypeId.equals(EventType.ISSUE_UPDATED_ID) && event.changeLog?.getRelated("ChildChangeItem")?.any { it.field == piCustomField.name }) {
def change = event.changeLog?.getRelated("ChildChangeItem")?.find { it.field == piCustomField.name }
def issueKey = (String) change.newstring
def piIssue = issueManager.getIssueByCurrentKey(issueKey)
def oldIssueKey = (String) change.oldstring
def oldPIIssue = issueManager.getIssueByCurrentKey(oldIssueKey)
def summaryText = piIssue ? piIssue.summary.replace(" ", "-") : ""
def summaryLabel = new Label(null, issue.id, piLabelCustomField.idAsLong, summaryText)
def summarySet = summaryText ? [summaryLabel] as Set : [] as Set
piLabelCustomField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(piLabelCustomField), summarySet), changeHolder)
if (issue.issueType.name == "Epic" && oldPIIssue.status.statusCategory.name != "New") {
def oldSummaryText = oldPIIssue ? oldPIIssue.summary.replace(" ", "-") : ""
labelManager.addLabel(currentUser, issue.id, piHistoryCustomField.idAsLong, oldSummaryText, false)
}
issueIndexingService.reIndex(issue)
}
can anyone help me to resolve this
Could you plesae help me to fix the above script
What version of Scriptrunner were you using and what version did you upgrade to?
Could be a groovy change or just a breaking change from the plugin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
we are using Version 7.4 Script runner after upgrading to Jira 9.4.1 it's not working again we tried degraded version 6.38.0 and also tried it's failing these are all happening after our Jira upgraded to 9.4.1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if it is a groovy change what needs to be updated in the above script could you please help with updating the above script
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: null
This is the error I am getting Vesion of script runner I am using is 7.9.0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the Error
ERROR [runner.AbstractScriptListener]: *************************************************************************************
2023-02-01 12:05:55,480 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: null
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.