# "drone exec" does not support global pipeline variables

**URL:** <https://drone.discourse.group/t/drone-exec-does-not-support-global-pipeline-variables/7608>\
**Category:** Drone Bugs\
**Created:** [June 10, 2021, 8:42am UTC](https://drone.discourse.group/t/drone-exec-does-not-support-global-pipeline-variables/7608 "2021-06-10T08:42:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![1-alex98](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/1-alex98/32/3324_2.png) [@1-alex98](https://drone.discourse.group/u/1-alex98)\
**Post date:** [June 10, 2021, 8:42am UTC](https://drone.discourse.group/t/drone-exec-does-not-support-global-pipeline-variables/7608/1 "2021-06-10T08:42:19Z")

</div>

Following pipeline(docker pipeline as requested by docs should be supported):

```auto
kind: pipeline
type: docker
name: default
platform:
  os: linux

environment:
  TEST: test

steps:
  - name: test
    image: alpine
    commands:
      - echo $${TEST}

```

Follows syntax as described in [Syntax | Drone](https://docs.drone.io/pipeline/environment/syntax/#per-pipeline)

But running it locally gives following output:

```auto
alex@alex-latop:~/test/drone bug test$ drone exec
[test:0] + echo ${TEST}
[test:1] 

```

Expected: Environment variable is in output

Workaround: set it per step instead of per pipeline

```auto
alex@alex-latop:~/test/drone bug test$ drone --version
drone version 1.2.4

```

---

<div class="post-metadata">

**Author:** ![slinstaedt](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/slinstaedt/32/5250_2.png) [@slinstaedt](https://drone.discourse.group/u/slinstaedt)\
**Post date:** [June 10, 2021, 6:05pm UTC](https://drone.discourse.group/t/drone-exec-does-not-support-global-pipeline-variables/7608/2 "2021-06-10T18:05:21Z")

</div>

I also stumbled over this over a year ago. Would like to see this fixed, too.

---

<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:** [June 10, 2021, 6:25pm UTC](https://drone.discourse.group/t/drone-exec-does-not-support-global-pipeline-variables/7608/3 "2021-06-10T18:25:06Z")

</div>

the problem is that `drone exec` uses the old `drone/drone-yaml` and `drone/drone-runtime` libraries which lacks the global environment variable feature. These libraries were deprecated and are no longer being used by the Docker runner. The solution is to upgrade `drone exec` to use `drone-runners/drone-runner-docker` as opposed to the previously mentioned libraries.

So tldr the feature works fine when the Docker runner is running your pipeline, but not when you are running locally with `drone exec`

---

<div class="post-metadata">

**Author:** ![reevespaul](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/reevespaul/32/3425_2.png) [@reevespaul](https://drone.discourse.group/u/reevespaul)\
**Post date:** [August 5, 2021, 2:04pm UTC](https://drone.discourse.group/t/drone-exec-does-not-support-global-pipeline-variables/7608/5 "2021-08-05T14:04:35Z")

</div>

I’ve just run into this problem and was about to post a bug report - but thankfully discourse pointed me to previous reports - well done! That saves time and bandwidth.

But, back to the problem and the suggested solution

> [@Drone-vault plugin - missing vault address](https://drone.discourse.group/t/drone-vault-plugin-missing-vault-address/9299/3):
>
> upgrade `drone exec` to use `drone-runners/drone-runner-docker` as opposed to the previously mentioned libraries

- is this scheduled to be fixed? I’ve never written any golang but it looks as if it requires a bit more than some copy/paste otherwise I’d try it myself. But I’ve already lost a lot of time today on this today ☹

There is another associated bug here - afaict the yaml is parsed differently. I think I stumbled across that yesterday so yaml that works with drone exec may not work with the runner. The idea behing drone exec is great , but in its currently implementation it is not so useful.

I did notice, however, as a workaround it is possible to add global vars to the env var file that drone exec loads. That seems to work, but again will not work the same way as the runner as the runner requires `environment:` to be declared for each pipeline, not the entire file. Which again is a bit of a bummer.

---

<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 5, 2021, 2:29pm UTC](https://drone.discourse.group/t/drone-exec-does-not-support-global-pipeline-variables/7608/6 "2021-08-05T14:29:37Z")

</div>

> [@Drone-vault plugin - missing vault address](https://drone.discourse.group/t/drone-vault-plugin-missing-vault-address/9299/5):
>
> is this scheduled to be fixed?

yes

> [@Drone-vault plugin - missing vault address](https://drone.discourse.group/t/drone-vault-plugin-missing-vault-address/9299/5):
>
> There is another associated bug here - afaict the yaml is parsed differently

drone exec uses an old, deprecated yaml parser and execution engine. the old yaml parser and execution engine were replaced in drone core about 18 months ago, but have not been replaced in the command line tools yet. so moving to the new yaml parser and execution engine will solve any and all issues where you see a discrepancy in behavior.

---

<div class="post-metadata">

**Author:** ![Michael1](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/michael1/32/2401_2.png) [@Michael1](https://drone.discourse.group/u/Michael1)\
**Post date:** [December 1, 2021, 10:24am UTC](https://drone.discourse.group/t/drone-exec-does-not-support-global-pipeline-variables/7608/7 "2021-12-01T10:24:22Z")

</div>

> [@Drone-vault plugin - missing vault address](https://drone.discourse.group/t/drone-vault-plugin-missing-vault-address/9299/6):
>
> > [@Drone-vault plugin - missing vault address](https://drone.discourse.group/t/drone-vault-plugin-missing-vault-address/9299/5):
> >
> > is this scheduled to be fixed?
> 
> yes

Hi @bradrydzewski ,  
are there any news on this topic?  
TIA!
