Creating a Docker image in Bamboo using Docker task throws "invalid reference format" exception

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問


プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

要約

This article talks about the problem seen while creating the Docker image in Bamboo using Docker task and assigning a tag to it. The tag can be either derived using Bamboo variable, branch name, etc or defined manually.

The Docker task while creating the image fails with exception ERROR: invalid tag "" : invalid reference format

環境

Issue was seen on Bamboo 9.2.4 but the solution will be applicable for all supported versions of Bamboo. 

診断

To diagnose the problem please refer the Bamboo build log and we can see the below error when the docker task fails

ERROR: invalid tag "releaseBranchTestingVersion1" : invalid reference format.
Last command executed with error! Exit code 1, message: None

Here we are trying to define a tag "releaseBranchTestingVersion1" to the Docker image which is being created ( Please note that this tag contains both lowercase and uppercase letters ) 

原因

If we read the  Docker tag convention page it mentions not to use uppercase letters in docker tag name. 

The path consists consists of slash-separated components. Each component may contain lowercase letters, digits and separators. A separator is defined as a period, one or two underscores, or one or more hyphens. A component may not start or end with a separator. While the OCI Distribution Specificationopen_in_new supports more than two slash-separated components, most registries only support two slash-separated components

The problem can occur if any of the above rule in violated with the tag name.

ソリューション

The current problem was related to using both lowercase and uppercase in the Docker tag, the solution is to just use the lowercase.

As explained earlier tag can be either a branch name, variable name or something manually defined, below are some example on how to convert them from uppercase to lowercase

echo ${bamboo.planKey} | tr '[:upper:]' '[:lower:]'
echo ${bamboo.planRepository.branch} | tr '[:upper:]' '[:lower:]'
Before
build	02-Nov-2023 12:17:41	SCRIP-TIC2
build	02-Nov-2023 12:17:41	TESTING_bamboo_BITBUCKET
After
build	02-Nov-2023 11:50:29	scrip-tic2
build	02-Nov-2023 11:50:29	testing_bamboo_bitbucket




最終更新日: 2023 年 12 月 5 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.