[JIRA] (JENKINS-57735) Cannot use groovy with() on {{currentBuild}}

1 view
Skip to first unread message

Aaron.Marasco@BIA-Boeing.com (JIRA)

unread,
May 29, 2019, 7:05:02 AM5/29/19
to jenkinsc...@googlegroups.com
Aaron Marasco created an issue
 
Jenkins / Bug JENKINS-57735
Cannot use groovy with() on {{currentBuild}}
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline
Created: 2019-05-29 11:04
Environment: Jenkins 2.150.3
Pipeline 2.6
Priority: Minor Minor
Reporter: Aaron Marasco

Trying to follow the Groovy Style Guide's item 9 "Using with() and tap() for repeated operations on the same bean:"

    currentBuild.with {
      result = 'FAILURE'
      description += "\nFailed in ${stage_name} stage"
    }

Resulted in:

groovy.lang.MissingPropertyException: No such property: description for class: groovy.lang.Binding
 	at groovy.lang.Binding.getVariable(Binding.java:63)
 	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:264)
 	at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:288)
 	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:292)
 	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
 	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
...

The workaround is simply:

    currentBuild.result = 'FAILURE'
    currentBuild.description += "\nFailed in ${stage_name} stage"
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)
Reply all
Reply to author
Forward
0 new messages