This plugin defines a new build type to execute a shell command in a cross-platform environment.
Cross platform shell executor.
Using Jenkins built-in "Execute Windows batch command" you can run commands using the windows shell.
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.
This plugin does exactly this: it takes a command, as the two standard build steps do, and executes it calling the correct shell depending on the operating system running on the current job executor.
$JOBPARAM1
is converted to %JOBPARAM1%
in theConstraints:
Examples:
Example 1: run executable + script with parameter
Write your command in the *nix style:
php scripts/build.php $JOBPARAM1
If the command runs on a *nix node, the command runs un-altered. If it runs on a Windows node, it is changed to:
php scripts\build.php %JOBPARAM1%
Note that the file separator and variable naming convention have changed.
It cannot translate any command! So you cannot write
rm -rf bin
because on windows rm
command is not available.
You can wrap your commands in two scripts, one for windows and one for unix, each one calling the right command for the operating system:
clean
rm -rf bin
clean.bat
del /F /S bin
and then call clean
using an XShell build step.
This will execute clean
in unix and clean.bat
in windows.
To add a XShell build step
Add build step
button and chooseInvoke XShell script
;