Can Jenkins work to execute a shell or a Windows command conditionally based on the operator’s operating system?

I am trying to create a task that will execute a program for remote agents. The program is exe when the agent is in Windows or the shell script when it is in Linux. The program is already deployed on agents. I am looking for a solution that would allow me to conditionally run exe (Windows executable command line) or the shell (Execute shell) depending on the operating environment of the agent.

So far, I have discovered that there is a plug-in for the conditions of execution ( https://wiki.jenkins-ci.org/display/JENKINS/Run+Condition+Plugin ), which would be great, unfortunately, it does not have validation for the operating system the operator.

Is there any way to do this? Google doesn't tell me anything.

+4
source share
1 answer

Find something that works:

https://www.techiepie.com/2016/04/14/how-to-identify-jenkins-slave-operating-system-in-a-build/

  • Add a conditional build step - one or more.
  • In run? Select "Execute Shell" and enter the echo "IsShell" command
  • Provide Linux command-line commands as steps to start if the condition is met.
  • Add one more step of conditional construction - one or more.
  • In run? Condition Select "Run Windows Command Commands" and enter the echo command "IsWindows"
  • Providing Windows command commands as steps to run if the condition is met.
+1

Source: https://habr.com/ru/post/1673139/


All Articles