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

              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: