add update_config and post_data
authorWilliam Zhang <jollychang@gmail.com>
Wed, 9 May 2012 02:28:56 +0000 (10:28 +0800)
committerWilliam Zhang <jollychang@gmail.com>
Wed, 9 May 2012 02:28:56 +0000 (10:28 +0800)
jenkinsapi/jenkinsbase.py
jenkinsapi/job.py

index f41f2fd..61eede8 100644 (file)
@@ -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:
index 9a94884..df03007 100644 (file)
@@ -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)