-
Bug
-
Resolution: Unresolved
-
Minor
In the Release Notes for Powershell support, it is stated clearly, with an example, that writing to the error stream in powershell will fail that stage:
Your powershell step may produce a failing exit status in the following instances:
- Something in your PowerShell script has thrown an exception
- Your PowerShell script explicitly calls exit with a non-zero exit code
- Your PowerShell script calls a native application that produces a non-zero $LastExitCode
- Your PowerShell script results in a non-empty error stream (with or without throwing an exception)
However, if I try that myself, the stage succeeds (though error output is still written to the console):
pipeline { agent { label 'windows' } options { skipDefaultCheckout() durabilityHint('PERFORMANCE_OPTIMIZED') } stages { stage('write-error') { steps { powershell 'write-error "bang"' } } } }
[write-error] powershell.exe : C:\Jenkins\workspace\owpos\pos\frp\00-build@tmp\durable-2fc4febd\powershellScript.ps1 : bang [write-error] At C:\Jenkins\workspace\owpos\pos\frp\00-build@tmp\durable-2fc4febd\powershellWrapper.ps1:3 char:1 [write-error] + & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ... [write-error] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [write-error] + CategoryInfo : NotSpecified: (C:\Jenkins\work...ript.ps1 : bang:String) [], RemoteException [write-error] + FullyQualifiedErrorId : NativeCommandError [write-error] [write-error] At line:1 char:1 [write-error] [write-error] + & 'C:\Jenkins\workspace\owpos\pos\frp\00-build@tmp\durable-2fc4febd\p ... [write-error] [write-error] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [write-error] [write-error] + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException [write-error] [write-error] + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,powershellScript.ps1 [write-error] [write-error] [write-error]
The plugin should behave like the documentation.
[JENKINS-54036] Write-Error in powershell step behaves confusingly
Labels | New: error exit failure powershell |
Description |
Original:
In the [Release Notes for Powershell support|https://jenkins.io/blog/2017/07/26/powershell-pipeline/], it is stated clearly, with an example, that writing to the error stream in powershell will fail that stage: {quote} Your powershell step may produce a failing exit status in the following instances: * Something in your PowerShell script has thrown an exception * Your PowerShell script explicitly calls exit with a non-zero exit code * Your PowerShell script calls a native application that produces a non-zero $LastExitCode * *Your PowerShell script results in a non-empty error stream (with or without throwing an exception)* {quote} However, if I try that myself, the stage succeeds (though error output is still written to the console): {noformat} pipeline { agent { label 'windows' } options { skipDefaultCheckout() durabilityHint('PERFORMANCE_OPTIMIZED') } stages { stage('write-error') { steps { powershell 'write-error "bang"' } } } } } {noformat} {noformat} [write-error] powershell.exe : C:\Jenkins\workspace\owpos\pos\frp\00-build@tmp\durable-2fc4febd\powershellScript.ps1 : bang [write-error] At C:\Jenkins\workspace\owpos\pos\frp\00-build@tmp\durable-2fc4febd\powershellWrapper.ps1:3 char:1 [write-error] + & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ... [write-error] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [write-error] + CategoryInfo : NotSpecified: (C:\Jenkins\work...ript.ps1 : bang:String) [], RemoteException [write-error] + FullyQualifiedErrorId : NativeCommandError [write-error] [write-error] At line:1 char:1 [write-error] [write-error] + & 'C:\Jenkins\workspace\owpos\pos\frp\00-build@tmp\durable-2fc4febd\p ... [write-error] [write-error] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [write-error] [write-error] + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException [write-error] [write-error] + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,powershellScript.ps1 [write-error] [write-error] [write-error] {noformat} The plugin should behave like the documentation. |
New:
In the [Release Notes for Powershell support|https://jenkins.io/blog/2017/07/26/powershell-pipeline/], it is stated clearly, with an example, that writing to the error stream in powershell will fail that stage: {quote} Your powershell step may produce a failing exit status in the following instances: * Something in your PowerShell script has thrown an exception * Your PowerShell script explicitly calls exit with a non-zero exit code * Your PowerShell script calls a native application that produces a non-zero $LastExitCode * *Your PowerShell script results in a non-empty error stream (with or without throwing an exception)* {quote} However, if I try that myself, the stage succeeds (though error output is still written to the console): {noformat} pipeline { agent { label 'windows' } options { skipDefaultCheckout() durabilityHint('PERFORMANCE_OPTIMIZED') } stages { stage('write-error') { steps { powershell 'write-error "bang"' } } } } {noformat} {noformat} [write-error] powershell.exe : C:\Jenkins\workspace\owpos\pos\frp\00-build@tmp\durable-2fc4febd\powershellScript.ps1 : bang [write-error] At C:\Jenkins\workspace\owpos\pos\frp\00-build@tmp\durable-2fc4febd\powershellWrapper.ps1:3 char:1 [write-error] + & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ... [write-error] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [write-error] + CategoryInfo : NotSpecified: (C:\Jenkins\work...ript.ps1 : bang:String) [], RemoteException [write-error] + FullyQualifiedErrorId : NativeCommandError [write-error] [write-error] At line:1 char:1 [write-error] [write-error] + & 'C:\Jenkins\workspace\owpos\pos\frp\00-build@tmp\durable-2fc4febd\p ... [write-error] [write-error] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [write-error] [write-error] + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException [write-error] [write-error] + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,powershellScript.ps1 [write-error] [write-error] [write-error] {noformat} The plugin should behave like the documentation. |
Issue Type | Original: New Feature [ 2 ] | New: Bug [ 1 ] |
Labels | Original: error exit failure powershell | New: error exit failure powershell triaged-2018-11 |