azure-dev: Set "continueOnError" to `false` script errors cant't stop execution of AZD in Windows
Describe the issue:
For azd hook test, when set the “continueOnError” flag to false
, script errors can not control stop execution of AZD. example as follow:
Repro Steps:
- Clone template
todo-nodejs-mongo
to local. - Add hook config in
azure.yaml
(Execute a script with errors).
- Run azd command to trigger hook.(eg.
azd package
)
Environment:
- OS: Windows desktop.
- Template: todo-nodejs-mongo
- Azd version: 0.8.0-beta.3-daily.2763383 (commit https://github.com/Azure/azure-dev/commit/3f484a283b309b3cab6f91386a4a7af7f4a082a2)
Expected behavior:
When set the “continueOnError” flag to false
, script errors can control stop execution of AZD
@rajeshkamal5050 for notification.
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 15 (13 by maintainers)
@v-jiaodi Since this is using an external script you need to manually update it to include the following:
$ErrorActionPreference='Stop'
This will instruct Powershell to stop on errors if this is the desired behavior. We will not be addressing this issue for external script hooks internally within
azd
for the time being.What happens if we change the script to:
$ErrorActionPreference='Stop'; Write-Host1111 $env:AZURE_ENV_NAME
?Since
ErrorActionPreference
of powershell was likely set toContinue
here, powershell will not stop on errors, and continue. The exit code would be 0. Setting$ErrorActionPreference='Stop'
will appropriately terminate with non-zero exit code on errors.