question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PowerShell on Target Machines task: Non-zero exit code is marked as "pass"

See original GitHub issue

Invoking a PowerShell script that exits with a non-zero code does not mark the task as failed.

E.g., simply running a .ps1 with

Exit 1

has the following output reported in the logs

Deployment status for machine '<hostname>:5985' : 'Passed'

The regular PowerShell task with an inline script marks the task as failed as expected.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
shaykalyancommented, May 2, 2017

@psutharsan: Not a very clean work around, but since the default $ErrorActionPreference is set to “Stop”, writing to the Error stream in your script via Write-Error will be terminal and result in the task being marked as failed.

@pavanadepu2: I’m curious why the design is such?

0reactions
RoopeshNaircommented, Oct 12, 2018

Thank you for your feedback. This should be fixed now. The latest version supports additional error handling options as well.

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does my VSTS custom task passes with exit code 1?
My custom VSTS build task won't fail. It always passes, while the $LASTEXITCODE is other then zero. The code does as expected.
Read more >
PowerShell on target machines v3 task - Microsoft Learn
Use this task to execute PowerShell scripts on remote machine(s). This version of the task uses PSSession and Invoke-Command for remoting.
Read more >
Powershell on target machines does not exit successfully
I have a task with a powershell script that runs on 2 machines. It looks like the following, it imports a module and...
Read more >
Non-Zero return code: Ansible fails due to non-zero value
Ansible will fail if the exit status of a task is any non-zero value. Here's how we can resolve Non-Zero return code: Ansible....
Read more >
Command Step | Buildkite Documentation
soft_fail, Allow specified non-zero exit statuses not to fail the build. ... Jobs that time out with an exit status of 0 are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found