[JIRA] (JENKINS-52884) durable-task-plugin 1.23 powershell step does not return exit code other than 0 or 1

2 views
Skip to first unread message

dustin@escoffery.com (JIRA)

unread,
Aug 3, 2018, 9:06:03 PM8/3/18
to jenkinsc...@googlegroups.com
Dustin Escoffery created an issue
 
Jenkins / Bug JENKINS-52884
durable-task-plugin 1.23 powershell step does not return exit code other than 0 or 1
Issue Type: Bug Bug
Assignee: Unassigned
Components: durable-task-plugin
Created: 2018-08-04 01:05
Environment: Jenkins ver. 2.121.2
durable-task-plugin 1.23
Priority: Minor Minor
Reporter: Dustin Escoffery

 

After upgrading to durable-task-plugin 1.23, the powershell step does not return the correct non-zero exit code. In version 1.22 the code was correct.

powershell 'exit 123'

ERROR: script returned exit code 1

 

 

def status = powershell(returnStatus:true, script:'exit 123')
echo "$status" 

[Pipeline] echo
1

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

dustin@escoffery.com (JIRA)

unread,
Mar 5, 2019, 6:32:02 PM3/5/19
to jenkinsc...@googlegroups.com
Dustin Escoffery commented on Bug JENKINS-52884
 
Re: durable-task-plugin 1.23 powershell step does not return exit code other than 0 or 1

I believe the bug was introduced in

https://github.com/jenkinsci/durable-task-plugin/pull/71

https://github.com/jenkinsci/durable-task-plugin/commit/e7f0dd5e7c7018b58dac08bfbc49b8037480a282

 

Consider powershell script "test.ps1" with contents:

 

exit 2

 

 

Prior to the change, the old method correctly sets the error code to 2:

 

& powershell -ExecutionPolicy ByPass -File test.ps1
$LASTEXITCODE

2

 

 

After the change (durable-task 1.23 and above), the new method incorrectly sets the error code to 1:

 

& powershell -ExecutionPolicy ByPass -Command "& .\test.ps1"
$LASTEXITCODE

1

 

 

This example uses PSVersion 5.1.16299.967

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

dustin@escoffery.com (JIRA)

unread,
Mar 5, 2019, 6:40:01 PM3/5/19
to jenkinsc...@googlegroups.com

gabloe@microsoft.com (JIRA)

unread,
Mar 22, 2019, 8:26:02 PM3/22/19
to jenkinsc...@googlegroups.com
Gabriel Loewen commented on Bug JENKINS-52884
 
Re: durable-task-plugin 1.23 powershell step does not return exit code other than 0 or 1

The change to using -Command was to solve a different regression in Powershell versions < 5.  The fix here is to add an additional exit $LASTEXITCODE within the command block.  e.g.:

 

& powershell -ExecutionPolicy ByPass -Command "& .\test.ps1; exit $LASTEXITCODE;"
$LASTEXITCODE

2

 

I'll send a PR shortly with this fix.

gabloe@microsoft.com (JIRA)

unread,
Mar 22, 2019, 8:43:02 PM3/22/19
to jenkinsc...@googlegroups.com

gabloe@microsoft.com (JIRA)

unread,
Mar 22, 2019, 8:43:02 PM3/22/19
to jenkinsc...@googlegroups.com

lystor@gmail.com (JIRA)

unread,
Apr 5, 2019, 6:02:01 AM4/5/19
to jenkinsc...@googlegroups.com

dnusbaum@cloudbees.com (JIRA)

unread,
Jul 5, 2019, 3:24:03 PM7/5/19
to jenkinsc...@googlegroups.com
Devin Nusbaum updated Bug JENKINS-52884
 

A fix for this issue was just released in version 1.30 of Durable Task Plugin.

Change By: Devin Nusbaum
Status: Fixed but Unreleased Resolved
Released As: durable-task 1.30
Reply all
Reply to author
Forward
0 new messages