What would be the way to determine the current OS a Jenkins pipeline is running?
Context: I'm building a shared Jenkins pipeline script that should run on all platforms (windows, OSX, linux) and execute something different in each platform.
I tried something like:
import org.apache.commons.lang.SystemUtils
if (SystemUtils.IS_OS_WINDOWS){
bat("Command")
}
if (SystemUtils.IS_OS_MAC){
sh("Command")
}
if (SystemUtils.IS_OS_LINUX){
sh("Command")
}
But even it is running on windows or mac node
it always goes into the SystemUtils.IS_OS_LINUX
branch
I tried a quick pipeline like this.
node('windows ') {
println ('## OS ' + System.properties['os.name'])
}
node('osx ') {
println ('## OS ' + System.properties['os.name'])
}
node('linux') {
println ('## OS ' + System.properties['os.name'])
}
Each node get correctly run in a machine with the correct OS but all of them print ## OS Linux
any ideas?
Thanks Fede