Hi team, what is the recommended way to pass the multiple environment variables? e.g. I would like to have access to all the GitLab predefined env variables (https://docs.gitlab.com/ee/ci/variables/predefined_variables.html) when running inside a GitLab CI/CD pipeline
#Multiple environment variables
1 messages · Page 1 of 1 (latest)
👋 there's two ways you can do this:
-
Pass the env vars as an argument string or []string like
dagger call myfunc --envs $(env)< this is just an example, you'd need to adapt the subshell as needed -
Dump the env vars into a file and pass that file over like:
env > .env && dagger call myfunc --envs .env
I want to offer up option 3 🙂
export -p > env_vars.sh - this will dump your env with export prefixed
then load in and source the file, here is a one liner example
dagger core container from --address "alpine" with-file --path "env_vars.sh" --source env_vars.sh with-exec --args "sh,-c,source env_vars.sh && env" stdout
Heres an example of this working in gitlab https://github.com/levlaz/snippetbox/blob/export/.gitlab-ci.yml