From: Josh Davidson Date: Sat, 15 Sep 2012 19:00:22 +0000 (-0600) Subject: Fix regex search and add support for retrieving artifacts with the same name in diffe... X-Git-Tag: v0.2.23~275^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e16e662f9b7f49c8e281611dadc8e06a464ae03d;p=tools%2Fpython-jenkinsapi.git Fix regex search and add support for retrieving artifacts with the same name in different directories --- diff --git a/jenkinsapi/api.py b/jenkinsapi/api.py index a906288..ab19484 100644 --- a/jenkinsapi/api.py +++ b/jenkinsapi/api.py @@ -44,7 +44,7 @@ def get_artifacts( jenkinsurl, jobid=None, build_no=None, proxyhost=None, proxyp build = job.get_build( build_no ) else: build = job.get_last_good_build() - artifacts = dict((artifact.filename, artifact) for artifact in build.get_artifacts()) + artifacts = build.get_artifact_dict() log.info("Found %i artifacts in '%s'" % ( len(artifacts.keys() ), build_no )) return artifacts @@ -151,12 +151,12 @@ def search_artifact_by_regexp( jenkinsurl, jobid, artifactRegExp ): J = Jenkins( jenkinsurl ) j = J[ jobid ] - build_ids = j.getBuildIds() + build_ids = j.get_build_ids() for build_id in build_ids: - build = j.getBuild( build_id ) + build = j.get_build( build_id ) - artifacts = build.getArtifactDict() + artifacts = build.get_artifact_dict() for name, art in artifacts.iteritems(): md_match = artifactRegExp.search( name ) diff --git a/jenkinsapi/build.py b/jenkinsapi/build.py index 8126d5b..35dca86 100644 --- a/jenkinsapi/build.py +++ b/jenkinsapi/build.py @@ -67,7 +67,7 @@ class Build(JenkinsBase): del af, url def get_artifact_dict(self): - return dict( (a.filename, a) for a in self.get_artifacts() ) + return dict( (a.url[len(a.build.baseurl + "artifact/"):], a) for a in self.get_artifacts() ) def get_upstream_job_name(self): """