Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-47927

Final text fields cannot use other fields to initialize

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None
    • Jenkins 2.73.7
      Pipeline 2.5

      I would expect this to work, but it doesn't:

      @Field final yum_base = '/export/www/yum/'
      @Field final repo_path_base = "${yum_base}${env.BRANCH_NAME}/"
      

      The second line gives me a NullPointerException:

      ...
      Seen branch in repository origin/v1.2.0
      Seen 37 remote branches
      Obtained releng/jenkins/runtime/groovy/Jenkinsfile_Job1.groovy from 39d085cb3ae81592f1965672e8e7f2bb0f6708d2
      java.lang.NullPointerException
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.$build(CpsScript.java:141)
      	at org.jenkinsci.plugins.workflow.cps.EnvActionImpl$Binder.getValue(EnvActionImpl.java:147)
      	at org.jenkinsci.plugins.workflow.cps.EnvActionImpl$Binder.getValue(EnvActionImpl.java:142)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:121)
      	at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:456)
      	at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:284)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:286)
      	at org.kohsuke.groovy.sandbox.impl.Checker$checkedGetProperty$3.callStatic(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:230)
      	at WorkflowScript.<init>(WorkflowScript:29)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at java.lang.Class.newInstance(Class.java:442)
      	at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:434)
      Caused: groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class WorkflowScript. Reason
      	at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:466)
      	at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
      	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:129)
      	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:123)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:517)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:480)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:269)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:421)
      

      Looks like JENKINS-34599, but wasn't fixed by it.

            Unassigned Unassigned
            aarondmarasco_vsi Aaron D. Marasco
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: