I\'m executing this code:
node(\'my_windows_slave\') {
sh \'ls\'
}
In my Windows slave I can properly execute sh command:
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.
bat step instead of sh.From Jenkins docs:
Windows-based systems should use the bat step for executing batch commands.