-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
Windows 10 x64
JRE 1.8u144
Jenkins 2.78
Durable Task Plugin 1.14
Jenkins installed as Standard Windows Service without a separate Webserver or Proxy
Recently one of our PowerShell scripts failed but the pipeline didn't abort because Jenkins considered the PowerShell script to be succesful.
You can reproduce the problem with the following example pipeline script:
node { powershell ''' $ErrorActionPreference = 'Stop' & cmd /c 'exit 0' Copy-Item 'doesnt' 'exist' ''' }
This script should fail because of ErrorActionPreference = 'Stop' and because Copy-Item will return an error because the file doesn't exist (resulting in $? = False).
I assume that this happens because the PowerShell plugin first checks for $LASTEXITCODE, which was set to 0 by the "cmd" command. The problem is that $? isn't checked as well.
- is duplicated by
-
JENKINS-48175 Powershell 'Hello World' Task Hangs
- Open
-
JENKINS-48325 Powershell step hangs indefinitely.
- Closed