DEV Community

Cover image for How to use variables in bamboo for building and deploying and how to store sensitive information
dannypk
dannypk

Posted on

3 3

How to use variables in bamboo for building and deploying and how to store sensitive information

Hello Dear Coders,

Last time I wrote an article regarding security with Nexus and NPM Packages. Once your packages are secure, how do your CI Builds are supposed to work and do things like npm install or how can they run your docker containers?

This article will show you how to do that if you are using Bamboo.


Bamboo has some 2 types of variables:

  • global variables
  • plan specific variables

If the global variables share the same name as the plan specific variables, then the plan specific variable will overwrite the global variable.

How to define a global variable:

  1. Go to Bamboo and open administrator panel by clicking the cogwheel Alt Text
  2. From the left panel, under Build Resources choose Global Variables Alt Text
  3. Create a new variable by giving it a name and a value and click Add. Alt Text

How to define a plan variable:

  1. Go to the Plan and press E(dit) key or go to Actions and click Configure plan Alt Text
  2. Go to Variables Alt Text
  3. The same step as on global variable

Now you can use that variable in your plans. But what about sensitive information ?

Bamboo provides us with a feature that allows us to store sensitive information. If your variable name contains one of the keywords "PASSWORD" or "SECRET", it will automatically encrypt that information
Alt Text

That's a very nice feature and very helpful.

After the variables are configured, we can create our task and use our variables like this:

export PORT=${bamboo.PORT}
echo \_auth = ${bamboo.SECRET_NEXUS_AUTH} >> .npmrc
./docker-build.sh ${bamboo.CONTAINER_NAME} ${bamboo.PORT}

In your build logs, you will see that the variables are encrypted and the sensitive data is not stored.
Alt Text

The same way you can use the variables in your deployment tasks.

Thanks for reading and I hope this will bring a bit of security to your projects. Comments are welcome ! :)

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay