Jenkins file 如下:
pipeline { agent {label 'master'} stages { stage ('tttt') { steps { sh "pwd" sh "mkdir aaa" dir('aaa') { sh "pwd" } sh "pwd"
echo "----------------------------"
sh "cd aaa"
sh "pwd"
} } } }
dir 只改变wrap 内的路径,退出wrap,路径恢复到原来的地方
cd 命令根本不起效!
Running on Jenkins in /applications/jenkins/workspace/ssh_test [Pipeline] { [Pipeline] stage [Pipeline] { (tttt) [Pipeline] sh + pwd /applications/jenkins/workspace/ssh_test [Pipeline] sh + mkdir aaa [Pipeline] dir Running in /applications/jenkins/workspace/ssh_test/aaa [Pipeline] { [Pipeline] sh + pwd /applications/jenkins/workspace/ssh_test/aaa [Pipeline] } [Pipeline] // dir [Pipeline] sh + pwd /applications/jenkins/workspace/ssh_test
[Pipeline] echo ---------------------------- [Pipeline] sh + cd aaa [Pipeline] sh + pwd /applications/jenkins/workspace/ssh_test
标签:Pipeline,aaa,cd,pwd,sh,jenkins,test,Jenkins,dir From: https://www.cnblogs.com/qgbo/p/18281248