gpt4 book ai didi

shell - Jenkins Pipeline 插件看似跳过命令

转载 作者:行者123 更新时间:2023-12-01 09:31:46 24 4
gpt4 key购买 nike

我有一个 Jenkins Pipeline plugin脚本看起来像这样:

stage("check out project") {
shell "pwd"
echo "test 1"
git credentialsId: "user", url: "http://url/project"
echo "test 2"
shell "git --version"
echo "test 3"
}

构建的输出是这样的:

[Pipeline] stage
[Pipeline] { (check out project)
[Pipeline] echo
test 1
[Pipeline] echo
test 2
[Pipeline] echo
test 3
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS

从输出和构建时间来看,只执行了 echo 命令。所有其他的都被忽略。似乎没有发生错误。

如何让所有命令都被执行?

最佳答案

您的脚本成功运行并按预期工作

  1. node{ }
  2. 包围它
  3. 使用 sh 代替 shell

像这样:

node{
stage("check out project") {
sh "pwd"
echo "test 1"
git credentialsId: '12341234-1234-1234-1234-123412341234', url: "git@github.com:sendgrid/sendgrid-java.git"
echo "test 2"
sh "git --version"
echo "test 3"
}
}

关于shell - Jenkins Pipeline 插件看似跳过命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40804522/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com