Azure-pipelines-tasks: Repository names with uppercase letters break Docker tasks

Created on 31 Oct 2016  路  9Comments  路  Source: microsoft/azure-pipelines-tasks

If the name of the repository has an uppercase letter and the "Image Name" field in the task settings is left default as ($(Build.Repository.Name):$(Build.BuildId), the Docker task fails since Docker fails if the repository name is not all lowercase.

2016-10-31T21:32:10.1156180Z ##[section]Starting: Build an image
2016-10-31T21:32:10.4071990Z 4de0abcf-e253-4b34-b9c7-eb5cdfdd0c7a exists true
2016-10-31T21:32:10.4099210Z [command]/usr/bin/docker login -u * -p * *
2016-10-31T21:32:11.0489340Z Login Succeeded
2016-10-31T21:32:11.0554530Z [command]/usr/bin/docker build -f /home/vstsbuild/vsts-agent/_work/1/s/Dockerfile -t OguzPastirmaci/vsts-dockerhub-dockercloud-azure:276 /home/vstsbuild/vsts-agent/_work/1/s
2016-10-31T21:32:11.0704490Z invalid argument "OguzPastirmaci/vsts-dockerhub-dockercloud-azure:276" for t: invalid reference format: repository name must be lowercase
2016-10-31T21:32:11.0712890Z See 'docker build --help'.
2016-10-31T21:32:11.0775540Z [command]/usr/bin/docker logout
*
2016-10-31T21:32:11.0882480Z Remove login credentials for **
2016-10-31T21:32:11.0937030Z ##[error]/usr/bin/docker failed with return code: 1
2016-10-31T21:32:11.1322530Z ##[section]Finishing: Build an image

Release bug

Most helpful comment

We automatically convert the default value of image name to lower case. That is value of "$(Build.Repository.Name):$(Build.BuildId)" variable. Due to a bug, during docker push default value was not getting converted to lower case which has been fixed with this PR: https://github.com/Microsoft/vsts-tasks/commit/c86a7db6970191d6896c567c8d15cf5748b992d0#diff-5cb8a3cd5987528bf4faccde2cad95e4

All 9 comments

@chrisrpatterson @OguzPastirmaci moved this to the appropriate repo https://github.com/Microsoft/VSTS-Docker-Preview/issues/10

Do we have any updates on this? I am not sure that https://github.com/Microsoft/VSTS-Docker-Preview/issues/10 is monitored. Thanks.

We automatically convert the default value of image name to lower case. That is value of "$(Build.Repository.Name):$(Build.BuildId)" variable. Due to a bug, during docker push default value was not getting converted to lower case which has been fixed with this PR: https://github.com/Microsoft/vsts-tasks/commit/c86a7db6970191d6896c567c8d15cf5748b992d0#diff-5cb8a3cd5987528bf4faccde2cad95e4

Thanks @jikuma !

I know this is a little old but.. This still happens to me, today, with the latest task versions. Let me know if there's another issue/repository i should raise this issue in or just in a new issue in this one.

For example, in a docker rmi command (so not in the default list of commands), trying to use mycompanyregistry.azurecr.io/$(ProductName):$(Build.BuildNumber) as the arguments for rmi will fail if either variables/properties have text in them - it gets converted to uppercase.

In my case, Build.BuildNumber contains -draft as a suffix (this being a draft version of the pipeline).

FWIW The same in a docker build/push command in the same tasks doesn't become uppercase and Force image name to follow Docker naming convention is enabled in all tasks.

@bansalaseem do your team still own this? if not, can you add appropriate person

@ransagy this is happening because rmi is not listed in the commands. Although it is supported to be executed in the task; the additional input handlings don't happen on the strings, i.e. Force image name to follow Docker naming convention is not honored in that context, because the task wouldn't know if you were using an image name in this context.

You might have added mycompanyregistry.azurecr.io/$(ProductName):$(Build.BuildNumber) to your args section, right? The value provided in the args section, would be added as args directly to the docker command without any processing. For reference: containercommand.ts

As a work around, you could execute this bash script to implement the same enforcing of lowercase in image names

IMAGE_NAME=`echo "mycompanyregistry.azurecr.io/$(ProductName):$(Build.BuildNumber)" | awk '{print tolower($0)}'`
docker rmi $IMAGE_NAME

@ds-ms Thank you for the response and explanation; I figured as much, But wondered if its intended.

For now, I've worked around it in a very similar manner to what you suggested; Used a Powershell inline script task to generate another variable that is lowercased to be used with rmi.

I think so.
Given that you're passing the value in the arguments section; it implies that you're forming the desired cli command to be executed by yourself. i.e. docker <command> <args>

Was this page helpful?
0 / 5 - 0 ratings