Reputation: 81
I'm trying to build a job that will execute a program on remote agents. The program is either exe when agent is on Windows or shell script when it is on Linux. The program is already deployed on agent machines. I'm looking for a solution that would allow me to conditionally run either exe (Execute Windows batch command) or shell (Execute shell) depending on the agent's OS.
So far I found there is a run condition plugin (https://wiki.jenkins-ci.org/display/JENKINS/Run+Condition+Plugin), whuch would be great, unfortunatelly it does not have check for agent's OS.
Is there any way to accomplish that? Google tells me nothing.
Upvotes: 5
Views: 6871
Reputation: 18831
The solution that I found that avoids any exceptions in the output is:
For Windows, compare that these strings match:
${ENV,var="OS"}
Windows_NT
For Linux, compare that these strings match:
${ENV,var="OS"}
(The second string is left blank.)
Upvotes: 1
Reputation: 81
Found something that seems to work:
https://www.techiepie.com/2016/04/14/how-to-identify-jenkins-slave-operating-system-in-a-build/
Upvotes: 3