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

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

Use bitbucket variables (deployment,repository..secured, non-secured) in GAE pipe.


What's the suggested way to set environment variables when using bitbucket pipelines? I.e. how can I set the bitbucket deployment variables as my applications environment variables when building? I am using the google cloud app engine pipe.

The app.yaml supports the usage of env variables per default, however, it seems like the bitbucket variables are not accessible at this point.

My app.yaml looks like this:

runtime: nodejs10
instance_class: F4_1G

   TEST: '${TEST}'

another approach was to use the script section in the bitbucket-pipelines.yaml, for example:

- echo "Deploying to GCP APP Engine"          
- echo "Setting necessary environment variables.."          
- export TEST="${TEST}"

Both result in either *undefined values or not setting the env variables at all*.

Thanks for your response.



PS: I am expecting the secret variables to be set correctly using this approach, or do I need to manually decode them using base64? Can you please provide me a working example for both cases. Preferrably using the app.yaml.



1 answer

  • if you have a single-line value for the variable, then you can just set it in the repository variables and that should work out-of-the-box
  • if you have a json file for instance, then you need to set the variable to base64 encoded value and then in the pipeline step you can do:
- echo $VARIABLE | base64 -d | docker login -u _json_key --password-stdin

 Check this good article, I think it will solve most of your issues.

Thanks for the response. I would like to avoid writing a custom docker script when I can use the bitbucket pipe for google cloud app deployments:

- pipe: atlassian/google-app-engine-deploy:0.6.1

This pipe uses an app.yaml, which per default allows you to define env_variables. This is where I would like to use my secured bitbucket deployment variables. I feel like this is the cleanest solution! If only it would work...

E.g. in app.yaml:

runtime: nodejs10
instance_class: F4_1G


As an alternative solution, setting the env variables in the script section of bitbucket pipelines would also be ok. As seen in this example:

- echo "Deploying to GCP APP Engine"
- export MY_TEST='${TEST}'
- export MY_TEST_SEC=$(echo "${TEST_SEC}| base64 -d)
- pipe: atlassian/google-app-engine-deploy:0.6.1

Even though the commands get exectued and the values seem to be available (i.e. I can decode the bitbucket values on secured variables or use unsecured ones), the export variables are not set in the final image that is deployed to my app engine!

Probably has to do with the fact that the final image is the docker image, that is defined in the google app engine pipe: atlassian/google-app-engine-deploy:0.6.1. And everything before is basically a runtime-environment to help deploy the pipe? Or because this pipe is relying on the env_variables in the app.yaml - but there I dont have the bitbucket variables accessible?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

3,908 views 68 21
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