How do I invoke Global environment variables in Jenkinsfile? For example, if I have a variable -
name:credentialsId value:xxxx-xxxx-xxxxx-xxxxxxxxx
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] ] }