zendesk/samson

Setting environment variables on a per deploy basis via API

benrudolph opened this issue ยท 1 comments

Been having difficulty trying to set env variables via an API call. The use case here is that I would like to set a HOSTS variable that limits the deploy to just affect that one host(s). I'm using the latest version of Samson. Currently my API call looks something like:


env_name="deploy[environment_variables_attributes][0][name]=HOSTS"
env_value="deploy[environment_variables_attributes][0][value]=${IP}"

deploy() {
    curl -X POST -H "Authorization: Bearer ${BEARER}" \
        -d "deploy[reference]=$2&${env_name}&${env_value}"  \
        http://10.0.1.239:3000/projects/XX/stages/deploy-${DEP_ENV}/deploys.json
}


deploy main

While this does something in Samson (the env tab shows that there is a diff), I cannot access the env variable in the deploy. I've tried setting ENV_WHITELIST but that doesn't seem to change anything.

I've taken a look at #3774 & #2608 & #1719 and done some code diving, but for the life of me can't figure out what I'm supposed to be doing. Happy to update docs too. Any help is much appreciated! Merry Christmas ๐ŸŽ„

the env vars will be available as .env, try ls .env*, to load them use source .env

ENV_WHITELIST is for exposing env vars that samson was booted with to the deploy environment

please update any docs that are incorrect ๐Ÿ‘