Jenkins Pipeline cannot execute SH command file in a Windows slave

后端 未结 2 1321
無奈伤痛
無奈伤痛 2021-01-12 16:25

I\'m executing this code:

node(\'my_windows_slave\') {
   sh \'ls\'
}

In my Windows slave I can properly execute sh command:

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-12 16:54

    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.

提交回复
热议问题