-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The Azure CLI Task does not fail when a command fails #10125
Comments
We have run into this issue with a customer project that looking to bring a large Heroku app into Azure and Azure DevOps. Would be great if this script worked like many/most of the others out there. |
I often recommend use of the Azure CLI task to build and push containers as well, as it's nice to be able to interact with ACR without creating a seperate service principal. However with how things are designed now I need an incredibly over complicated script to check each previous lines success and only continue if it's really working. |
@jlorich @cwiederspan The Azure CLI task relies on the scripting environment’s behaviour. For inline scripts, the task actually creates a batch script (in Windows) or bash script (in Linux) with the specified commands and executes the script. So the behaviour of whether to exit on individual command failure or not is dependent on the script & scripting environment. The default behaviour for batch script (Windows) is to exit on failure, while the same for bash script (Linux) is to continue irrespective of return code. @jlorich Since you are running the script on Ubuntu agent, your script is simply continuing further without considering the return code of individual commands. If you want to alter this behaviour, you need to modify your script appropriately – either explicitly check for command return code for specific commands or alter the script execution behaviour. E.g., in order to achieve the latter in Ubuntu, you can probably add “set -e” command to the start of your script. Let us know if this doesn't work for you. |
Thanks for the insights @amaljg. Perhaps this is just a lacking in the documentation then, as both myself and a number of others have ran into this in the past - especially with inconsistencies depending on the agent that is running. I think this has led to a number of various issues that have been filed here in the past too. For an external script file, setting To me having adding an option that sets
This would make it quite clear what is happening, and also provide the option to write a release task that is not dependent on the underlying agents behavior. |
Thanks @jlorich for the feedback. Adding @pulkitaggarwl to consider the feedback in the next version of the task. For now, since you are unblocked, I'm closing this issue. Feel free to reach out to us, if you need any further help. |
…d fail the run, a=testonly Automatic update from web-platform-tests Fix #27476: Installing STP failing should fail the run NB: microsoft/azure-pipelines-tasks#10125 -- wpt-commits: 84b2f829080ddd13feabe98d68ce3fddbcf543c4 wpt-pr: 27477
…d fail the run, a=testonly Automatic update from web-platform-tests Fix #27476: Installing STP failing should fail the run NB: microsoft/azure-pipelines-tasks#10125 -- wpt-commits: 84b2f829080ddd13feabe98d68ce3fddbcf543c4 wpt-pr: 27477 UltraBlame original commit: a7a3846e593c00be847c844404fdae07c53cae39
…d fail the run, a=testonly Automatic update from web-platform-tests Fix #27476: Installing STP failing should fail the run NB: microsoft/azure-pipelines-tasks#10125 -- wpt-commits: 84b2f829080ddd13feabe98d68ce3fddbcf543c4 wpt-pr: 27477 UltraBlame original commit: a7a3846e593c00be847c844404fdae07c53cae39
…d fail the run, a=testonly Automatic update from web-platform-tests Fix #27476: Installing STP failing should fail the run NB: microsoft/azure-pipelines-tasks#10125 -- wpt-commits: 84b2f829080ddd13feabe98d68ce3fddbcf543c4 wpt-pr: 27477 UltraBlame original commit: a7a3846e593c00be847c844404fdae07c53cae39
Since I see no open feature request: Is there an option now? Will we get one? It’s easy to forget to add |
…d fail the run, a=testonly Automatic update from web-platform-tests Fix #27476: Installing STP failing should fail the run NB: microsoft/azure-pipelines-tasks#10125 -- wpt-commits: 84b2f829080ddd13feabe98d68ce3fddbcf543c4 wpt-pr: 27477
I believe the setting is there already, called |
@stodirascu that does not sound correct. |
Aha, I see, @kappmeier. Then +1 for this to be reopened. |
Required Information
Type: Bug
Task Name: Azure CLI
Environment
Server: Azure Pipelines
Account Name: mtcdenver
Project Name: Azure Demos
Build Definition Name: demo-whack-a-mole-admin
Build Number: #20190401.2
Agent: Hosted
Issue Description
When a command within the Azure CLI task fails, subsequent commands within the script continue to run and the task is marked as successful, causing the build or release process to conitnue. The Azure CLI task only fails if there is a failing exit code on the last command, which is not how any script runner should be expected to work.
Any failing exit code returned from any command should immediately terminate the script and mark the task as failed.
Task logs
Relevant log snippet:
However the task continues to run other commands after, and marks itself as successful.
Full Debug Logs
The text was updated successfully, but these errors were encountered: