| Alright, just discovered some odd behavior. If the Stdout is returned, then the script will fail as expected... I would expect both to return a postive exit code! The downside of using returnStdout is that none of that output will be displayed in the logs.
pipeline {
agent any
stages {
stage('gobbledygook - will pass') {
steps{
powershell script: 'gobbledygook'
}
}
stage('gobbledygook - will fail') {
steps{
powershell returnStdout: true, script: 'gobbledygook'
}
}
}
}
And this is the output:
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in C:\jenkins_workspace\Jenkins Playground\PowershellErrorExample
[Pipeline] {
[Pipeline] stage
[Pipeline] { (gobbledygook - will pass)
[Pipeline] powershell
powershell.exe : gobbledygook : The term 'gobbledygook' is not recognized as the name of a cmdlet, function, script file, or operable
At C:\jenkins_workspace\Jenkins Playground\PowershellErrorExample@tmp\durable-805172ca\powershellWrapper.ps1:3 char:1
+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (gobbledygook : ...e, or operable :String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\jenkins_workspace\Jenkins Playground\PowershellErrorExample@tmp\durable-805172ca\powershellScript.ps1:1 char:1
+ gobbledygook
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (gobbledygook:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (gobbledygook - will fail)
[Pipeline] powershell
gobbledygook : The term 'gobbledygook' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At C:\jenkins_workspace\Jenkins Playground\PowershellErrorExample@tmp\durable-bf7e742d\powershellScript.ps1:1 char:1
+ gobbledygook
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (gobbledygook:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
|