Hi,
I'm trying to write a quick script that sets a custom variable called "Environment" which is a single pull-down selectable choice of the following values:
None
Dev
Test
QA
QA2
Prod
I have a Custom Listener setup as "VersionReleaseEvent and when I made my release, it does appear to be triggering my script which errors out immediately before and of my debug log statements even run.
Once a release happens, I want my custom variable "Environment" set to "Prod".
The code I've written is the following and it is erroring out on the event.issue line
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import org.apache.log4j.Logger
import org.apache.log4j.Level
def mylog = Logger.getLogger("PushReleaseVersionToProd")
// Set log level
mylog.setLevel(Level.DEBUG)
def issue = event.issue as Issue
def EnvFieldName = 'Environment'
mylog.debug "EnvFieldName is $EnvFieldName"
def customFieldManager = ComponentAccessor.customFieldManager
def EnvField = customFieldManager.getCustomFieldObjects(issue).findByName(EnvFieldName)
assert EnvField : "Could not find custom field with name $EnvFieldName"
mylog.debug "EnvField is $EnvField at end of script"
EnvField = "Prod"
The error log is the following:
2021-07-29 14:18:32,284 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2021-07-29 14:18:32,286 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.project.VersionReleaseEvent, file: null
groovy.lang.MissingPropertyException: No such property: issue for class: com.atlassian.jira.event.project.VersionReleaseEvent
at PushReleaseVersionToProd.run(PushReleaseVersionToProd.groovy:15)
I'd appreciate any help in trying to suss out what the issue may be.
Thanks,
Jeff