From: Paul Belanger Date: Wed, 14 Nov 2012 04:14:16 +0000 (-0500) Subject: Add the ability to create a jenkins job X-Git-Tag: v0.2.23~264^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=49581858a6a1c8a170016d6ee4dc4661d32a0b01;p=tools%2Fpython-jenkinsapi.git Add the ability to create a jenkins job Signed-off-by: Paul Belanger --- diff --git a/jenkinsapi/jenkins.py b/jenkinsapi/jenkins.py index 7875697..f23a2c1 100644 --- a/jenkinsapi/jenkins.py +++ b/jenkinsapi/jenkins.py @@ -156,9 +156,24 @@ class Jenkins(JenkinsBase): """ return jobname in self.get_jobs_list() + def create_job(self, jobname, config): + """ + Create a job + :param jobname: name of new job, str + :param config: configuration of new job, xml + :return: new Job obj + """ + headers = {'Content-Type': 'text/xml'} + qs = urllib.urlencode({'name': jobname}) + url = urlparse.urljoin(self.baseurl, "createItem?%s" % qs) + request = urllib2.Request(url, config, headers) + self.post_data(request, None) + newjk = self._clone() + return newjk.get_job(jobname) + def copy_job(self, jobname, newjobname): """ - Copy a job + Copy a job :param jobname: name of a exist job, str :param newjobname: name of new job, str :return: new Job obj