Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-44991

Add cross-platform command step



    • Similar Issues:


      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"]


          Issue Links


            inkychris Chris Wright created issue -
            inkychris Chris Wright made changes -
            Field Original Value New Value
            Component/s workflow-durable-task-step-plugin [ 21715 ]
            Component/s workflow-basic-steps-plugin [ 21712 ]
            jglick Jesse Glick made changes -
            Link This issue duplicates JENKINS-26169 [ JENKINS-26169 ]
            jglick Jesse Glick made changes -
            Link This issue duplicates JENKINS-44231 [ JENKINS-44231 ]
            jglick Jesse Glick made changes -
            Resolution Duplicate [ 3 ]
            Status Open [ 1 ] Resolved [ 5 ]


              Unassigned Unassigned
              inkychris Chris Wright
              0 Vote for this issue
              2 Start watching this issue