Lesstep
Azure Pipelines · scripts · Checked November 9, 2026

Azure Pipelines: "##[error]Bash exited with code '1'."

This line is not the error. It is the agent saying that the script of a bash: or script: step ended with an exit status other than 0, which fails the step. The command that failed printed the reason in the lines just above it, and the number in the quotes tells you what kind of failure it was.

What it looks like

/home/vsts/work/_temp/6d0f3a2e-5b1c-4e8a-9f7d-2c4b8a1e0f93.sh: line 3: dotnet-format: command not found
##[error]Bash exited with code '127'.

When the pipeline is a pull request's build validation, the pull request waits on it: Azure DevOps Pull Requests, a plugin for JetBrains IDEs, lists the pull request's branch policies with their state in IntelliJ IDEA, Rider or PyCharm, and with Pro runs a failed build policy again once the script is fixed. Its Pipelines tab (version 1.0.86 and later) lists the runs of the repositories you have open and opens a failed task's log in the editor, free to read.

First, find the line that caused it

What the number usually means

CodeUsuallyWhat to do
1The tool reported a failure: a build error, failed tests, npm or dotnet stopping. Also grep that found no line, when it is the last command.Read the tool's own message above. For a grep that may find nothing, end with || true or test the result in an if.
5pytest: no tests were collected (pytest's exit codes).Test files named test_*.py or *_test.py and test functions named test_*, run from the right folder.
126Found but not executable: Permission denied.A script committed from Windows has no executable bit. Run git update-index --chmod=+x build.sh and commit, or call it as bash ./build.sh.
127command not found.The tool is not on the agent or not on the PATH of this step. See below.
128 + NEnded by signal N. 137 is 128 + 9, a SIGKILL, often the out-of-memory killer; 143 is 128 + 15, a SIGTERM.For 137, use less memory (fewer parallel workers, a smaller heap) or a bigger agent.

126, 127 and 128 + N come from Bash itself, as the Bash manual describes; every other number is whatever the failing program returned.

"command not found" for a tool that is installed

Failing tests should still publish their results

A test runner returns 1 when a test fails, the step fails, and the next steps are skipped, including the one that publishes the results. Keep the failure and run the publishing step anyway. Microsoft's page on conditions: succeededOrFailed() runs even if a previous step failed, unless the run was canceled.

- script: pytest --junitxml=junit/test-results.xml
  displayName: Run tests
- task: PublishTestResults@2
  condition: succeededOrFailed()
  inputs:
    testResultsFiles: '**/test-results.xml'

Ending the test command with || true, a common answer, makes the run green with failed tests. If you do it, set failTaskOnFailedTests: true on PublishTestResults@2, which fails the task when the results file has a failed test.

"Bash wrote one or more lines to the standard error stream"

With failOnStderr: true, the Bash task fails if anything is written to standard error, whatever the exit code. git, curl, npm and many other tools write progress and warnings there. Leave it at its default, false, and let the exit code decide. To fail on purpose with your own message, use a logging command:

echo "##vso[task.logissue type=error]The service did not start."
exit 1

On Windows: "Cmd.exe exited with code" and "PowerShell exited with code"

Azure DevOps pull requests in IntelliJ IDEA, Rider and PyCharm

Azure DevOps Pull Requests, a plugin by Lesstep for JetBrains IDEs 2024.1 or later and Android Studio, reads the organization, project and repository from your git remote and lists the pull requests that wait for your review in an IDE tool window, on Azure DevOps Services and on Azure DevOps Server. It shows the branch policies of a pull request with their state, so a required build that has not passed is next to its pull request, and with Pro you run a failed or expired build policy again from there. The review inbox is free; voting, commenting, completing and creating are Pro, with a 30-day trial.

Get it on JetBrains Marketplace

Azure DevOps and Azure Pipelines are trademarks of Microsoft Corporation; IntelliJ IDEA, Rider and PyCharm are trademarks of JetBrains s.r.o. This page is not affiliated with or endorsed by Microsoft or JetBrains.

More: No test result files matching were found · Dotnet command failed with non-zero exit code · Unable to locate executable file · No space left on device · Build validation · 日本語