Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Jenkins how can you detect if a server is Windows vs. Linux?

On Jenkins I'm using the Conditional BuildStep Plugin. Is there a way to have it run some build steps depending on whether or not the slave node it's running on is Windows vs. Linux?

like image 879
twasbrillig Avatar asked Sep 20 '25 06:09

twasbrillig


1 Answers

You can use isUnix() function available in jenkins for identifying the OS type.

So you can use something like below inside your jenkinsfile under script block:-

 if (isUnix()) {
    sh 'ls -la'
} else {
    bat 'dir'
}
like image 105
user_9090 Avatar answered Sep 22 '25 03:09

user_9090