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

load step fails to bind "complex" @Field defined variables

    XMLWordPrintable

Details

    Description

      for more complex variables that are annotated with @Field, the load step fails to bind the variable into the Script class.

      For example:

      // a.groovy
      import groovy.transform.Field
      
      @Field
      def LOADED_BUILD_NUMBER = ${env.BUILD_NUMBER}
      
      return this
      
      // Jenkinsfile
      node() {
        def a = load('a.groovy')
        echo(${env.BUILD_NUMBER})
        echo(${a.LOADED_BUILD_NUMBER})
      }
      

      This example will fail. However, if you replace ${env.BUILD_NUMBER} with a simple type such as `3`, the load step will succeed.

       

      This seems to be related to the security update in workflow-cps v2.64 and the subsequent regression fix for @Field in v2.71.

      Attachments

        Activity

          duemir Denys Digtiar created issue -
          duemir Denys Digtiar made changes -
          Field Original Value New Value
          Description for more complex variables that are annotated with @Field, the load step fails to bind the variable into the Script class.

          For example:
          {code:java}
          // a.groovy
          import groovy.transform.Field

          @Field
          def LOADED_BUILD_NUMBER = ${env.BUILD_NUMBER}

          return this

          // Jenkinsfile
          node() {
            def a = load('a.groovy')
            echo(${env.BUILD_NUMBER})
            echo(${a.LOADED_BUILD_NUMBER})
          }
          {code}
          {{}}

          This example will fail. However, if you replace ${env.BUILD_NUMBER} with a simple type such as `3`, the load step will succeed.

           

          This seems to be related to the security update in workflow-cps v2.64 and the subsequent regression fix for @Field in v2.71.
          for more complex variables that are annotated with @Field, the load step fails to bind the variable into the Script class.

          For example:
          {code:java}
          // a.groovy
          import groovy.transform.Field

          @Field
          def LOADED_BUILD_NUMBER = ${env.BUILD_NUMBER}

          return this

          // Jenkinsfile
          node() {
            def a = load('a.groovy')
            echo(${env.BUILD_NUMBER})
            echo(${a.LOADED_BUILD_NUMBER})
          }
          {code}
          This example will fail. However, if you replace ${env.BUILD_NUMBER} with a simple type such as `3`, the load step will succeed.

           

          This seems to be related to the security update in workflow-cps v2.64 and the subsequent regression fix for @Field in v2.71.
          llibicpep Dee Kryvenko made changes -
          Priority Minor [ 4 ] Critical [ 2 ]

          People

            Unassigned Unassigned
            duemir Denys Digtiar
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: