Jenkins Pipeline 无法在 Windows 从站中执行 SH 命令文件 [英] Jenkins Pipeline cannot execute SH command file in a Windows slave
问题描述
我正在执行这段代码:
node('my_windows_slave') {
sh 'ls'
}
在我的 Windows slave 中,我可以正确执行 sh
命令:
In my Windows slave I can properly execute sh
command:
但是流水线脚本无法运行.sh
文件:
But the pipeline script can't run the .sh
file:
[Pipeline] sh
[D:workspacesandbox_pipeline] Running shell script
sh: D:workspacesandbox_pipeline@tmpdurable-2d7dd2f8script.sh: command not found
我注意到的是,这个 .sh
文件甚至没有被创建,一旦我尝试使用 bat
并且工作正常.
What I could notice is that this .sh
file is not even created, once I tried with bat
and worked fined.
任何线索可能是什么问题?
Any clue what could be the problem?
[更新]
Jenkins 无法创建 SH
临时文件.已经检查了日志、权限以及我想到的所有内容.
Jenkins somehow can't create the SH
temporary file. Already checked the log, permissions, everything that came to my mind.
推荐答案
一旦我仍然不能 100% 确定根本原因并且可能其他人出现一个优雅的解决方案...
I will leave my workaround as an answer for while before approve it once I'm still not 100% sure about the root cause and might someone else show up with a elegant solution...
def shell(command) {
return bat(returnStdout: true, script: "sh -x -c "${command}"").trim()
}
<小时>
注意
您仍然在 CMD
中执行 SH
命令,这意味着某些 %d
可能会破坏您的 SH
命令.
You still executing SH
commands in a CMD
, it means some %d
for example can break your SH
command.
这篇关于Jenkins Pipeline 无法在 Windows 从站中执行 SH 命令文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!