Conducto for CI/CD

Environment Variables and Secrets

Matt Jachowski
Conducto
Published in
2 min readApr 7, 2020

--

Non-trivial pipelines require the specification of environment variables and secrets. This is easy in Conducto.

Explore our live demo, view the source code for this tutorial, or clone the demo and run it for yourself.

git clone https://github.com/conducto/demo.git
cd demo/cicd
python env_secrets.py --local

Alternatively, download the zip archive here.

Environment Variables

To specify environment variables, just supply the env argument to any node. Assign a dictionary of key value pairs where both keys and values must be strings.

env = {
"NUM_THREADS": "4",
"TEST_URL": "http://localhost:8080",
}

image = co.Image("bash:5.0")
command = "env | grep -e NUM_THREADS -e TEST_URL
env_test = co.Exec(command, env=env, image=image)

Secrets

Some environment variables, like passwords and tokens, are sensitive and should not be hardcoded into any scripts. You can configure Conducto with both user- and org-level secrets (if you are an admin), which will be injected into each running exec node. You can specify a dictionary of secrets with our Secrets API.

# get_my_secrets_dict() returns a dict of string to string
user_secrets = get_my_secrets_dict()
token = co.api.Auth().get_token_from_shell()
secrets = co.api.Secrets()

secrets.put_user_secrets(token, user_secrets, replace=False)

Or you can enter them through our web interface.

Specifying AWS keys as user-level secrets.

That’s it! Now, with the information you learned in Your First Pipeline, Execution Environment, Data Stores, Node Parameters, CI/CD Extras, and here, you can create arbitrarily complex pipelines.

--

--