get_vsc_url
authorjollychang <jollychang@gmail.com>
Tue, 18 Sep 2012 07:38:02 +0000 (15:38 +0800)
committerjollychang <jollychang@gmail.com>
Tue, 18 Sep 2012 07:38:02 +0000 (15:38 +0800)
jenkinsapi/job.py

index 2dfe279..e84ed11 100644 (file)
@@ -228,6 +228,19 @@ class Job(JenkinsBase):
             }
         return vcsmap.get(bs.project.scm.attrs['class'])
 
+    def get_vcs_url(self):
+        if self._config is None:
+            self.load_config()
+
+        bs = BeautifulSoup(self._config, 'xml') 
+        vcsurlmap = {
+            'svn' : lambda : bs.project.scm.find("hudson.scm.SubversionSCM_-ModuleLocation").remote.text, 
+            'git' : lambda : bs.project.scm.userRemoteConfigs.find('hudson.plugins.git.UserRemoteConfig').url.text, 
+            'hg' : lambda : bs.project.scm.source.text,
+        }
+        vcs = self.get_vcs()
+        return vcsurlmap[vcs]()
+
     def update_config(self, config):
         '''Update the config.xml to the job'''
         return self.post_data("%(baseurl)s/config.xml" % self.__dict__, config)