-
Type:
Bug
-
Resolution: Won't Fix
-
Priority:
Major
-
Component/s: workflow-cps-global-lib-plugin
-
None
If there is a class in a library as well as some vars and the class's constructor tries to a var from the same library the new()'s result will be the var's result and not a class of the requested type.
Â
Sample code:
src/com/test/X.groovy:
package com.test public final class X {   public final String result   public X(def steps) {     if (steps.y())       result = 'y returned TRUE'     else       result = 'y returned FALSE'   } }
Â
vars/y.groovy:
def call() {
  return false
}
Â
Jenkinsfile:
lib = library 'testLib' x = lib.com.test.X(this) echo "x = $x" echo "result = ${x.result}"
Â
If testLib is set to contain the above code and the Jenkinsfile executed, then it will print:
x = false
and throw an exception:
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such field found: field java.lang.Boolean result
Â
Calling into vars from other class methods seems to work fine.