bitrise-io/envman

Name: envman

Owner: Bitrise

Description: Environment variable manager

Created: 2015-06-05 15:02:28.0

Updated: 2018-01-16 11:56:33.0

Pushed: 2018-03-12 14:53:16.0

Homepage: null

Size: 3821

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

envman

Manage your Environment Variable collections. Switch between Environment Variable sets quickly and easily, or run a single command with a pre-defined set of Environment Variables.

envman can also be used as a bridge between separate tools, one tool can register its outputs through envman and the next tool can access these as simple environment variables.

Public Beta: this repository is still under active development, frequent changes are expected, but we we don't plan to introduce breaking changes, unless really necessary. Feedback is greatly appreciated!

Part of the Bitrise Continuous Integration, Delivery and Automations Stack, with bitrise and stepman.

Who and for what?
Install

Check the latest release for instructions at: https://github.com/bitrise-io/envman/releases

How? - Use cases
Develop & Test in Docker

Or use the included scripts:

How does it work?

envman will run the command you specify with the environments found in its environment store.

When you add a new key-value pair with envman add it stores the key and value in an .envstore file in the current directory (this can be changed), and when you call envman run the next time the environments in the .envstore file will be loaded for the command, and the command will be executed with an environment which includes the specified environment variables.

This is the same as you would manually set all the environments, one by one with export KEY=value (in bash) before calling the command.

envman makes it easy to switch between environment sets and to isolate these environment sets from each other - you don't have to unset environments, the specified environment set will only be available for that single run of envman / the command and won't affect subsequent calls of the command or envman.

Usage example: Simple Bash example

Add/store an environment variable:

an add --key MY_TEST_ENV_KEY --value 'test value for test key'

Echo it:

an run bash -c 'echo "Environment test: $MY_TEST_ENV_KEY"'

Why bash -c is required? Because echo in itself does not do any environment expansion, it simply prints its input. So if you want to see the value of an environment you have to run it through a tool/shell which actually performs the environment expansion (replaces the environment key with the value associated with it).

Usage example: Ruby
Add environment variable with --value flag
em( "envman add --key SOME_KEY --value 'some value' --expand false" )
Add environment variable from an input stream
open('envman add --key SOME_KEY', 'r+') {|f|
f.write('some value')
f.close_write
f.read

Add environment variable with a value file
ire 'tempfile'

 = Tempfile.new('SOME_FILE_NAME')
.write('some value')
.close

em( "envman add --key SOME_KEY --valuefile #{file.path}" )

.unlink
Usage example: Go
Add environment variable with --value flag
rt "os/exec"

 exec.Command("envman", "add", "--key", "SOME_KEY", "--value", "some value")
:= c.Run()
rr != nil {
/ Handle error

Add environment variable from an input stream
rt "os/exec"

 RunPipedEnvmanAdd(keyStr, valueStr string) error {
envman := exec.Command("envman", "add", "--key", keyStr)
envman.Stdin = strings.NewReader(valueStr)
envman.Stdout = os.Stdout
envman.Stderr = os.Stderr
return envman.Run()


:= RunPipedEnvmanAdd("SOME_KEY", "some value")
rr != nil {
// Handle error

Add environment variable with a value file
rt (
"os/exec"
"fmt"


 exec.Command("envman", "add", "--key", "SOME_KEY", "--valuefile", "/path/to/file/which/contains/the/value")
:= c.Run()
rr != nil {
// Handle error

Usage example: Bash
Add environment variable with --value flag
an add --key SOME_KEY --value 'some value'
Add environment variable from an input stream
 "some value" | envman add --key SOME_KEY
Add environment variable with a value file
an add --key SOME_KEY --valuefile /path/to/file/which/contains/the/value --expand false
Release a new version
  1. Update go dependencies (bitrise run dep-update)
  2. PR & merge these changes to the master branch
  3. Bump RELEASE_VERSION in bitrise.yml
  4. Commit (do not Push) these changes on master branch
  5. Run bitrise run create-release
  6. Fill the current version's Release Notes section in CHANGELOG.md
  7. Push the changes to the master branch
  8. Open the project's bitrise app on bitrise.io, find the triggered create-release workflow run's build
  9. Download and test the generated bitrise binaries (envman version --full)
  10. Create the new version's release on github:
  11. Fill Tag and Version inputs
  12. Copy paste the Changelog's Release Notes and Install or upgrade sections to the release description on github
  13. Attach the generated (on bitrise.io) linux and darwin binaries to the release
  14. Push the Publish release button on github

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.