I’m attempting to verify that the following use case is not possible (and request that it be added it if not )
I wish to do something like:
$ drone exec -e ENV_VAR=value --local
and have ENV_VAR be set as an environment variable across all build steps in a .drone.yml pipeline.
My use case:
Certain environment variables are only available on our Drone server. These variables are integral to running the build successfully. For example, this is how we store service account credentials to various other systems. Without said env vars, the build will always fail, leaving us to to repeatedly push (or force push) new commits just to debug what’s wrong with our .drone.yml.
So my questions:
Is this not possible? I’ve looked around but fear I may have missed something.
Is there a better (currently functioning) way to get what I’m after?
(if no to both ) Could this be integrated into a future release?
Is this not possible? I’ve looked around but fear I may have missed something.
-e is not currently supported
Is there a better (currently functioning) way to get what I’m after?
Unfortunately I do not think so
Could this be integrated into a future release?
Absolutely. Adding environment variables to the pipeline should be a relatively simple change. It will require a few minor modifications, which I tried to summarize below with some sample code:
envs := map[string]string{}
for _, env := range c.StringSlice("e") { // get -e KEY=VALUE variables
envs = append(envs, strings.Splitn(env, "=", 2)
}
And then we pass the map to build runner like this:
If you are willing to open an issue for tracking, we can plan to include in the next release. If this is a high-priority item and you want to submit a PR, I am happy to get that expedited and merged for you.