XShell Plugin

Skip to end of metadata
Go to start of metadata

Plugin Information

Plugin ID xshell Changes In Latest Release
Since Latest Release
Latest Release
Latest Release Date
Required Core
Nov 10, 2013
Source Code
Issue Tracking
Open Issues
Marco Ambu (id: mambu)
Usage Installations 2013-Apr 491
2013-May 495
2013-Jun 545
2013-Jul 567
2013-Aug 569
2013-Sep 587
2013-Oct 613
2013-Nov 626
2013-Dec 632
2014-Jan 668
2014-Feb 696
2014-Mar 705

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.

What it does...

  • It runs any executable (with complete command line) available in the system from current working dir (command must be in Path or in job's workspace directory or subdirectory).
  • Automatic conversion of file separator is done according to the executing operating system.


  • the current working directory of the command execution is always the job's workspace root.
  • ./ must not be included in command line (use the configuration switch provided to specify that command is in current working dir or subdir).


Example 1: run executable + script
php scripts/build.php

runs php (must be in Path) with scripts/build.php as argument (path relative to workspace; forward slashes can be used because php handles them correctly in any OS).

this command is equivalent to the following

php scripts\build.php

The file separator will be automatically translated to the right one, according to the operating system running during execution.

... and what it does not!

Command translation problem


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:

rm -rf bin
del /F /S bin

and then call clean using an XShell build step.
This will execute clean in unix and clean.bat in windows.

Variable expansion problem


Translate variable expansion syntax in the command line provided to the plugin. So you want to write something like this:

myscript $JOBPARAM1


myscript %JOBPARAM1%

This won't work because each of this command will only work in one OS, not in both.


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:

myscript $JOBPARAM1
myscript %JOBPARAM1%

and then call script-wrapper using an XShell build step.
This will execute script-wrapper in unix and script-wrapper.bat in windows.


  • in windows you can call clean and get clean.bat called, in unix you can't (so the solutions above work);
  • in unix you have to specify if the command is in the current working dir (and if it is not available it will not be searched in PATH), in windows you haven't to.

Build step configuration

To add a XShell build step

  • click on the Add build step button and choose Invoke XShell script;
  • fill in the command line text;
  • choose if the executable is in global Path or in workspace.


  • Allow execution from a custom working dir (different from workspace dir)
  • Run executable from workspace directory (in unix must be written using ./ form). DONE in 0.2
  • Replace any '\' or '/' in the command line with File.separator
  • Set environment variables... (see comments)

Version history

Version 0.10 (Dev)

Version 0.9 (Nov 10, 2013)

Version 0.8 (Apr 11, 2012)

Version 0.7 (Dec 29, 2011)

  • Added environment variable format conversion (e.g. $VAR to %VAR% for Windows launcher) - Thanks to tclif (https://github.com/tclift)

Version 0.6 (Mar 1, 2011)

  • Updates for Jenkins

Version 0.4 (Sep 22, 2010)

  • Modified regex for path separator replacement that was causing an exception issue #7538
  • Added build variables to environment variables (as in CommandInterpreter).

Version 0.3 (May 18, 2010)

  • Replace any '\' or '/' in the command line with correct file separator (selected using OS where the task is executed).

Version 0.2 (Mar 26, 2010)

  • Run executable from workspace directory also in unix.

Version 0.1 (Mar 25, 2010)

  • Initial release
  • Runs a single command line


plugin-builder plugin-builder Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Add Comment