Hello,
I'd like to change the current workspace in a pipeleine script. My naive approach is the following script
pipeline {
agent any
environment {
WORKSPACE = '/home/sparsick'
}
stages {
stage('Build') {
steps {
sh 'echo $WORKSPACE'
sh 'pwd'
}
}
}
}
The output of this script:
Running on Jenkins in /home/sparsick/dev/jenkins-2.0/workspace/Workspace Change In Pipeline
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] sh
[Workspace Change In Pipeline] Running shell script
+ echo /home/sparsick
/home/sparsick
[Pipeline] sh
[Workspace Change In Pipeline] Running shell script
+ pwd
/home/sparsick/dev/jenkins-2.0/workspace/Workspace Change In Pipeline
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
I expected that the output of the pwd command is the same as the output of the echo command. But It isn't. So my question how I can change the current workspace in a pipeline script?
Thank you and best regards,
Sandra