From 615ba5cca1d341765723e0a9381bfa1474c7ab5a Mon Sep 17 00:00:00 2001 From: Ramon van Alteren Date: Mon, 6 Feb 2012 09:29:04 +0100 Subject: [PATCH] Trigger parameterized builds with token as well Per request of RBURHUM. Although the api explaination recommends to use authentification / security to trigger builds and not use the (deprecated) trigger builds remotely with a security token, apparently people are still using it. --- jenkinsapi/job.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jenkinsapi/job.py b/jenkinsapi/job.py index 5447548..7adb480 100644 --- a/jenkinsapi/job.py +++ b/jenkinsapi/job.py @@ -34,11 +34,13 @@ class Job(JenkinsBase): def get_build_triggerurl( self, token=None, params={} ): if token is None: extra = "build" + elif params: + assert isinstance(token, str ), "token if provided should be a string." + params['token'] = token + extra = "buildWithParameters?" + urllib.urlencode(params) else: assert isinstance(token, str ), "token if provided should be a string." extra = "build?" + urllib.urlencode({'token':token}) - if params: - extra = "buildWithParameters?" + urllib.urlencode(params) buildurl = urlparse.urljoin( self.baseurl, extra ) return buildurl -- 2.7.4