It appears that the tag source is injecting a tag for the working path of the build, which is adding a space to the tag, and causing docker to choke.
I'm not sure if we want to fix this with a simple PR to the Docker task to change tag to tag.Trim(), or if this is an issue that needs to be fixed higher up in the chain, or both.
Take, for example:
/usr/bin/docker build -f /home/vsts/work/1/s/Dockerfile --label com.azure.dev.image.system.teamfoundationcollectionuri=https://dev.azure.com/CertifID/ --label com.azure.dev.image.build.sourceversion=b1e056b8fcbcff87e398b1b05581b405a6aa9561 --build-arg CERTIFID_GIT_USER=ipointer-certifid --build-arg CERTIFID_GIT_PAT=*** -t ***/certifidhomeroom:185 -t ***/certifidhomeroom:latest -t ***/certifidhomeroom: /home/vsts/work/1/s
##[error]invalid argument "***/certifidhomeroom:" for "-t, --tag" flag: invalid reference format
Notice the space between that last tag's prefix, and the work location 鈽濓笍 .
For reference, the relevant part of my YML:
- task: Docker@2
displayName: Build HR & Vnts Img
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)'
repository: '$(imageRepository)'
command: 'build'
Dockerfile: '**/Dockerfile'
tags: '$(tag)'
arguments: '--build-arg CERTIFID_GIT_USER=$(CERTIFID_GIT_USER) --build-arg CERTIFID_GIT_PAT=$(CERTIFID_GIT_PAT)'
_Originally posted by @ipointer-certifid in https://github.com/microsoft/azure-pipelines-tasks/issues/14262#issuecomment-764908578_
I have a similar issue and use it like that:
- task: Docker@2
inputs:
containerRegistry: "official-docker-modmoto"
repository: "modmoto/w3champions-matchmaking-service"
command: "buildAndPush"
Dockerfile: "**/Dockerfile"
buildContext: "."
tags: |
$(TAG)
$(IS_LATEST)
On pull-request build the IS_LATEST variable is null, on master builds it is latest. In the version 2.176.0 this resulted in a command where the IS_LATEST was ignored and the image did not have the latest tag. Now version 2.181.0 breaks my build because it tries to tag the build with an empty tag like that: --tag myImage: (mark the white space).
@ipointer-certifid Could you please check whether your $(tag) variable also has extra newline or an empty value like @modmoto pointed out? We'll probably need to add a null check in that case.
Whitespaces are not trimmed in the newer versions of azure-pipelines-task-lib after this commit. We updated the version of this library in the last deployment and that's why it started breaking some of the pipelines. We are working on a fix. In the mean time, please make sure that you do not provide empty tags to work around the issue.
Could you please share the ADO org name as well?
https://dev.azure.com/w3champions/
that is us, or do you want it from @ipointer-certifid ?
Thanks @modmoto. I wanted it from both actually. 馃槃
The deployment with the fix will complete on all the rings by next week. I'll keep you posted.
ok, thanks a lot for the quick fix! =D
We experienced this too, all our pipelines started failing.
For now we have set our tasks to the last known working version:
- task: [email protected]
Ah nice, was not aware that you could set such a specific task number. Will use this workaround until the fix is rolled out :)
That version number worked in some places, but i had schema errors e.g. in deployment tasks when doing that.
What helped me was adding a "-" after the pipe:
tags: |-
$(TAG)
$(IS_LATEST)
According to https://yaml-multiline.info/ that removes a trailing newline that is added by yaml otherwise.
@m2xumb This worked for me, thanks!
Most helpful comment
That version number worked in some places, but i had schema errors e.g. in deployment tasks when doing that.
What helped me was adding a "-" after the pipe:
According to https://yaml-multiline.info/ that removes a trailing newline that is added by yaml otherwise.