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