How do I update environment variables in a step for another step to use?

I have a script that updates keys for docker login.

  • If I do NOT run the script that updates keys the in a step, the docker login works perfectly.
  • If I run the update keys script on my local machine, the script works, and the docker login works
  • If I run the update keys in the pipeline build, the script works but the docker login does NOT work (because the environment variables are not being updated)
  • The update keys script needs to run before my docker login

How do I get an updated copy of the environment variables in between steps?


image: node:8.2.1

name: Update Docker Password for Login
npm install aws-sdk request-promise base-64
node build-tools/update-bb-aws-docker-login.js
name: Push Server to AWS Repository
docker login -u AWS -p $AWS_DOCKER_LOGIN https://$AWS_DOCKER_URL
docker build -t dev .
docker tag dev:latest $AWS_DOCKER_URL/dev:latest
docker push $AWS_DOCKER_URL/dev:latest

docker: true


1 answer

0 votes

Environment Variables are not carried across steps. They are always copied from those set in the Pipelines UI. If you'd like to update them you can use the Bitbucket Pipelines REST API to do so. Alternatively you can combine the two steps so that the new credentials are available in the push step. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday 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 ROLLBAR_ACCESS_TOKEN...

194 views 0 12
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you