Jenkins Pipeline无法在Windows从站中执行SH命令文件 [英] Jenkins Pipeline cannot execute SH command file in a Windows slave
问题描述
我正在执行以下代码:
node('my_windows_slave') {
sh 'ls'
}
在我的Windows从站中,我可以正确执行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:\workspace\sandbox_pipeline] Running shell script
sh: D:\workspace\sandbox_pipeline@tmp\durable-2d7dd2f8\script.sh: command not found
我可以注意到的是,一旦我尝试使用bat
并对其罚款,该.sh
文件甚至都不会创建.
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屋!