Using KEY/VALUE pairs during build

I was reading this discussion Parameters When Promoting A build and I still cannot get KEY/VALUE pairs to work.

I carefully add KEY = ATEST and VALUE = 123 via the web gui when I do a new build

This is the pipeline:

kind: pipeline
type: docker
name: build_linux

steps:

- name: smoketest
  image: localregistry/tw-0.0
  environment:
    _ENVTEST: envtest
  commands:
    - env | grep -v DRONE | grep -v CI | sort

and this is the output:

+ env | grep -v DRONE | grep -v CI | sort

[email protected]
GIT_AUTHOR_NAME=drone
[email protected]
GIT_COMMITTER_NAME=drone
GIT_TERMINAL_PROMPT=0
HOME=/root
HOSTNAME=ea33d4bad639
OS_NAME=tw
OS_VERSION=0.0
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/drone/src
SHLVL=0
_=/usr/bin/env
_ENVTEST=envtest

I’m convinced this is a bug.
This is with drone server v2.12.1

hello @reevespaul

I was just able to successfully test environment variables in a promoted pipeline with this config

kind: pipeline
type: docker
name: default

steps:
- name: env
  image: busybox
  commands:
  - env
  when:
    event:
    - promote
    target:
    - example

I set two variables, SOME_VARIABLE and ANOTHER_VARIABLE, both appeared in the log output from the env command.

In the past I have forgotten to hit the “+Add” button when adding variables, any chance that could be the issue?

(Sorry for the delayed reply - had to go down other rabbit holes.)

Yeah, I’ve been caught out by missing the ‘+Add’ button in the past - definitely bad UI design. But no, that is not the problem here.

I tested with ‘promote’ and yes - it works, just as you say.
But I was trying to pass KEY/VALUE pairs in the initial build. That is the bit that doesn’t work. Surely, for this feature to be useful it should support passing these variables at build and promote.

I was able to confirm this is supported and working in our API / backend code:
https://github.com/harness/drone/blame/3a23b0d0d4476701640683bc1010c4357e5543e7/handler/api/repos/builds/create.go#L94

@d1wilko can you please check the frontend code to see if we are passing build parameters as query parameters when invoking the API to create a new build?