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

Can't access variables in pipeline environment function parameters

    XMLWordPrintable

    Details

    • Epic Link:
    • Similar Issues:

      Description

      I'm trying to access "BRANCH_NAME" variable in "TEST" pipeline environment function parameters:

       

      @Library('manala') _
      
      pipeline {
        agent {
          docker 'manala/hugo'
        }
        environment {
          TEST = manalaDomainize("${env.BRANCH_NAME}")
        }
        stages {
          stage('Test') {
            steps {
              sh "echo $TEST"
            }
          }
        }
      }
      
      

      This breaks the build, returning:

       

      groovy.lang.MissingPropertyException: No such property: TEST for class: groovy.lang.Binding
      

      Without success, i've tried different syntaxes:

       

       

      TEST = manalaDomainize("$BRANCH_NAME")
      TEST = manalaDomainize("${BRANCH_NAME}")
      TEST = manalaDomainize("${env.BRANCH_NAME}")
      TEST = manalaDomainize(env.BRANCH_NAME)
      TEST = manalaDomainize(BRANCH_NAME)
      

       

      Of course, manalaDomainize() is a valid function, and everything is ok when i provide a simple string such as "foo".

       

        Attachments

          Issue Links

            Activity

            nervo nervo nervo created issue -
            hrmpw Patrick Wolf made changes -
            Field Original Value New Value
            Component/s pipeline-model-definition-plugin [ 21706 ]
            Component/s pipeline [ 21692 ]
            hrmpw Patrick Wolf made changes -
            Assignee Andrew Bayer [ abayer ]
            abayer Andrew Bayer made changes -
            Labels declarative-variable-and-method-resolution
            jamesdumay James Dumay made changes -
            Epic Link JENKINS-45422 [ 183590 ]
            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 ]

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                nervo nervo nervo
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: