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

parallel tee sh garbles output

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

       

            rsandell rsandell
            jamessassano James Sassano
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: