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.
          Hide
          mpokorny Martin added a comment -

          Great idea. I personally do that in our internal TestNode class. But there will be also Great to logs some useful information like NODE_NAME, time stamp and duration.

          Show
          mpokorny Martin added a comment - Great idea. I personally do that in our internal TestNode class. But there will be also Great to logs some useful information like NODE_NAME, time stamp and duration.

            People

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

              Dates

              Created:
              Updated: