acr
acr copied to clipboard
Error running ACR task: failed to unmarshal task before running: failed to deserialize task and validate: yaml: line 4: could not find expected ':'
Describe the bug I want to create an acr task to trigger new builds of my "app" image after base image updates inside same Azure registry. As stated in the tutorial, I need to run my task once so it can track the base image dependency...
When I run my task I get the following error:
failed to unmarshal task before running: failed to deserialize task and validate: yaml: line 4: could not find expected ':'
Run ID: cb6 failed after 9s. Error: failed during run, err: exit status 1
To Reproduce
- Create the task :
az acr task create `
--registry $ACR_NAME `
--name tasktestacrtask01 `
--image 'testacrtask:tasktestacrtask01{{.Run.ID}}' `
--file Dockerfile `
--arg IMAGE=$ACR_NAME.azurecr.io/is-serverbase `
--context /dev/null `
--platform windows
- Run the task :
az acr task run --registry $ACR_NAME --name tasktestacrtask01
Queued a run with ID: cb6
Waiting for an agent...
2020/04/21 20:01:14 Alias support enabled for version >= 1.1.0, please see https://aka.ms/acr/tasks/task-aliases for more information.
failed to unmarshal task before running: failed to deserialize task and validate: yaml: line 4: could not find expected ':'`
Run ID: cb6 failed after 9s. Error: failed during run, err: exit status 1
If this can help, first lines of my dockerfile look like this:
# escape=`
# some comments
ARG IMAGE=nameofmyregistry.azurecr.io/is-serverbase
ARG VERSION=4.7.2-windowsservercore-ltsc2019
FROM $IMAGE:$VERSION
Expected behavior I want my task to run with success and monitor further base image updates.
What am I missing here ?
Any relevant environment information
- OS: Windows
- Azure CLI version : 2.0.81
- Docker version 19.03.2, build 6a30dfc
- Datetime (UTC) when the issue occurred : April 21, 2020 20:30:00 (UTC)
@geoffreygeslin, it looks you used a Dockerfile as a multi-step task file. They're different. For you case, you first need to push the source code including Dockerfile to GitHub or Azure DevOps repository and then run the the command like the following to create the task.
az acr task create `
--registry $ACR_NAME `
--name tasktestacrtask01 `
--image 'testacrtask:tasktestacrtask01{{.Run.ID}}' `
--file Dockerfile `
--arg IMAGE=$ACR_NAME.azurecr.io/is-serverbase `
--context https://github.com/user/repo.git#branch:folder `
--platform windows
Multi-step task provides the features which allow you do more stuff beyond docker build. If you are interested, you can see how to use a single Dockerfile OR multi-step task file to build the same project.
https://github.com/Azure-Samples/acr-tasks/tree/master/build-aspnetapp
@northtyphoon Thank you for your quick reply.
As my acr contains :
- the base image to monitor,
- the build context of my "app" image (I used 'acr build')
... I thought my scenario would work. Can this case be condidered to be covered by acr tasks someday ?
For now, I do prefer to use a multi-step task file rather than changing our repository.
Looking at the acb.yaml file in the sample, I'm wondering which parts are mandatory ? Can I start with a most simple 2 steps file, only containing "build" and "push" ?
Also, as my base image is already pushed in my registry, can you confirm I can skip the "az acr import" prerequisite ?
You only need "build" and "push". You don't need "import" if you already have the base image in your registry.
I successfully run an multi step build with "az acr run" and a yaml file.
I'm wondering how to pass custom build args on "az acr run" command ? In the documentation, I can't fin any "build-arg" argument for acr run, whereas it is supported on "az acr build"... Also, how should I decribe such custom build args in the yaml file ? Can i use the $ syntax for variables of my own ?
Now that I have a multistep build with a valid yaml file, i will follow the rest of this tutorial : https://docs.microsoft.com/en-us/azure/container-registry/container-registry-tutorial-base-image-update#build-the-application-container
Could you please explicitly confirm I do NOT need any git or az devops repo to get my "multi-steps" az task auto-triggered ?
Yes here is an example of a Docker file
ARG REGISTRY=myregistry.azurecr.io
ARG IMAGE=hello-world:latest
FROM $REGISTRY/$IMAGE
Here it the acb.yaml that you can create the task with using the $Registry alias for build args.
version: v1.1.0
steps:
- build: -t $Registry/hello-world:$ID -f Dockerfile --build-arg REGISTRY=$Registry .
- push: ["$Registry/hello-world:$ID"]
sample here - https://github.com/sajayantony/dockerfiles/tree/master/docker-build-args
Any Updates on this ?
Closing as this has been inactive for over three months. Please open a support ticket with our team for assistance.