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

bat pipeline with returnstdout=true echos command

      We updated to Jenkins LTS 2.401.1 via dockerhub. Since that version all our pipeline builds broke because the bat pipeline step seems to also return the command call itself in the result which it did not before. Powershell works.

       

      See the following code to reproduce the problem

      stage('Test') {
        steps {
          script {
            def result = bat(label: '', returnStdout: true, script: 'echo echotestresponse')
            echo "output from bat: $result"
            def psResult = powershell(label: '', returnStdout: true, script: 'echo echotestresponse')
            echo "output from powershell: $psResult"
          }
        }
      }

      Output is:

      17:17:18  [Pipeline] stage
      17:17:18  [Pipeline] { (Test)
      17:17:18  [Pipeline] script
      17:17:18  [Pipeline] {
      17:17:18  [Pipeline] bat
      17:17:18  [Pipeline] echo
      17:17:18  output from bat: 
      17:17:18  jenkins@HMJENKINS4 d:\jenkins\workspace\MPA_jenkins-fixing>echo echotestresponse 
      17:17:18  echotestresponse
      17:17:18  
      17:17:18  [Pipeline] powershell
      17:17:19  [Pipeline] echo
      17:17:19  output from powershell: echotestresponse
      17:17:19  
      17:17:19  [Pipeline] }
      17:17:19  [Pipeline] // script
      17:17:19  [Pipeline] }
      17:17:19  [Pipeline] // stage 

      Additionally there is also a new line character at start of the result now.

       

      A workaround seems to be to prefix any command with @ or @echo off explicitely.

          [JENKINS-71436] bat pipeline with returnstdout=true echos command

          Daniel created issue -
          Daniel made changes -
          Summary Original: bat pipeline step does not return stdout anymore New: bat pipeline step does not return stdout anymore with returnstdout=true
          Daniel made changes -
          Priority Original: Minor [ 4 ] New: Critical [ 2 ]
          Daniel made changes -
          Description Original: We updated to Jenkins LTS 2.401.1 via dockerhub. Since that version the bat pipeline step seems to be broken and does not return stdout anymore. The same code with powershell works.

           

          See the following code to reproduce the problem
          {code:java}
          stage('Test') {
            steps {
              script {
                def result = bat(label: '', returnStdout: true, script: 'echo echotest response')
                echo "output from bat: $result"

                def psResult = powershell(label: '', returnStdout: true, script: 'echo echotest response')
                echo "output from powershell: $psResult"
              }
            }
          } {code}
          Output is:

           
          {code:java}
          16:56:23 [Pipeline] stage
          16:56:23 [Pipeline] { (Test)
          16:56:23 [Pipeline] script
          16:56:23 [Pipeline] {
          16:56:23 [Pipeline] bat
          16:56:23 [Pipeline] echo
          16:56:23 output from bat:
          16:56:23 jenkins@HMJENKINS4 d:\jenkins\workspace\MPA_jenkins-fixing>echo echotest response
          16:56:23 echotest response
          16:56:23
          16:56:23 [Pipeline] powershell
          16:56:24 [Pipeline] echo
          16:56:24 output from powershell: echotest
          16:56:24 response
          16:56:24
          16:56:24 [Pipeline] }
          16:56:24 [Pipeline] // script
          16:56:24 [Pipeline] }
          16:56:24 [Pipeline] // stage
           {code}
           

          Variable is not set with output from stdout in bat step. See "output from bat:"

           
          New: We updated to Jenkins LTS 2.401.1 via dockerhub. Since that version all our pipeline builds are broken because the bat pipeline step seems to not return stdout anymore. The same code with powershell works.

           

          See the following code to reproduce the problem
          {code:java}
          stage('Test') {
            steps {
              script {
                def result = bat(label: '', returnStdout: true, script: 'echo echotest response')
                echo "output from bat: $result"

                def psResult = powershell(label: '', returnStdout: true, script: 'echo echotest response')
                echo "output from powershell: $psResult"
              }
            }
          } {code}
          Output is:

           
          {code:java}
          16:56:23 [Pipeline] stage
          16:56:23 [Pipeline] { (Test)
          16:56:23 [Pipeline] script
          16:56:23 [Pipeline] {
          16:56:23 [Pipeline] bat
          16:56:23 [Pipeline] echo
          16:56:23 output from bat:
          16:56:23 jenkins@HMJENKINS4 d:\jenkins\workspace\MPA_jenkins-fixing>echo echotest response
          16:56:23 echotest response
          16:56:23
          16:56:23 [Pipeline] powershell
          16:56:24 [Pipeline] echo
          16:56:24 output from powershell: echotest
          16:56:24 response
          16:56:24
          16:56:24 [Pipeline] }
          16:56:24 [Pipeline] // script
          16:56:24 [Pipeline] }
          16:56:24 [Pipeline] // stage
           {code}
           

          Variable is not set with output from stdout in bat step. See "output from bat:"

           
          Daniel made changes -
          Description Original: We updated to Jenkins LTS 2.401.1 via dockerhub. Since that version all our pipeline builds are broken because the bat pipeline step seems to not return stdout anymore. The same code with powershell works.

           

          See the following code to reproduce the problem
          {code:java}
          stage('Test') {
            steps {
              script {
                def result = bat(label: '', returnStdout: true, script: 'echo echotest response')
                echo "output from bat: $result"

                def psResult = powershell(label: '', returnStdout: true, script: 'echo echotest response')
                echo "output from powershell: $psResult"
              }
            }
          } {code}
          Output is:

           
          {code:java}
          16:56:23 [Pipeline] stage
          16:56:23 [Pipeline] { (Test)
          16:56:23 [Pipeline] script
          16:56:23 [Pipeline] {
          16:56:23 [Pipeline] bat
          16:56:23 [Pipeline] echo
          16:56:23 output from bat:
          16:56:23 jenkins@HMJENKINS4 d:\jenkins\workspace\MPA_jenkins-fixing>echo echotest response
          16:56:23 echotest response
          16:56:23
          16:56:23 [Pipeline] powershell
          16:56:24 [Pipeline] echo
          16:56:24 output from powershell: echotest
          16:56:24 response
          16:56:24
          16:56:24 [Pipeline] }
          16:56:24 [Pipeline] // script
          16:56:24 [Pipeline] }
          16:56:24 [Pipeline] // stage
           {code}
           

          Variable is not set with output from stdout in bat step. See "output from bat:"

           
          New: We updated to Jenkins LTS 2.401.1 via dockerhub. Since that version all our pipeline builds are broken because the bat pipeline step seems to not return stdout anymore. The same code with powershell works.

           

          See the following code to reproduce the problem
          {code:java}
          stage('Test') {
            steps {
              script {
                def result = bat(label: '', returnStdout: true, script: 'echo echotestresponse')
                echo "output from bat: $result"
                def psResult = powershell(label: '', returnStdout: true, script: 'echo echotestresponse')
                echo "output from powershell: $psResult"
              }
            }
          }{code}
          Output is:
          {code:java}
          17:17:18 [Pipeline] stage
          17:17:18 [Pipeline] { (Test)
          17:17:18 [Pipeline] script
          17:17:18 [Pipeline] {
          17:17:18 [Pipeline] bat
          17:17:18 [Pipeline] echo
          17:17:18 output from bat:
          17:17:18 jenkins@HMJENKINS4 d:\jenkins\workspace\MPA_jenkins-fixing>echo echotestresponse
          17:17:18 echotestresponse
          17:17:18
          17:17:18 [Pipeline] powershell
          17:17:19 [Pipeline] echo
          17:17:19 output from powershell: echotestresponse
          17:17:19
          17:17:19 [Pipeline] }
          17:17:19 [Pipeline] // script
          17:17:19 [Pipeline] }
          17:17:19 [Pipeline] // stage {code}
          Variable is not set with output from stdout in bat step. See "output from bat:"

           
          Daniel made changes -
          Component/s Original: batch-task-plugin [ 15505 ]
          Daniel made changes -
          Labels Original: jenkins pipeline plugin windows New: jenkins pipeline windows
          Mark Waite made changes -
          Assignee Original: Kohsuke Kawaguchi [ kohsuke ]
          Daniel made changes -
          Summary Original: bat pipeline step does not return stdout anymore with returnstdout=true New: bat pipeline with returnstdout=true echos command
          Daniel made changes -
          Priority Original: Critical [ 2 ] New: Major [ 3 ]
          Daniel made changes -
          Description Original: We updated to Jenkins LTS 2.401.1 via dockerhub. Since that version all our pipeline builds are broken because the bat pipeline step seems to not return stdout anymore. The same code with powershell works.

           

          See the following code to reproduce the problem
          {code:java}
          stage('Test') {
            steps {
              script {
                def result = bat(label: '', returnStdout: true, script: 'echo echotestresponse')
                echo "output from bat: $result"
                def psResult = powershell(label: '', returnStdout: true, script: 'echo echotestresponse')
                echo "output from powershell: $psResult"
              }
            }
          }{code}
          Output is:
          {code:java}
          17:17:18 [Pipeline] stage
          17:17:18 [Pipeline] { (Test)
          17:17:18 [Pipeline] script
          17:17:18 [Pipeline] {
          17:17:18 [Pipeline] bat
          17:17:18 [Pipeline] echo
          17:17:18 output from bat:
          17:17:18 jenkins@HMJENKINS4 d:\jenkins\workspace\MPA_jenkins-fixing>echo echotestresponse
          17:17:18 echotestresponse
          17:17:18
          17:17:18 [Pipeline] powershell
          17:17:19 [Pipeline] echo
          17:17:19 output from powershell: echotestresponse
          17:17:19
          17:17:19 [Pipeline] }
          17:17:19 [Pipeline] // script
          17:17:19 [Pipeline] }
          17:17:19 [Pipeline] // stage {code}
          Variable is not set with output from stdout in bat step. See "output from bat:"

           
          New: We updated to Jenkins LTS 2.401.1 via dockerhub. Since that version all our pipeline builds broke because the bat pipeline step seems to also return the command call itself in the result which it did not before. Powershell works.

           

          See the following code to reproduce the problem
          {code:java}
          stage('Test') {
            steps {
              script {
                def result = bat(label: '', returnStdout: true, script: 'echo echotestresponse')
                echo "output from bat: $result"
                def psResult = powershell(label: '', returnStdout: true, script: 'echo echotestresponse')
                echo "output from powershell: $psResult"
              }
            }
          }{code}
          Output is:
          {code:java}
          17:17:18 [Pipeline] stage
          17:17:18 [Pipeline] { (Test)
          17:17:18 [Pipeline] script
          17:17:18 [Pipeline] {
          17:17:18 [Pipeline] bat
          17:17:18 [Pipeline] echo
          17:17:18 output from bat:
          17:17:18 jenkins@HMJENKINS4 d:\jenkins\workspace\MPA_jenkins-fixing>echo echotestresponse
          17:17:18 echotestresponse
          17:17:18
          17:17:18 [Pipeline] powershell
          17:17:19 [Pipeline] echo
          17:17:19 output from powershell: echotestresponse
          17:17:19
          17:17:19 [Pipeline] }
          17:17:19 [Pipeline] // script
          17:17:19 [Pipeline] }
          17:17:19 [Pipeline] // stage {code}
          Additionally there is also a new line character at start of the result now.

           

          A workaround seems to be to prefix any command with @ or @echo off explicitely.

            Unassigned Unassigned
            dko Daniel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: