bitbucket-env-manager
v2.2.2
Published
Deploys Bitbucket Environment
Maintainers
Readme
Bitbucket Deploy Pipeline Environments
A command line tool to manage Bitbucket pipeline deployment variables for different environments across multiple repositories
Installation
$ npm i -g bitbucket-env-managerUsage
$ bitbucket-env-manager <command_name>Available commands
init
generate
------
deploy
list
deleteInitialize Credentials
- Setup Oauth Consumer keys in bitbucket with proper env variable edit access.
- It should create
~/.bitbucket_env_manager/<workspace>.envfile - During the auth API calls, this should create access tokens in
~/.bitbucket_env_manager/<workspace>_tokens.jsonfile
bitbucket-env-manager init- Set
OAUTH_CLIENT,OAUTH_SECRETandWORKSPACE
Generate
$ bitbucket-env-manager generate- Creates a new project manager folder with example for bitbucket environments
- In
project_envs/example/info.jsonset the workspace and repository_slug names from bitbucket.workspacerepo
Deploy
$ bitbucket-env-manager deploy- Select multiple
.envfiles to be deployed to bitbucket fromproject_envsfolder. - As indicated in example folder, the folder should
- contain environment variables file with name pattern
.env.{0|1|2}.{env_name}.{0|1|2}is for the rank of the environment to be created.- 0 -> Test, 1 -> Staging, 2 -> Production
{env_name}is the environment name to be created.
- optionally contain a
.env.repofile for repository-level variables that will be deployed once per repository - contain
info.jsonfile, withworkspace: workspace namerepo: repository_slug namesecured: [], an Array with keys from the env files (including .env.repo) that need to be marked as secured in bitbucket.envs_config:{ [env_name] : {admin_only:boolean} }, Config object for each {env_name}. admin_only boolean flag allows to specify if the environment needs to be restricted to be deployed by admins only.
- contain environment variables file with name pattern
Repository Variables
You can now manage repository-level variables using a .env.repo file:
Place
.env.repoalongside your environment .env filesVariables in this file will be deployed at the repository level
These variables will be available to all environments
The
securedarray in info.json also applies to repository variablesRepository variables are deployed only once when multiple environments are deployed together
Example:
.env.0.Developmentfilename deployment will delete any existingDevelopmentenvironment and variables from the bitbucket repository, and creates a newDevelopmentenvironment underTestCategory.
List
$ bitbucket-env-manager list- Allows to list variables from existing environment from the repository
- Select the
info.jsonfile for the desired repository - Select the
env_namefrom the list to to view the variables from the environment in bitbucket.
Delete
bitbucket-env-manager delete- Allows to delete a existing environment from the repository
- Select the
info.jsonfile for the desired repository - Select the
env_namefrom the list to remove the environment from bitbucket.
