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


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

and this is the output:

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

[email protected]
[email protected]

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

- name: env
  image: busybox
  - env
    - promote
    - 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:

@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?

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

I did a quick test in (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 :slight_smile:

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 - it will be part of the next drone ui release :slight_smile:

1 Like