# Setting global agent environment URL variables

**URL:** <https://drone.discourse.group/t/setting-global-agent-environment-url-variables/10074>\
**Category:** Drone Support\
**Created:** [May 5, 2019, 11:56pm UTC](https://drone.discourse.group/t/setting-global-agent-environment-url-variables/10074 "2019-05-05T23:56:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![blopker](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/blopker/32/5855_2.png) [@blopker](https://drone.discourse.group/u/blopker)\
**Post date:** [May 5, 2019, 11:56pm UTC](https://drone.discourse.group/t/setting-global-agent-environment-url-variables/10074/1 "2019-05-05T23:56:56Z")

</div>

I’ve been trying to hook Drone up to a private Python repository so as to use it as a default for all ‘pip’ installs. According to the ‘pip’ docs, ‘pip’ will respect a PIP\_INDEX\_URL environment variable if set. So I’m tying to figure out how to set that variable for all builds.

The first way I found was using the DRONE\_RUNNER\_ENVIRON environment variable. Unfortunately, there’s a known issue (bug?) with the configuration library Drone uses. Putting a URL in the variable results in an error:

> error=“envconfig.Process: assigning RUNNER\_DRONE\_RUNNER\_ENVIRON to Environ: converting ‘PIP\_INDEX\_URL:[https://piprepo/](https://piprepo/)’ to type map[string]string. details: invalid map item: "PIP\_INDEX\_URL:[https://piprepo/\](https://piprepo/%5C)”

See [Allow map[string]string to support ':' in its keys and values · Issue #84 · kelseyhightower/envconfig · GitHub](https://github.com/kelseyhightower/envconfig/issues/84). They mention workarounds there, but it would have to be implemented in Drone.

I also came across DRONE\_GLOBAL\_ENVIRON, but it no longer seems available in 1.0+.

Are there any other options for setting global environment variables?

Thank you.

---

<div class="post-metadata">

**Author:** ![blopker](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/blopker/32/5855_2.png) [@blopker](https://drone.discourse.group/u/blopker)\
**Post date:** [May 6, 2019, 12:01am UTC](https://drone.discourse.group/t/setting-global-agent-environment-url-variables/10074/2 "2019-05-06T00:01:16Z")

</div>

There’s also a potential fix here: [https://github.com/kelseyhightower/envconfig/pull/133](https://github.com/kelseyhightower/envconfig/pull/133)

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [May 6, 2019, 12:19am UTC](https://drone.discourse.group/t/setting-global-agent-environment-url-variables/10074/3 "2019-05-06T00:19:19Z")

</div>

As of Drone 1.0 the variable name is DRONE\_RUNNER\_ENVIRON

The workaround mentioned in that thread is using custom json decoder for the map. This would be a breaking change for our users and is therefore something we would prefer to avoid. With that being said, perhaps we could introduce DRONE\_RUNNER\_ENVIRON\_FILE as a new variable that loads a set of environment variables from file? We could use [https://github.com/joho/godotenv](https://github.com/joho/godotenv) (existing dependency) which would not be subject to the same limitation as the envconfig library.

---

<div class="post-metadata">

**Author:** ![blopker](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/blopker/32/5855_2.png) [@blopker](https://drone.discourse.group/u/blopker)\
**Post date:** [May 6, 2019, 4:25pm UTC](https://drone.discourse.group/t/setting-global-agent-environment-url-variables/10074/4 "2019-05-06T16:25:53Z")

</div>

An environment file would be perfect. I would generally prefer that to DRONE\_RUNNER\_ENVIRON anyway. Putting multiple key/value pairs in a string is a little unwieldy once you get past 3 or so.

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [August 20, 2019, 4:32pm UTC](https://drone.discourse.group/t/setting-global-agent-environment-url-variables/10074/5 "2019-08-20T16:32:00Z")

</div>

The latest build of the autoscaler support the following configuration parameter:

```auto
DRONE_AGENT_ENV_FILE=/path/to/env/file

```

This load an environment file using the [godotenv](https://github.com/joho/godotenv) library.

---

<div class="post-metadata">

**Author:** ![blopker](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/blopker/32/5855_2.png) [@blopker](https://drone.discourse.group/u/blopker)\
**Post date:** [August 21, 2019, 3:50am UTC](https://drone.discourse.group/t/setting-global-agent-environment-url-variables/10074/6 "2019-08-21T03:50:50Z")

</div>

Fantastic! Thanks for the update.

---

<div class="post-metadata">

**Author:** ![tuanalumi](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/tuanalumi/32/5528_2.png) [@tuanalumi](https://drone.discourse.group/u/tuanalumi)\
**Post date:** [October 15, 2019, 3:54am UTC](https://drone.discourse.group/t/setting-global-agent-environment-url-variables/10074/7 "2019-10-15T03:54:59Z")

</div>

Is there any other fixes for this? I don’t use autoscaler, so I can’t use DRONE\_AGENT\_ENV\_FILE.

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [September 9, 2021, 11:17pm UTC](https://drone.discourse.group/t/setting-global-agent-environment-url-variables/10074/8 "2021-09-09T23:17:49Z")

</div>

This feature is not limited to the autoscaler. If you want to pass an environment file directly to the runner you can use the following setting:  
[https://docs.drone.io/runner/docker/configuration/reference/drone-runner-env-file/](https://docs.drone.io/runner/docker/configuration/reference/drone-runner-env-file/)
