It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is it possible to pass the `deployment` arg to the docker runner?

Steven Mar 10, 2019

Given the following step,

name: Deploy to staging
deployment: test

Where `deployment` is set to `test`, I'd like to have my dockerfile perform different actions that would go further in preparing a testing environment. This would require the `deployment` variable being passed into the docker runner as a run variable.

Is this possible? If not, is there another way to achieve this?

1 answer

1 accepted

1 vote
Answer accepted
Matthew Watson Atlassian Team Mar 12, 2019

No, but there is a workaround for this - you can set an environment variable as per Deployment variables under and let it have the name of the environment in it - 

Steven Mar 12, 2019


My bitbucket-pipelines file looks something like this:

- step:
name: Deploy to production
deployment: production
trigger: manual
- apt-get update && apt-get install -y curl
- curl -O
- python
- pip3 install awsebcli --upgrade
- eb init fun-app -r ap-southeast-2 -p docker
- eb deploy fun-app-env

How/where would I be passing in that variable as a Dockerfile argument?

Matthew Watson Atlassian Team Mar 13, 2019

I'm not sure what you mean by "passing in that variable as a Dockerfile argument" - I'm going to assume you mean how would you be able to use that within your build script:

If you go to your repo->settings->Deployments->click on a environment (test)-> you can then add a variable, called, say "ENVIRONMENT" and set the value to "test" and then do the same for staging and production. Then in your script in the yml you'll be able to do:

 - if [ "${ENVIRONMENT}" = "test" ]; then xyz; fi

 Note also that we just released a feature called Bitbucket Pipes that has a Pipe for deploying to elastic beanstallk that you might want to use instead of what you're doing in your yml

Steven Mar 13, 2019 • edited

As in a docker build ARG that I could read and code against within the Dockerfile.

The idea here is to be able to pass additional context when building the container so that I can change what is actually being built.

Matthew Watson Atlassian Team Mar 13, 2019

Ah, now I get you - I didn't follow that it was `eb init -p docker` - I don't know if there is a way to do this - you might need to ask in a awsebcli forum. A workaround would be to substitute the variable straight into your Dockerfile inside pipelines before calling `eb init` - e.g. `sed -e 's/<ENV>/${ENVIRONMENT}/' > Dockerfile` for example...

Like Steven likes this

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

1,687 views 1 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you