parallel tee sh garbles output

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      When running the tee command on parallel stages the console output becomes garbled.  The stage name is displayed directly over other stage names, and output is mangled together.

      pipeline {
          agent any
          stages {
              stage('stage') {
                  steps {
                      script {
                          parallel ((1..20).collect{it}.collectEntries {stageNumber ->
                              ["$stageNumber": {
                                  node('master') {
                                      stage("$stageNumber") {
                                          tee('output.log') {
                                              sh("for i in 1 2 3 4 5; do sleep 1; echo $stageNumber \$i; done")
                                          }
                                      }
                                  }
                              }]
                          })
                      }
                  }
              }
          }
      }
      

      Will produce console output such as:

      ...
      + for i in 1 23 3 4 5
      +  4s l5e
      e+p  3s
      leep 3
      ++ e cehcoh o5  62 
      25
       ​62 2+ ​+f ofro ri  ii ni n1  12  23  34  455
      ...

       

      However, this behaves nominally if the tee block does not call sh:

                                              [1, 2, 3, 4, 5].each {
                                                  sleep 1
                                                  echo "$stageNumber $it "
                                              }

       

            Assignee:
            rsandell
            Reporter:
            James Sassano
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: