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

Add cross-platform command step

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              inkychris Chris Wright
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: