Search code examples
jenkinsjenkins-pluginsjenkins-job-dsl

isUnix for jenkins job dsl?


I use the isUnix function in my pipeline jobs, it would be nice if the jobs dsl also had this feature (I still need to use it for some things pipelines cant do). If not how do you check for windows or linux inside of a jenkins job dsl script?


Solution

  • Job DSL script:

    import org.apache.commons.lang.SystemUtils
    
    if (SystemUtils.IS_OS_UNIX || SystemUtils.IS_OS_MAC) {
      println 'linux'
      job('jobname') {
        //job steps
      }
    }
    else {
      println 'windows'
    }