let us specify Gerrit root URL

Our code was expecting the Gerrit web interface to be available at the
root of the Gerrit server which is not always the case since people
could publish the Gerrit web interface under a subdirectory. In such
configuration, the existing assumption prevents Zuul from getting
references information.

This patch adds a new optional configuration variable 'baseurl' to the
'gerrit' section. It lets one override the default:

 [gerrit]
 server=gerrit.wikimedia.org
 baseurl=https://gerrit.wikimedia.org/r

Updated Gerrit._getInfoRefs() to use 'baseurl' instead of 'server' when
creating the url to fetch references from. This is still falling back to
the old default whenever gerrit.baseurl is not set.

Change-Id: Ia9910acf46fe82c425911784412356598b3c7eac
Reviewed-on: https://review.openstack.org/16884
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
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:
Antoine Musso 2012-11-26 09:53:01 +01:00 committed by Jenkins
parent 2b2d2c40d5
commit 2747501dee
3 changed files with 11 additions and 2 deletions

View File

@ -57,6 +57,10 @@ gerrit
FQDN of Gerrit server.
``server=review.example.com``
**baseurl**
Optional: path to Gerrit web interface. Defaults to ``https://<value
of server>/``. ``baseurl=https://review.example.com/review_site/``
**user**
User name to use when logging into above server via ssh.
``user=jenkins``

View File

@ -5,6 +5,7 @@ apikey=1234567890abcdef1234567890abcdef
[gerrit]
server=review.example.com
;baseurl=https://review.example.com/r
user=jenkins
sshkey=/home/jenkins/.ssh/id_rsa

View File

@ -81,6 +81,10 @@ class Gerrit(object):
self.sched = sched
self.config = config
self.server = config.get('gerrit', 'server')
if config.has_option('gerrit', 'baseurl'):
self.baseurl = config.get('gerrit', 'baseurl')
else:
self.baseurl = 'https://%s' % self.server
user = config.get('gerrit', 'user')
if config.has_option('gerrit', 'sshkey'):
sshkey = config.get('gerrit', 'sshkey')
@ -117,8 +121,8 @@ class Gerrit(object):
message, action)
def _getInfoRefs(self, project):
url = "https://%s/p/%s/info/refs?service=git-upload-pack" % (
self.server, project)
url = "%s/p/%s/info/refs?service=git-upload-pack" % (
self.baseurl, project)
try:
data = urllib2.urlopen(url).read()
except: