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 platf
Assuming you have Windows as your only non-unix platform, you can use the pipeline function isUnix() and uname to check on which Unix OS you're on:
def checkOs(){
if (isUnix()) {
def uname = sh script: 'uname', returnStdout: true
if (uname.startsWith("Darwin")) {
return "Macos"
}
// Optionally add 'else if' for other Unix OS
else {
return "Linux"
}
}
else {
return "Windows"
}
}