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.
Using Jenkins built-in "Execute shell" you can run commands using unix shell. If you need to run a job cross platform you cannot use the two standard executors provided by Jenkins. You need a "build step" that can be executed both in Windows and in Unix.
Jenkins web console > Manage Jenkins > Configure System > Under shell, set the "Shell executable" = C:\cygwin64\bin\sh.exe > Click apply & also click save.
Found something that seems to work:
https://www.techiepie.com/2016/04/14/how-to-identify-jenkins-slave-operating-system-in-a-build/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With