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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,699
Community Members
 
Community Events
184
Community Groups

Pipelines: Image name as an artifact

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.
Nov 02, 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

@Mark C,

 thank you for the reply.

 

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

@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.
Nov 06, 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