## Advanced Syntax for Pipeline 

## String Interpolation 

Jenkins Pipeline uses rules identical to Groovy for string interpolation. Groovy’s String interpolation support can be confusing to many newcomers to the language. While Groovy supports declaring a string with either single quotes, or double quotes, for example: 

def singlyQuoted = 'Hello' def doublyQuoted = "World" 

Only the latter string will support the dollar-sign ( $ ) based string interpolation, for example: 

def username = 'Jenkins' echo 'Hello Mr. ${username}' echo "I said, Hello Mr. ${username}" 

Would result in: 

Hello Mr. ${username} I said, Hello Mr. Jenkins 

Understanding how to use string interpolation is vital for using some of Pipeline’s more advanced features. 

## Working with the Environment 

Jenkins Pipeline exposes environment variables via the global variable env , which is available from anywhere within a Jenkinsfile . The full list of environment variables accessible from within Jenkins Pipeline is documented at localhost:8080/pipeline-syntax/globals#env, assuming a Jenkins master is running on localhost:8080 , and includes: 

## BUILD_ID 

The current build ID, identical to BUILD_NUMBER for builds created in Jenkins versions 1.597+ 

## JOB_NAME 

Name of the project of this build, such as "foo" or "foo/bar". 

## JENKINS_URL 

Full URL of Jenkins, such as example.com:port/jenkins/ (NOTE: only available if Jenkins URL set in "System Configuration") 

Referencing or using these environment variables can be accomplished like accessing any key in a Groovy Map, for example: 

