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

option to trim stdout on sh / bat

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Would it be possible to add an option like "trimOutput" to apply trim() to returnStdout without having to wrap the `sh` / `bat` steps in `script{}`?

       

      Edit:

      To clarify what I mean
      currently
      script {
           date = sh(
               script: "date +%Y%m%d",
               returnStdout: true).trim()
      }

      proposed:
      date = sh script: "date +%Y%m%d",
                returnStdout: true,
                trimOutput: true

       

      It's a simple thing and I assume quite common, but it would make pipelines more readable and it would be easier to figure out for people new to Jenkins if the option was right there in the docs, instead of having to hunt for it on StackOverflow.

        Attachments

          Activity

          bgdnlp Bogdan Lp created issue -
          bgdnlp Bogdan Lp made changes -
          Field Original Value New Value
          Description Would it be possible to add an option like "trimOutput" to apply trim() to returnStdout without having to wrap the `sh` / `bat` steps in `script{}`? Would it be possible to add an option like "trimOutput" to apply trim() to returnStdout without having to wrap the `sh` / `bat` steps in `script{}`?

           

          Edit:

          To clarify what I mean
           currently
           {{script {}}
           {{     date = sh(}}
           {{         script: "date +%Y%m%d",}}
           {{         returnStdout: true).trim()}}
           {{}}}

          proposed:
           {{date = sh script: "date +%Y%m%d",}}
           {{          returnStdout: true,}}
           {{          trimOutput: true}}

           

          It's a simple thing and I assume quite common, but it would make pipelines more readable and it would be easier to figure out for people new to Jenkins if the option was right there in the docs, instead of having to hunt for it on StackOverflow.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            bgdnlp Bogdan Lp
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: