Sending environment variables to builds triggered via API


I was wondering if there was a way to push an environment variable to a build triggered by the API?

I’m looking to parameterise the browsers being used by our end to end tests by checking an environment variable value (don’t worry, no secrets!) and I was wondering if this could be sent as a part of the POST body?


if you are using drone build restart <repo> <build> you can pass parameters using the -p flag, for example something like this:

drone build start -p key1=val1 -p key2=val2 <repo> <build>

Hi Brad,

Not currently! We’re looking to build them using the /api/repos/:owner/:project/builds/latest endpoint as opposed to the CLI.


the CLI uses the API under the covers. The variables are pretty much just passed as url query parameters when you make the API call. Reference code here:


Note that this may only work with Drone 1.x or higher


Hi Brad,

thanks for the extra info - so if I were to try to add something like BROWSER_SELECTION=primary to the /api/repos/:owner/:project/builds/latest endpoint, would it be as simple as /api/repos/:owner/:project/builds/latest?BROWSER_SELECTION=primary?


yes, that should do it


Absolutely fantastic! Thanks a lot :+1:


although I do not think /latest works with this particular endpoint