# Using KEY/VALUE pairs during build

**URL:** <https://drone.discourse.group/t/using-key-value-pairs-during-build/12266>\
**Category:** Drone Support\
**Created:** [July 14, 2022, 11:36am UTC](https://drone.discourse.group/t/using-key-value-pairs-during-build/12266 "2022-07-14T11:36:17Z")\
**Posts on this page:** 6\
**Page:** 1

<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:** [July 14, 2022, 11:36am UTC](https://drone.discourse.group/t/using-key-value-pairs-during-build/12266/1 "2022-07-14T11:36:17Z")

</div>

I was reading this discussion [Parameters When Promoting A build](https://drone.discourse.group/t/parameters-when-promoting-build/10813) 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:

```auto
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:

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

GIT_AUTHOR_EMAIL=noreply@drone
GIT_AUTHOR_NAME=drone
GIT_COMMITTER_EMAIL=noreply@drone
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

---

<div class="post-metadata">

**Author:** ![jimsheldon](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/jimsheldon/32/7760_2.png) [@jimsheldon](https://drone.discourse.group/u/jimsheldon)\
**Post date:** [July 14, 2022, 7:24pm UTC](https://drone.discourse.group/t/using-key-value-pairs-during-build/12266/2 "2022-07-14T19:24:44Z")

</div>

hello @reevespaul

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

```auto
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.

 ![Screen Shot 2022-07-14 at 3.20.49 PM](https://canada1.discourse-cdn.com/flex003/uploads/testdrone/original/2X/7/7e7c9dd29e467026e85541e7f19b2954d32672e0.png)

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

---

<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:** [July 22, 2022, 10:19am UTC](https://drone.discourse.group/t/using-key-value-pairs-during-build/12266/3 "2022-07-22T10:19:22Z")

</div>

(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.

---

<div class="post-metadata">

**Author:** ![brad](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/brad/32/4172_2.png) [@brad](https://drone.discourse.group/u/brad)\
**Post date:** [July 22, 2022, 3:57pm UTC](https://drone.discourse.group/t/using-key-value-pairs-during-build/12266/4 "2022-07-22T15:57:03Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![d1wilko](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/d1wilko/32/6474_2.png) [@d1wilko](https://drone.discourse.group/u/d1wilko)\
**Post date:** [October 18, 2022, 1:36pm UTC](https://drone.discourse.group/t/using-key-value-pairs-during-build/12266/5 "2022-10-18T13:36:51Z")

</div>

Apologies for the delay in reply I have rejoined the drone team after a secondment!

I did a quick test in [cloud.drone.io](http://cloud.drone.io) (which is an earlier version but it should be fine)

@reevespaul as you have noticed the key/value pairs are not being passed in the request for new builds - but they are for promotions - I’ll raise a ticket and fix this for new builds

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![d1wilko](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/d1wilko/32/6474_2.png) [@d1wilko](https://drone.discourse.group/u/d1wilko)\
**Post date:** [October 24, 2022, 3:40pm UTC](https://drone.discourse.group/t/using-key-value-pairs-during-build/12266/6 "2022-10-24T15:40:39Z")

</div>

Ok I have fixed this in this PR - [bug: [DRON-433]: fix new build query logic by d1wilko · Pull Request #424 · drone/drone-ui · GitHub](https://github.com/drone/drone-ui/pull/424) - it will be part of the next drone ui release 🙂
