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

Pipelines: Image name as an artifact

AZZ November 1, 2022

hello,

 is there a way to pass docker's image between the steps of a pipeline?

something to this extent:

steps:
- step: &Build
name: Build an image
services:
- docker
script:
- export IMAGE=$BITBUCKET_REPO_SLUG_BLAH
- export DOCKER_FILE="dockerfile"
- docker builder build -t $IMAGE -f $DOCKER_FILE .
artifacts:
- $IMAGE
- step: &Deploy
name: Deploy Docker image
deployment: Test
services:
- docker
clone:
enabled: false
script:
- docker login -u $SERVICE_ACCOUNT -p $SERVICE_ACCOUNT_TOKEN
- docker push $IMAGE
pipelines:
custom:
Build:
- step: *Build_And_Scan
- step: *Deploy
 

 

1 answer

1 accepted

0 votes
Answer accepted
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 2, 2022

Hi @AZZ,

Thank you for reaching out to the community.

To save the built Docker image and access it in the next step, you can use Caching.

caches:
  - docker

Using Docker cache, we create the cache from the layers generated by your build.
This way, you can access the Docker image in any step within 1 week.

However, please kindly note that we don't automatically refresh Caches. We do have an existing feature request for it that can be located through this link. - https://jira.atlassian.com/browse/BCLOUD-16314
You can upvote and watch it for now so that you'll be notified of any updates from our team when the feature becomes available on Bitbucket Cloud.

As a workaround, if you'd like to refresh the Docker cache, you will need to clear it first using the Pipes script (atlassian/bitbucket-clear-cache).
Here's a blog post on how to use the Pipes script. - Automatically refresh caches when build dependencies are updated

Hope it helps and do let me know if you have further questions.

Regards,
Mark C

AZZ November 3, 2022

@Mark C,

 thank you for the reply.

 

Does it mean that i do not have to use "artifacts" to pass docker image?

AZZ November 3, 2022

@Mark C 

and the additional question:

 is there a way to reuse var IMAGE without redefining it in the "deploy" step?

I look at the "stage", but, it seems, i can only define static values for variables there. e.g. I can't have an expression of shell call in there.

Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 6, 2022

Hi @AZZ

You don't need to use artifacts as Caches is available for any steps for 1 week.
You can also use a repository variable for your Docker image name and that will be available on your steps.

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events