bitbucket-pipelines-env-vars-populator

1.0.1 • Public • Published

Bitbucket Pipelines Env Vars Populator

Utility to populate Bitbucket pipelines' environment variables.

The problem

Manual configuration of the piepeline environment variables can lead to errors: you can forget to configure a specific variable for a specific environment, you can misspell the variable key, etc. With this tool you will be sure that each evironment will contain the same variables, and that not error are performed during variables population.

Getting started

  • Create you .env file from the .env.example file
  • Create your CSV input file from the ./in/example.csv file
  • npm start to populate the variables!

Use the Binary to deploy and .env file into a repo deployment

  • install as dependency in your project or globally with
  • run deploy-bitbucket-envs

Do you want to know more?

CSV structure

The input file has to be a CSV file (for which you can define you own symbol separator). The CSV file has to have two mandatory columns:

  • key column: define the variable key (aka variable name)
  • secured column: wheather or not the variable should be secured and not visible from the Bitbucket console. Any other column in you CSV file will correspond to a different environment. You can specify as many columns as you want, and each column should be named with you environment slug (aka environment name).

Example

You want to populate your pipeline environments as following:

Test environment

  • Variable named DANIELE with value SALVATORE
  • Secured variable named MY_PASSWORD with value SECURE_PWD

Production environment

  • Variable named DANIELE with value SAVER
  • Secured variable named MY_PASSWORD with value 12$trRt

You will then create a CSV file similar to:

key;secured;test;production
DANIELE;FALSE;SALVATORE;SAVER
MY_PASSWORD;TRUE;SECURE_PWD;12$trRt

** PS: note that the CSV separator is ; so you will need to specify it in your .env file. **

while running the tool with the npm start command, you will see usefull log message in your console.

From you Bitbucket > Deployment console you will then see something similar to: Bitbucket console screenshot

You can specify additional environment adding new column to the CSV.

The following image shows the correspondence between CSV and Bitbucket console:

Correspondence

Important!

** You wrote your account password in the .env file. Remember to remove it once you are done! ** At the moment in which this tool was developer, the library used to interact with Bitbucket API do not support any other authentication method differnt from simple auth username/password.

Assumptions

  • You already have a bitbucket workspace in place
  • You already have a bitbuket repository in place
  • You already configured the bitbucket repository to enable pipelines

Readme

Keywords

none

Package Sidebar

Install

npm i bitbucket-pipelines-env-vars-populator

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

1.97 MB

Total Files

19

Last publish

Collaborators

  • danielesalvatore