-
Bug
-
Resolution: Incomplete
-
Minor
-
None
-
Jenkins ver. 2.73.1
Plugins:
* Pipeline v2.5
* Pipeline: Declarative v1.2.5
* Pipeline: Job v2.15
In our environment, the home directory is a symlink to another location
ln -s /vol/slavedata/home.jenkins /home/jenkins
So the WORKSPACE environment variable in a test-pipeline job points to something like /home/jenkins/workspace/test-pipeline, and the real path would be /vol/slavedata/home.jenkins/workspace/test-pipeline
In a FreeStyle job I have the following groovy script:
def ws = new File(System.getenv('WORKSPACE')) // /home/jenkins/workspace/test-freestyle def ws2 = new File('/vol/slavedata/home.jenkins/workspace/test-freestyle') println ws.canonicalPath println ws2.canonicalPath
and the output is as expected:
/vol/slavedata/home.jenkins/workspace/test-freestyle /vol/slavedata/home.jenkins/workspace/test-freestyle
However, in a Pipeline job, a similar script:
pipeline { agent any stages { stage('test') { steps { script { def ws = new File(env.WORKSPACE) // /home/jenkins/workspace/test-pipeline def ws2 = new File('/vol/slavedata/home.jenkins/workspace/test-pipeline') echo ws.canonicalPath echo ws2.canonicalPath } } } } }
yields an unexpected result:
[Pipeline] echo /home/jenkins/workspace/test-pipeline [Pipeline] echo /vol/slavedata/home.jenkins/workspace/test-pipeline