I am trying to get the current workspace of my Jenkins build using a Groovy pipeline script:
node('master') { // PULL IN ENVIRONMENT VARIABLES // Jenkins makes these variables available for each job it runs def buildNumber = env.BUILD_NUMBER def workspace = env.WORKSPACE def buildUrl = env.BUILD_URL // PRINT ENVIRONMENT TO JOB echo "workspace directory is ${workspace}" echo "build URL is ${env.BUILD_URL}" } It returns:
[Pipeline] Allocate node : Start Running on master in /Users/Shared/Jenkins/Home/jobs/test/workspace [Pipeline] node { [Pipeline] echo workspace directory is null [Pipeline] echo build URL is http://localhost:8080/job/test/5/ [Pipeline] } //node [Pipeline] Allocate node : End [Pipeline] End of Pipeline Finished: SUCCESS