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

Variables and functions are no longer binding in a when/expression since version 1.1

    Details

    • Similar Issues:

      Description

      So this was working fine before Pipeline Model Definition version 1.1.
      ==============================
      #!/usr/bin/env groovy
       
      def SKIP_BUILD = false
       
      pipeline {
          stages {
              stage('build') {
                  when {
                      expression {
                          return !SKIP_BUILD
                      }
                  }
                  steps {
                     echo "Do build work here."
                      **                
                  }
              }
       
          }
       
      }
      ================================
       
      In version 1.0.1 the variable "SKIP_BUILD" was bound correctly and the expression could properly evaluate it.
       
      As of version 1.1 (and still in 1.1.4) this results in 
      groovy.lang.MissingPropertyException: No such property: SKIP_BUILD for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) Same issue if I was trying to use a function in an expression, it used to work now it does not bind. Both bind fine outside of the expression block.
       
      This is blocking me from upgrading Pipeline plugins for Jenkins

        Attachments

          Issue Links

            Activity

            eserating Erik Serating created issue -
            abayer Andrew Bayer made changes -
            Field Original Value New Value
            Labels declarative-variable-and-method-resolution
            jamesdumay James Dumay made changes -
            Summary Declarative Pipeline - Variables and functions are no longer binding in a when/expression since version 1.1 Variables and functions are no longer binding in a when/expression since version 1.1
            jamesdumay James Dumay made changes -
            Epic Link JENKINS-45426 [ 183594 ]
            Hide
            abayer Andrew Bayer added a comment -

            This is fixed as part of JENKINS-42753, there's a relevant test there, and it'll be included in the upcoming Declarative 1.2 release.

            Show
            abayer Andrew Bayer added a comment - This is fixed as part of JENKINS-42753 , there's a relevant test there, and it'll be included in the upcoming Declarative 1.2 release.
            abayer Andrew Bayer made changes -
            Link This issue depends on JENKINS-42753 [ JENKINS-42753 ]
            abayer Andrew Bayer made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            Hide
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            Show
            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.
            bitwiseman Liam Newman made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                eserating Erik Serating
              • Votes:
                3 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: