When running the powershell task, if the path you pass doesn't exist, the step does not cause the build to fail:
pipeline:
node("WINDOWS_MACHINE"){
powershell("a_file_that_doesnt_exist")
}
output:
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on <VM NAME> in D:\J\workspace\TEST_POWERSHELL_STEP
[Pipeline]
{
[Pipeline] powershell
[TEST_POWERSHELL_STEP] Running PowerShell script
powershell.exe : a_file_that_doesnt_exist : The term 'a_file_that_doesnt_exist' is not recognized as the name of a cmdlet, function,
At D:\J\workspace\TEST_POWERSHELL_STEP@tmp\durable-feef7c1b\powershellWrapper.ps1:5 char:3
+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Fi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (a_file_that_doe...let, function, :String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
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 D:\J\workspace\TEST_POWERSHELL_STEP@tmp\durable-feef7c1b\powershellScript.ps1:1 char:1
+ a_file_that_doesnt_exist
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (a_file_that_doesnt_exist:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
—
I would expect that unless i have asked for the return code, the step should cause the build to fail. This should act the same way as if the calling script returned an invalid error code.