How to use Bamboo variables when using an existing Dockerfile in a Docker build task
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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.
*Except Fisheye and Crucible
Purpose
When using a Docker task in Bamboo to build a docker image, it may be desirable to pass and dereference Bamboo variables even when using an existing Dockerfile.
Solution
Use Docker build arguments:
It can be configured in Bamboo inside your Docker task configuration using the Additional Arguments field. Example below:
--build-arg VERSION=${bamboo.versionVariable}
ARG VERSION
RUN curl -L --silent https://packages.atlassian.com/maven-external/com/atlassian/bamboo/atlassian-bamboo/${VERSION}/atlassian-bamboo-${VERSION}.pom > /tmp/pom.xml