Drop Jenkins.getBestBuildURL() method

The ability to configure success and failure URL patterns (cf.
'success-pattern' and 'failure-pattern') obsoletes the need to
guess-by-fetching an appropriate link for the build status, which can be
extremely expensive. (Wikimedia's Zuul instance makes three HTTP requests per
invocation -- 'testReport', which 302s to 'testReport/', which 404s, and then
'consoleFull', which often runs to hundreds of kilobytes.)

Also corrects a small typo in README.rst.

Change-Id: Ib222f544c98253152a5e787ec0cdf28fa2d80cf6
Reviewed-on: https://review.openstack.org/28128
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
This commit is contained in:
Ori Livneh 2013-05-02 19:13:53 -07:00 committed by Jenkins
parent 031e23f723
commit 7191ee881d
4 changed files with 12 additions and 35 deletions

View File

@ -17,4 +17,4 @@ Use `git review` to submit patches (after creating a gerrit account that links t
# Do your commits
$ git review
# Enter your username if promped
# Enter your username if prompted

View File

@ -23,7 +23,6 @@ import threading
import time
import urllib # for extending jenkins lib
import urllib2 # for extending jenkins lib
import urlparse
from uuid import uuid4
import jenkins
@ -378,21 +377,6 @@ class Jenkins(object):
self.log.error("Build %s has not started but "
"was not found in queue" % build)
def getBestBuildURL(self, url):
try:
test_url = urlparse.urljoin(url, 'testReport')
self.jenkins.jenkins_open(urllib2.Request(test_url))
return test_url
except:
pass
try:
console_url = urlparse.urljoin(url, 'consoleFull')
self.jenkins.jenkins_open(urllib2.Request(console_url))
return console_url
except:
pass
return url
def setBuildDescription(self, build, description):
if not build.number:
return
@ -412,8 +396,6 @@ class Jenkins(object):
self.log.debug("Found build %s" % build)
del self.builds[uuid]
if url:
build.base_url = url
url = self.getBestBuildURL(url)
build.url = url
build.result = status
build.number = number

View File

@ -450,7 +450,6 @@ class Build(object):
def __init__(self, job, uuid):
self.job = job
self.uuid = uuid
self.base_url = None
self.url = None
self.number = None
self.result = None

View File

@ -922,17 +922,13 @@ class BasePipelineManager(object):
result = job.failure_message
if job.failure_pattern:
pattern = job.failure_pattern
url = None
if build.url:
if pattern:
url = pattern.format(change=changeish,
pipeline=self.pipeline,
job=job,
build=build)
else:
url = build.url
if not url:
url = job.name
if pattern:
url = pattern.format(change=changeish,
pipeline=self.pipeline,
job=job,
build=build)
else:
url = build.url or job.name
if not job.voting:
voting = ' (non-voting)'
else:
@ -960,10 +956,10 @@ class BasePipelineManager(object):
change = build.build_set.change
for build in build.build_set.getBuilds():
if build.base_url:
if build.url:
concurrent_builds += """\
<li>
<a href="{build.base_url}">
<a href="{build.url}">
{build.job.name} #{build.number}</a>: {build.result}
</li>
""".format(build=build)
@ -979,7 +975,7 @@ class BasePipelineManager(object):
if other_build:
other_builds += """\
<li>
Preceded by: <a href="{build.base_url}">
Preceded by: <a href="{build.url}">
{build.job.name} #{build.number}</a>
</li>
""".format(build=other_build)
@ -990,7 +986,7 @@ class BasePipelineManager(object):
if other_build:
other_builds += """\
<li>
Succeeded by: <a href="{build.base_url}">
Succeeded by: <a href="{build.url}">
{build.job.name} #{build.number}</a>
</li>
""".format(build=other_build)