Jenkins Global environment variables in Jenkinsfile

后端 未结 5 1126
深忆病人
深忆病人 2021-02-05 06:17

How do I invoke Global environment variables in Jenkinsfile?
For example, if I have a variable -

 name:credentialsId 
 value:xxxx-xxxx-xxxxx-xxxxxxxxx
         


        
5条回答
  •  余生分开走
    2021-02-05 06:36

    When referring to env in Groovy scope, simply use env.VARIABLE_NAME, for example to pass on BUILD_NUMBER of upstream job to a triggered job:

    stage ('Starting job') {
        build job: 'TriggerTest', parameters: [
            [$class: 'StringParameterValue', name: 'upstream_build_number', value: env.BUILD_NUMBER]
        ]
    }
    

提交回复
热议问题