How to determine the current operating system in a Jenkins pipeline

后端 未结 5 1315
醉梦人生
醉梦人生 2020-12-28 21:31

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

5条回答
  •  悲哀的现实
    2020-12-28 21:47

    As far as I know Jenkins only differentiates between windows and unix, i.e. if on windows, use bat, on unix/mac/linux, use sh. So you could use isUnix(), more info here, to determine if you're on unix or windows, and in the case of unix use sh and @Spencer Malone's answer to prope more information about that system (if needed).

提交回复
热议问题