Azure / container-apps-deploy-pipelines-task

Azure Pipelines Task (Release Candidate) for building and deploying Azure Container Apps
MIT License
6 stars 10 forks source link

Exit code from docker and az cli are ignored #15

Closed mateuszkozakiewicz closed 1 year ago

mateuszkozakiewicz commented 1 year ago

Non-zero exit codes from docker and az should fail this task in the pipeline, however currently they are simply ignored and pipeline is successful. Example output where 2 problems occurred:

Logging in to Azure Container Registry using access token to be generated via Azure CLI.
/usr/bin/bash -c CA_ADO_TASK_ACR_ACCESS_TOKEN=$(az acr login --name xxxacr --output json --expose-token --only-show-errors | jq -r '.accessToken'); docker login xxxacr.azurecr.io -u 00000000-0000-0000-0000-000000000000 -p $CA_ADO_TASK_ACR_ACCESS_TOKEN > /dev/null 2>&1
No imageToDeploy argument was provided; setting the image to deploy to 'xxxacr.azurecr.io/backend:539.20230202.18'.
A Dockerfile was provided or found for the application source; attempting to build the image from Dockerfile '/home/vsts/work/1/s/home/vsts/work/1/s/Dockerfile'.
/usr/bin/docker build --tag xxxacr.azurecr.io/backend:539.20230202.18 --file /home/vsts/work/1/s/home/vsts/work/1/s/Dockerfile /home/vsts/work/1/s
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/vsts/work/1/s/home: no such file or directory
/usr/bin/docker push xxxacr.azurecr.io/backend:539.20230202.18
The push refers to repository [xxxacr.azurecr.io/backend]
An image does not exist locally with the tag: xxxacr.azurecr.io/backend
/usr/bin/az containerapp up --name xxx-api --resource-group xxx1 --image xxxacr.azurecr.io/backend:539.20230202.18 --target-port 8080
WARNING: The command requires the extension containerapp. It will be installed first.
WARNING: The installed extension 'containerapp' is in preview.
WARNING: Using resource group 'xxx1'
WARNING: Using ContainerAppEnvironment 'xxx-managedEnvironment' in resource group xxx1
WARNING: Updating Containerapp xxx-api in resource group xxx1
ERROR: (WebhookInvalidParameterValue) The following field(s) are either invalid or missing. Invalid value: "xxxacr.azurecr.io/backend:539.20230202.18": GET https:: MANIFEST_UNKNOWN: manifest tagged by "539.20230202.18" is not found; map[Tag:539.20230202.18]: template.containers.xxx-api.image.
/usr/bin/az account clear
Finishing: Deploy to Container App

First problem is here unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/vsts/work/1/s/home: no such file or directory this is an exit code 1 from docker.

Second problem is here ERROR: (WebhookInvalidParameterValue) The following field(s) are either invalid or missing. Invalid value: "xxxacr.azurecr.io/backend:539.20230202.18": GET https:: MANIFEST_UNKNOWN: manifest tagged by "539.20230202.18" is not found; map[Tag:539.20230202.18]: template.containers.xxx-api.image.

cormacpayne commented 1 year ago

@mateuszkozakiewicz Hey Mateusz, thanks for bringing this issue up -- looks like we need to properly handle the error code returned when we make calls to tl.execSync for these command line tools, such as az and docker. This should be a quick fix -- I'll work on getting this out shortly.

cormacpayne commented 1 year ago

@mateuszkozakiewicz -- This is now fixed in the 0.1.10 release of the AzureContainerAppsRC task -- if you continue to see errors not being handled correctly in your usage of this task, please let me know and I'll look into it. Thanks!