Issue Summary
The Docker task does not allow using variables to point to the name of the image to be used for the task specially for Push and Pull commands
The repository field in the "Pull a Docker image from repository" and "Push a Docker image to a Docker registry" commands prevents the ${bamboo.variable} syntax from being entered, as it does not meet the regex requirements for a Docker repository name.
Steps to Reproduce
- Add variable with docker registry and image name e.g. registry.address:port/namespace/repository:tag
- Add Docker task.
- Docker configuration - select option Push a docker image to a docker registry.
- Select Custom registry and paste ${bamboo.image}
Expected Results
Variable under repository field is been recognized for "Pull a Docker image from repository" and "Push a Docker image to a Docker registry" commands
Actual Results
The variable is not recognized in the repository and the below error is seen int he UI when we try to save the task
"You must specify a registry address when pushing to a custom registry"
The piece of code where the issue seems to be restricted to the config validation only, i.e. if that would accept variables for the namespace and repository parts, the execution would resolve and use those correctly.
The responsible validation code can be found in the respective validator implementations, and the PushConfigValidator
-
- Both validators attempt to parse the content of the Repository field into their respective parts, i.e. "registry/namespace/repository:tag" in order to then validate the namespace and the repository parts against respective regex patterns that do not accept Bamboo variables!
- The registry and tag parts are not validated at all, hence they allow variable usage.
Workaround
you can create a 'script' task with inline content: "docker push ${bamboo.variable}" or "docker pull ${bamboo.variable}"
to achieve this purpose.