Jenkins Pipeline无法在Windows从站中执行SH命令文件 [英] Jenkins Pipeline cannot execute SH command file in a Windows slave

查看:1480
本文介绍了Jenkins Pipeline无法在Windows从站中执行SH命令文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行以下代码:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆