Skip to content

Commit

Permalink
Merge pull request pycontribs#59 from pabelanger/create_job
Browse files Browse the repository at this point in the history
Add the ability to create a jenkins job
  • Loading branch information
salimfadhley committed Dec 7, 2012
2 parents 69f4202 4958185 commit e901b85
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion jenkinsapi/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 156,24 @@ def has_job(self, jobname):
"""
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
Expand Down

0 comments on commit e901b85

Please sign in to comment.