-
New Feature
-
Resolution: Duplicate
-
Minor
In pipeline stages where a node could be windows or unix, it would be useful to have a generic command step for commands that are the same in batch or shell instead of requiring a conditional isUnix() block or custom function. Example use cases would be calling ruby or python scripts, or running other programs that have the same CLI on multiple platforms like doxygen, cmake etc.
My current workaround is:
def command(command) { if (isUnix()) { sh command } else { bat command } }
Or to reduce the number of isUnix calls and outputs in Blue Ocean or Stage View, have the isUnix bool an argument for the command method.
This is a simple workaround but somewhat annoying to need in either every jenkinsfile, or to need a global pipeline library for.
Example syntax:
command "echo Hello world!"
Not sure if "command" is an appropriate name but could really be anything.
It may also be helpful to some to be able to call specific programs/shells etc with arguments which could use a named argument form:
command command: "/bin/bash", arguments: "cat example.txt" command command: "/path/to/ruby", arguments: "my-script.rb"
or with arguments passed as an array which is seen in other applications:
command command: "/bin/bash", arguments: ["cat", "example.txt"]
- duplicates
-
JENKINS-26169 Workflow support for XShell plugin
- Open
-
JENKINS-44231 Safely pass args to sh step
- Open