How to process Specs in Docker using a custom Docker image
プラットフォームについて: 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 は除く
要約
When using repository-stored specs, Bamboo offers a feature of processing the specs inside a Docker container, isolated from the Bamboo environment. By default, this feature uses the atlassian/bamboo-specs-runner
image from Docker Hub, matching your version of Bamboo.
Should you require any customization to the default image used by the Specs runner, you'd need to maintain your own image, and then configure Bamboo to use it. The purpose of this article is to explain how to achieve the latter.
Please see this page for more information on this feature.
環境
Bamboo with repository-stored Specs.
This article assumes you have already created a customized image, and that it is available in a Docker registry (either public or private).
ソリューション
Public repository
If your Docker image is available on a public repository in Docker Hub, it's pretty straightforward: you can specify it directly under Overview >> Security Settings >> Edit >> Docker image, using the following syntax.
<namespace>/<repository>:<tag>
例:
Private repository
Bamboo currently doesn't offer an option to pass credentials for a private registry. Please see the following feature request:
- BAM-19731Getting issue details... STATUS
回避策
There are, however, a few workarounds (please see the Feature Request above) that you can perform so that the credentials are cached, and that way Bamboo doesn't need to send any credentials. You would just need to run docker login
for the private registry on the Bamboo host machine, using the same user account that runs Bamboo. This will cache the credentials for that registry in ~/.docker/config.json
.
例:
- Given a private repo in Docker Hub (example):
USER/test-repo:7.2.6
Open terminal as the same user that runs your Bamboo instance, and execute the following command:
docker login registry.hub.docker.com/USER/test-repo
- Provide your credentials so the login is successful and it gets cached in
~
/.docker/config.json
Under Bamboo >> Cog icon >> Overview >> Security Settings >> Edit, set the following for Docker image:
registry.hub.docker.com/<NAMESPACE>/<REPOSITORY>:<TAG>
例:
The Specs Scan should then succeeds:
2022-01-18 18:27:49,173 Pulling docker image registry.hub.docker.com/USER/test-repo:7.2.6 [...] 18-Jan-2022 18:27:49 Processing Specs within Docker container [...] 18-Jan-2022 18:28:00 [INFO] BUILD SUCCESS
Syntax for private repositories stored in Docker Hub:
registry.hub.docker.com/<namespace>/<repository>:<tag>
Syntax for repositories stored in private / local / other registries:
<registry.address>:<port>/<namespace>/<repository>:<tag>