title: How to determine the current operating system in a Jenkins pipeline
body: <p>What would be the way to determine the current OS a Jenkins pipeline is running?</p>
  
  <p>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.</p>
  
  <p>I tried something like:</p>
  
  <pre class="lang-java prettyprint-override"><code>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")
  }
  </code></pre>
  
  <p>But even it is running on windows or mac <code>node</code> it always goes into the <code>SystemUtils.IS_OS_LINUX</code> branch</p>
  
  <p>I tried a quick pipeline like this. </p>
  
  <pre><code>node('windows ') {
       println ('## OS ' + System.properties['os.name'])
  }
  node('osx ') {
       println ('## OS ' + System.properties['os.name'])
  }
  node('linux') {
       println ('## OS ' + System.properties['os.name'])
  }
  </code></pre>
  
  <p>Each node get correctly run in a machine with the correct OS but all of them print <code>## OS Linux</code></p>
  
  <p>any ideas?</p>
  
  <p>Thanks
  Fede</p>