From: Ramon van Alteren Date: Mon, 6 Feb 2012 08:29:04 +0000 (+0100) Subject: Trigger parameterized builds with token as well X-Git-Tag: v0.2.23~308^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=615ba5cca1d341765723e0a9381bfa1474c7ab5a;p=tools%2Fpython-jenkinsapi.git 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. --- 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