From 5246e154f99bc072a9e8cce8ab2e67f5f85449b0 Mon Sep 17 00:00:00 2001 From: William Zhang Date: Wed, 9 May 2012 10:28:56 +0800 Subject: [PATCH] add update_config and post_data --- jenkinsapi/jenkinsbase.py | 5 +++++ jenkinsapi/job.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/jenkinsapi/jenkinsbase.py b/jenkinsapi/jenkinsbase.py index f41f2fd..61eede8 100644 --- a/jenkinsapi/jenkinsbase.py +++ b/jenkinsapi/jenkinsbase.py @@ -72,6 +72,11 @@ class JenkinsBase(object): raise return result + def post_data(self, url, content): + request = urllib2.Request(url, content) + result = urllib2.urlopen(request).read().strip() + return result + def hit_url(self, url ): fn_urlopen = self.get_jenkins_obj().get_opener() try: diff --git a/jenkinsapi/job.py b/jenkinsapi/job.py index 9a94884..df03007 100644 --- a/jenkinsapi/job.py +++ b/jenkinsapi/job.py @@ -202,3 +202,7 @@ class Job(JenkinsBase): def get_config(self): '''Returns the config.xml from the job''' return self.hit_url("%(baseurl)s/config.xml" % self.__dict__) + + def update_config(self, config): + '''Update the config.xml to the job''' + return self.post_data("%(baseurl)s/config.xml" % self.__dict__, jobconfig) -- 2.34.1