gpt4 book ai didi

Jenkins Pipeline waitUntil bash命令返回特定字符串

转载 作者:行者123 更新时间:2023-12-02 10:12:37 26 4
gpt4 key购买 nike

我有一个管道阶段,我等待从 sh 脚本返回某个字符串,并且只有当字符串匹配时,才继续到下一个阶段,但是,它无法按预期工作:

node('master') {
stage("wait for bash completion") {
waitUntil {
def output = sh returnStdout: true, script: 'cat /tmp/test.txt'
output == "hello"
}
}
stage("execute after bash completed") {
echo "the file says hello!!!"
}
}

执行过程是这样的:

+ cat /tmp/test.txt
[Pipeline] }
Will try again after 0.25 sec
[Pipeline] {
[Pipeline] sh
[workspace] Running shell script
+ cat /tmp/test.txt
[Pipeline] }
Will try again after 0.3 sec
[Pipeline] {
[Pipeline] sh
[workspace] Running shell script
+ cat /tmp/test.txt
[Pipeline] }
Will try again after 0.36 sec
...
(so on and so forth)

我错过了什么?

最佳答案

来自waitUntil的帮助:

Runs its body repeatedly until it returns true. If it returns false, waits a while and tries again. --

您的执行输出看起来与等待 output == "hello" 匹配完全一样。也许文件 /tmp/test.txt 的内容并不完全是 hello。其中可能有一些空格,例如新行作为最后一个字符。

关于Jenkins Pipeline waitUntil bash命令返回特定字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53987649/

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