My job has a build step Build - Execute shell, I only put these two command in:
echo $WORKSPACE
echo $PWD
And the output really confused me:
+ echo /home/jenkins/workspace/tradefed/test_deployment
/home/jenkins/workspace/tradefed/test_deployment
+ echo /media/d/workspace/tradefed/test_deployment
/media/d/workspace/tradefed/test_deployment
Why the value of $WORKSPACE
and $PWD
are different ?
Update 2019/03/18:
As @PavelAnikhouski mentioned, $WORKSPACE
is set relatively to your $JENKINS_HOME
, $PWD
is OS environment variable, refers to current working directory in file system, so they should not be the same.
But I am still confused about $WORKSPACE
, why Jenkins has $WORKSPACE
, but execute shell in another working directory ?
the workspace of build
andmy Linux working directory
? – Privy$WORKSPACE
. Why Jenkins needs$WORKSPACE
, but execute shell in another working directory ? – Privycd /some/other/place
but it makes sense as a default. Is there something else in your script that is changing which directory you're in? – Laveenecho
. I have some settings inSource Code Management - Git
andGerrit Tigger
, but I didn't specify any path or change directory. – Privy