From 2747501dee0e519f8a8d37442192fb8f595edaec Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Mon, 26 Nov 2012 09:53:01 +0100 Subject: [PATCH] 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 Reviewed-by: James E. Blair Approved: Clark Boylan Reviewed-by: Clark Boylan Tested-by: Jenkins --- doc/source/zuul.rst | 4 ++++ etc/zuul.conf-sample | 1 + zuul/trigger/gerrit.py | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst index 4f661269a3..92b7a6fa80 100644 --- a/doc/source/zuul.rst +++ b/doc/source/zuul.rst @@ -57,6 +57,10 @@ gerrit FQDN of Gerrit server. ``server=review.example.com`` +**baseurl** + Optional: path to Gerrit web interface. Defaults to ``https:///``. ``baseurl=https://review.example.com/review_site/`` + **user** User name to use when logging into above server via ssh. ``user=jenkins`` diff --git a/etc/zuul.conf-sample b/etc/zuul.conf-sample index cba007db56..75d1ca5fa7 100644 --- a/etc/zuul.conf-sample +++ b/etc/zuul.conf-sample @@ -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 diff --git a/zuul/trigger/gerrit.py b/zuul/trigger/gerrit.py index 84bead0a45..3a8f104136 100644 --- a/zuul/trigger/gerrit.py +++ b/zuul/trigger/gerrit.py @@ -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: