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.