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

Can't access variables in pipeline environment function parameters

XMLWordPrintable

      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".

       

            abayer Andrew Bayer
            nervo nervo nervo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: