From 01c2e63057a77f1c58bdcc6b1321de346f759c23 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 23 Jan 2014 10:55:08 -0800 Subject: [PATCH] Remove push refs to gerrit feature This is in preparation to move to separate merger process, which will not have access to the trigger. Similar functionality can be obtained using the new replication feature, and docs have been updated to that effect. Change-Id: I9397f7eb8466af464c8e7adb02d0a8d3eff04f9f --- NEWS.rst | 7 +++++ doc/source/triggers.rst | 58 ++++++++++++++++++++++------------------ doc/source/zuul.rst | 6 ----- tests/fixtures/zuul.conf | 1 - zuul/merger.py | 18 +------------ zuul/scheduler.py | 11 ++------ 6 files changed, 42 insertions(+), 59 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index bbaa2a206f..52f5c4f231 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -1,3 +1,10 @@ +Since 2.0.0: + +* The push_change_refs option which specified that Zuul refs should be + pushed to Gerrit has been removed. Similar functionality may be + obtained using the replication feature. See the Triggers + documentation for details. + Since 1.3.0: * The Jenkins launcher is replaced with Gearman launcher. An internal diff --git a/doc/source/triggers.rst b/doc/source/triggers.rst index 17c93abef8..21aab13c46 100644 --- a/doc/source/triggers.rst +++ b/doc/source/triggers.rst @@ -49,32 +49,11 @@ and checking it out. The parameters that provide this information are described in :ref:`launchers`. These references need to be made available via a Git repository that -is available to Jenkins. You may accomplish this by either allowing -Zuul to push the references back to Gerrit, in which case you may -simply use the Gerrit Git repository. If you do not have access to -the Gerrit repository, or would prefer Zuul not push its refs there, -you may directly serve the Git repositories that Zuul uses, and -configure Jenkins to use those. Instructions for each of these -alternatives are in the following sections. - -Pushing to Gerrit -""""""""""""""""" - -If you want to push Zuul refs back to Gerrit, set the following -permissions for your project (or ``All-Projects``) in Gerrit (where -``CI Tools`` is a group of which the user you created above is a -member):: - - [access "refs/zuul/*"] - create = group CI Tools - push = +force CI Tools - pushMerge = group CI Tools - forgeAuthor = group CI Tools - [access "refs/for/refs/zuul/*"] - pushMerge = group CI Tools - -And set ``push_change_refs`` to ``true`` in the ``zuul`` section of -zuul.conf. +is available to Jenkins. You may accomplish this by either serving +Zuul's git repositories directly, allowing Zuul to push the references +back to Gerrit, or pushing the references to a third location. +Instructions for each of these alternatives are in the following +sections. Serving Zuul Git Repos """""""""""""""""""""" @@ -102,6 +81,33 @@ depending on what the state of Zuul's repository is when the clone happens). They are, however, suitable for automated systems that respond to Zuul triggers. +Pushing to Gerrit +""""""""""""""""" + +If you want to push Zuul refs back to Gerrit, set the following +permissions for your project (or ``All-Projects``) in Gerrit (where +``CI Tools`` is a group of which the user you created above is a +member):: + + [access "refs/zuul/*"] + create = group CI Tools + push = +force CI Tools + pushMerge = group CI Tools + forgeAuthor = group CI Tools + [access "refs/for/refs/zuul/*"] + pushMerge = group CI Tools + +And set the following in ``zuul.conf``: + + [replication] + url1=ssh://user@review.example.com:29418/ + +Pushing to Another Location +""""""""""""""""""""""""""" + +Simply set one or more destination URLs in the ``replication`` section +of zuul.conf as above. + Timer ----- diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst index b4adc4da6e..d2b394ba79 100644 --- a/doc/source/zuul.rst +++ b/doc/source/zuul.rst @@ -110,12 +110,6 @@ zuul Optional: Value to pass to `git config user.name`. ``git_user_name=zuul`` -**push_change_refs** - Boolean value (``true`` or ``false``) that determines if Zuul should - push change refs to the git origin server for the git repositories in - git_dir. - ``push_change_refs=true`` - **report_times** Boolean value (``true`` or ``false``) that determines if Zuul should include elapsed times for each job in the textual report. diff --git a/tests/fixtures/zuul.conf b/tests/fixtures/zuul.conf index 0cf27e1aa2..f77e07e5e1 100644 --- a/tests/fixtures/zuul.conf +++ b/tests/fixtures/zuul.conf @@ -11,7 +11,6 @@ layout_config=layout.yaml git_dir=/tmp/zuul-test/git git_user_email=zuul@example.com git_user_name=zuul -push_change_refs=true url_pattern=http://logs.example.com/{change.number}/{change.patchset}/{pipeline.name}/{job.name}/{build.number} job_name_in_report=true zuul_url=http://zuul.example.com/p diff --git a/zuul/merger.py b/zuul/merger.py index 09011aece0..a580a2121b 100644 --- a/zuul/merger.py +++ b/zuul/merger.py @@ -147,14 +147,11 @@ class Repo(object): class Merger(object): log = logging.getLogger("zuul.Merger") - def __init__(self, trigger, working_root, push_refs, sshkey, email, - username, replicate_urls): - self.trigger = trigger + def __init__(self, working_root, sshkey, email, username, replicate_urls): self.repos = {} self.working_root = working_root if not os.path.exists(working_root): os.makedirs(working_root) - self.push_refs = push_refs if sshkey: self._makeSSHWrapper(sshkey) self.email = email @@ -307,19 +304,6 @@ class Merger(object): refspecs = replicate_refspecs.get(i.change.project, []) refspecs.append('%s:%s' % (ref, ref)) replicate_refspecs[i.change.project] = refspecs - if self.push_refs: - # Push the results upstream to the zuul ref after - # they are created. - try: - repo.push(ref, ref) - complete = self.trigger.waitForRefSha(i.change.project, - ref) - except: - self.log.exception("Unable to push %s" % ref) - return False - if not complete: - self.log.error("Ref %s did not show up in repo" % ref) - return False project_branches.append((i.change.project, i.change.branch)) self.replicateRefspecs(replicate_refspecs) return commit diff --git a/zuul/scheduler.py b/zuul/scheduler.py index 9186ff3d8f..73034c7bda 100644 --- a/zuul/scheduler.py +++ b/zuul/scheduler.py @@ -367,11 +367,6 @@ class Scheduler(threading.Thread): else: merge_name = None - if self.config.has_option('zuul', 'push_change_refs'): - push_refs = self.config.getboolean('zuul', 'push_change_refs') - else: - push_refs = False - replicate_urls = [] if self.config.has_section('replication'): for k, v in self.config.items('replication'): @@ -385,10 +380,8 @@ class Scheduler(threading.Thread): # TODO: The merger should have an upstream repo independent of # triggers, and then each trigger should provide a fetch # location. - self.merger = merger.Merger(self.triggers['gerrit'], - merge_root, push_refs, - sshkey, merge_email, merge_name, - replicate_urls) + self.merger = merger.Merger(merge_root, sshkey, merge_email, + merge_name, replicate_urls) for project in self.layout.projects.values(): url = self.triggers['gerrit'].getGitUrl(project) self.merger.addProject(project, url)