"drone exec" does not support global pipeline variables

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

kind: pipeline
type: docker
name: default
  os: linux

  TEST: test

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

Follows syntax as described in Syntax | Drone

But running it locally gives following output:

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

Expected: Environment variable is in output

Workaround: set it per step instead of per pipeline

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

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

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

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

  • 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 :frowning:

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.


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.

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