Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

bitbucket-pipelines, build using ACR

Bo Christensen March 17, 2023

Hi, I have tried to solve this problem but have failed.

I need to build a docker image using bitbucket-pipelines and ACR.

I need examples of how to write the bitbucket-pipelines.yml

using 'az acr build' and how to push the image into ACR.

 

Please advise.

/Bo Christensen

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 20, 2023

Hi Bo,

Just to give you some context, Pipelines builds run in Docker containers. For every step of your build, a Docker container starts using the image you have specified in your bitbucket-pipelines.yml file. The repo is cloned in that container, and then the commands of the step's script are executed. When the step finishes that Docker container gets destroyed.

If you want to execute commands like 'az acr build', the Azure CLI needs to be installed on the Docker image that is specified as a build container in your bitbucket-pipelines.yml file. Microsoft provides the Docker image mcr.microsoft.com/azure-cli that has Azure CLI pre-installed. You can use it by specifying it in your bitbucket-pipelines.yml file as follows:

image: mcr.microsoft.com/azure-cli

This is the documentation for the Docker image options in bitbucket-pipelines.yml

If you use a different Docker image as a build container, you will need to install Azure CLI in the container by adding the necessary commands in the script of your step. So, it may be easier to use mcr.microsoft.com/azure-cli instead.

You should then be able to use commands from Azure CLI in the script of your step. For the exact commands that you need to use, you will need to check Azure CLI documentation:

If you have any questions, please feel free to reach out.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events