Jenkins Pipeline cannot execute SH command file in a Windows slave

余生颓废 提交于 2019-12-01 05:28:49

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()
}

Attention

You still executing SH commands in a CMD, it means some %d for example can break your SH command.

As said in Jenkins' docs, you should use the bat step instead of sh.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!