From c71af12b02d310a3ed8eb6b0a232b473f0f780fb Mon Sep 17 00:00:00 2001 From: Leonard Martin Date: Tue, 25 Aug 2020 16:02:07 +0100 Subject: [PATCH] Pass parameters to promote/rollback as querystring Custom build params are ignored when sent on the POST body and need to be attached to the querystring. Modify the promote and rollback functions to ensure that the params are sent in a way that is recognised by the Drone server. --- lib/index.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/index.js b/lib/index.js index cfbc678..26ed3ce 100644 --- a/lib/index.js +++ b/lib/index.js @@ -328,14 +328,14 @@ class Client { Joi.assert(target, Joi.string().required(), 'Must specify target') Joi.assert(params, Joi.object().pattern(/.*/, Joi.string()), 'Specify valid params') + const qs = Querystring.stringify( + Object.assign( + { target: target }, + params + ) + ) return this._axios.post( - `/api/repos/${owner}/${repo}/builds/${number}/promote`, - Querystring.stringify( - Object.assign( - { target: target }, - params - ) - ) + `/api/repos/${owner}/${repo}/builds/${number}/promote?${qs}` ) } @@ -354,14 +354,14 @@ class Client { Joi.assert(target, Joi.string().required(), 'Must specify target') Joi.assert(params, Joi.object().pattern(/.*/, Joi.string()), 'Specify valid params') + const qs = Querystring.stringify( + Object.assign( + { target: target }, + params + ) + ) return this._axios.post( - `/api/repos/${owner}/${repo}/builds/${number}/rollback`, - Querystring.stringify( - Object.assign( - { target: target }, - params - ) - ) + `/api/repos/${owner}/${repo}/builds/${number}/rollback/${qs}` ) }