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

Shell script taking/returning output/status

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Currently sh has no meaningful return value, and throws an exception if the exit status is not zero. Would be nice to have an option to have it return the exit code (zero or not) as an integer value:

      def r = sh script: 'someCommand', returnStatus: true
      

      Current workaround:

      sh 'someCommand; echo $? > status'
      def r = readFile('status').trim()
      

      Or to have it return its standard output (akin to shell backticks):

      def lines = sh(script: 'dumpStuff.sh', returnStdout: true).split("\r?\n")
      

      Workaround:

      sh 'dumpStuff.sh > result'
      def lines = readFile('result').split("\r?\n")
      

      Or to have it take something on standard input:

      sh script: 'loadStuff.sh', stdin: someText
      

      Workaround:

      writeFile file: 'input', text: someText
      sh 'loadStuff.sh < input'
      

      Probably requires some API changes in durable-task.

        Attachments

          Issue Links

            Activity

            jglick Jesse Glick created issue -
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Link This issue is duplicated by JENKINS-26812 [ JENKINS-26812 ]
            jglick Jesse Glick made changes -
            Link This issue is duplicated by JENKINS-28302 [ JENKINS-28302 ]
            jglick Jesse Glick made changes -
            Link This issue is related to JENKINS-29877 [ JENKINS-29877 ]
            jglick Jesse Glick made changes -
            Link This issue is related to JENKINS-27152 [ JENKINS-27152 ]
            jglick Jesse Glick made changes -
            Link This issue is duplicated by JENKINS-33173 [ JENKINS-33173 ]
            jglick Jesse Glick made changes -
            Link This issue is related to JENKINS-34331 [ JENKINS-34331 ]
            jglick Jesse Glick made changes -
            Link This issue is related to JENKINS-34331 [ JENKINS-34331 ]
            jglick Jesse Glick made changes -
            Link This issue is duplicated by JENKINS-34331 [ JENKINS-34331 ]
            hrmpw Patrick Wolf made changes -
            Labels api api followup
            jglick Jesse Glick made changes -
            Epic Link JENKINS-35394 [ 171187 ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "PR 11 (Web Link)" [ 14622 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 160123 ] JNJira + In-Review [ 185560 ]
            jglick Jesse Glick made changes -
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Resolved [ 5 ]
            abayer Andrew Bayer made changes -
            Component/s pipeline-general [ 21692 ]
            abayer Andrew Bayer made changes -
            Component/s workflow-plugin [ 18820 ]
            jcarsique Julien Carsique made changes -
            Component/s workflow-durable-task-step-plugin [ 21715 ]
            drewish andrew morton made changes -
            Link This issue is related to JENKINS-44930 [ JENKINS-44930 ]

              People

              Assignee:
              jglick Jesse Glick
              Reporter:
              jglick Jesse Glick
              Votes:
              50 Vote for this issue
              Watchers:
              64 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: