Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to setup a bitbucket pipeline to build code once and manually deploy to multiple environments?

Alfred Gonzalez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 3, 2020

Trying to build a BitBucket pipeline file to only build once and then push that build to different environments manually. but right now as i see it builds in each step and pushes. How do i use the image from the previous step.

pipelines:
  custom:
    buildDeploy:
      - step:
          name: Build Keycloak Docker Image and Upload Dev
          services:
            - docker
          deployment: dev
          script:
            - ls -ahl
            - docker build -t keycloak .
            - pipe: atlassian/aws-ecr-push-image:1.2.0
              variables:
                IMAGE_NAME: keycloak
                TAGS: 'latest'
      - step:
          name: Build Keycloak Docker Image and Upload Demo
          services:
            - docker
          deployment: demo
          trigger: manual
          script:
            - ls -ahl
            - docker build -t keycloak .
            - pipe: atlassian/aws-ecr-push-image:1.2.0
              variables:
                IMAGE_NAME: keycloak
                TAGS: 'latest'
      - step:
          name: Build Keycloak Docker Image and Upload Prod
          services:
            - docker
          deployment: Prod
          trigger: manual
          script:
            - ls -ahl
            - docker build -t keycloak .
            - pipe: atlassian/aws-ecr-push-image:1.2.0
              variables:
                IMAGE_NAME: keycloak
                TAGS: 'latest'
options:
  docker: true

1 answer

0 votes
ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 3, 2020

How do i use the image from the previous step. [?]

Via the registry.

The underlying problem you most likely run into with the design how you deploy the images is that you make use of the `latest` tag which is prone to side-effects that are that harsh that you can't (with your current setup/design)  deploy the same (container image build) revision first to dev, then test and then prod.

But I might misread your pipeline to some extend, as I can't see how the deployment to different environments there work already. If the image push to aws ecr is the deployment already then I can't see how this are actually different environments (here: dev, test and prod).

Maybe you can add a bit more context if your problem is more with creating the images, more with pushing them or more with deploying them to the different dev, test and prod environments and give a bit more description.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events