【发布时间】:2017-07-11 15:30:49
【问题描述】:
鉴于以下 Jenkinsfile:
@NonCPS
void touchFiles() {
sh "touch foo"
sh "touch bar"
}
node('general') {
touchFiles()
sh "ls"
}
我在 Jenkins 的控制台日志中看到以下内容:
Running on box35 in /internal/slave/build/workspace/1499786637.EXAMPLE_test-repo_test_jenkinsfile
[Pipeline] {
[Pipeline] sh
[1499786637.EXAMPLE_test-repo_test_jenkinsfile] Running shell script
+ touch foo
[Pipeline] sh
[1499786637.EXAMPLE_test-repo_test_jenkinsfile] Running shell script
+ ls
foo
请注意,'bar' 尚未创建。
为什么只有第一个sh 在这里运行?如何在 Jenkinsfile 中分解出一系列 sh 调用?
(我知道我可以写 sh "touch foo; touch bar",但在更复杂的 Jenkinsfile 中,我有时需要单独的 sh 调用。)
【问题讨论】: