jenkinsci / jenkinsci/durable-task-plugin

[JENKINS-49769] Successful powershell steps can fail due to handling of output

Open
#416 0 comments 0 reactions 0 assignees View on GitHub
component:durable-task-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
30
Forks
101
PR merge metrics
No merged PRs in 30d

Description

My builds started failing since updating to durable task plugin 1.18.  It would appear that the main script execution line was setting $LASTEXITCODE to 1 but $MAINSCRIPT was exiting with 0.

powershellHelper.ps1 line 53 is currently:

& { & $MainScript | Out-FileNoBom -Writer $OutputWriter } *>&1 | Out-FileNoBom -Writer $LogWriter;

And my take is that Out-FileNoBom can contribute to the $LASTEXITCODE, so the step can fail because of a logging error.  I found removing the $LogWriter or even the "*>&1" made it start working in a sandbox outside of Jenkins. I think that running $MainScript in isolation and capturing that $LASTEXITCODE, then doing the logging may be a more robust solution?

I've switched to using bat commands as a work around in the mean time.

---
Originally reported by say_ten, imported from: Successful powershell steps can fail due to handling of output


  • status: Open
  • priority: Minor
  • component(s): durable-task-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-09

Raw content of original issue

My builds started failing since updating to durable task plugin 1.18.  It would appear that the main script execution line was setting $LASTEXITCODE to 1 but $MAINSCRIPT was exiting with 0.

powershellHelper.ps1 line 53 is currently:

& { & $MainScript | Out-FileNoBom -Writer $OutputWriter } *>&1 | Out-FileNoBom -Writer $LogWriter;

And my take is that Out-FileNoBom can contribute to the $LASTEXITCODE, so the step can fail because of a logging error.  I found removing the $LogWriter or even the "*>&1" made it start working in a sandbox outside of Jenkins. I think that running $MainScript in isolation and capturing that $LASTEXITCODE, then doing the logging may be a more robust solution?

I've switched to using bat commands as a work around in the mean time.

environment

```
Jenkins 2.109

durable-task 1.18

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.