blob: 21aab13c46d828a782aa28d874f92ad311992742 [file] [log] [blame]
James E. Blaircdd00072012-06-08 19:17:28 -07001:title: Triggers
2
3Triggers
4========
5
6The process of merging a change starts with proposing a change to be
James E. Blair63bb0ef2013-07-29 17:14:51 -07007merged. Primarily, Zuul supports Gerrit as a triggering system, as
8well as a facility for triggering jobs based on a timer.
James E. Blaircdd00072012-06-08 19:17:28 -07009Zuul's design is modular, so alternate triggering and reporting
James E. Blair63bb0ef2013-07-29 17:14:51 -070010systems can be supported.
James E. Blaircdd00072012-06-08 19:17:28 -070011
12Gerrit
13------
14
15Zuul works with standard versions of Gerrit by invoking the ``gerrit
16stream-events`` command over an SSH connection. It also reports back
17to Gerrit using SSH.
18
19Gerrit Configuration
20~~~~~~~~~~~~~~~~~~~~
21
22Zuul will need access to a Gerrit user. Consider naming the user
23*Jenkins* so that developers see that feedback from changes is from
24Jenkins (Zuul attempts to stay out of the way of developers, most
25shouldn't even need to know it's there).
26
27Create an SSH keypair for Zuul to use if there isn't one already, and
28create a Gerrit user with that key::
29
30 cat ~/id_rsa.pub | ssh -p29418 gerrit.example.com gerrit create-account --ssh-key - --full-name Jenkins jenkins
31
32Give that user whatever permissions will be needed on the projects you
33want Zuul to gate. For instance, you may want to grant ``Verified
34+/-1`` and ``Submit`` to the user. Additional categories or values may
35be added to Gerrit. Zuul is very flexible and can take advantage of
36those.
James E. Blair172c0762012-10-02 15:35:54 -070037
38Zuul References
39~~~~~~~~~~~~~~~
40
41As the DependentPipelineManager may combine several changes together
42for testing when performing speculative execution, determining exactly
43how the workspace should be set up when running a Job can be complex.
44To alleviate this problem, Zuul performs merges itself, merging or
45cherry-picking changes as required and identifies the result with a
46Git reference of the form ``refs/zuul/<branch>/Z<random sha1>``.
47Preparing the workspace is then a simple matter of fetching that ref
48and checking it out. The parameters that provide this information are
49described in :ref:`launchers`.
50
51These references need to be made available via a Git repository that
James E. Blair01c2e632014-01-23 10:55:08 -080052is available to Jenkins. You may accomplish this by either serving
53Zuul's git repositories directly, allowing Zuul to push the references
54back to Gerrit, or pushing the references to a third location.
55Instructions for each of these alternatives are in the following
56sections.
James E. Blair172c0762012-10-02 15:35:54 -070057
58Serving Zuul Git Repos
59""""""""""""""""""""""
60
61Zuul maintains its own copies of any needed Git repositories in the
62directory specified by ``git_dir`` in the ``zuul`` section of
63zuul.conf (by default, /var/lib/zuul/git). If you want to serve
64Zuul's Git repositories in order to provide Zuul refs for Jenkins, you
65can configure Apache to do so using the following directives::
66
67 SetEnv GIT_PROJECT_ROOT /var/lib/zuul/git
68 SetEnv GIT_HTTP_EXPORT_ALL
69
70 AliasMatch ^/p/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/lib/zuul/git/$1
71 AliasMatch ^/p/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/lib/zuul/git/$1
72 ScriptAlias /p/ /usr/lib/git-core/git-http-backend/
73
74And set ``push_change_refs`` to ``false`` (the default) in the
75``zuul`` section of zuul.conf.
76
77Note that Zuul's Git repositories are not bare, which means they have
78a working tree, and are not suitable for public consumption (for
79instance, a clone will produce a repository in an unpredictable state
80depending on what the state of Zuul's repository is when the clone
81happens). They are, however, suitable for automated systems that
82respond to Zuul triggers.
James E. Blair63bb0ef2013-07-29 17:14:51 -070083
James E. Blair01c2e632014-01-23 10:55:08 -080084Pushing to Gerrit
85"""""""""""""""""
86
87If you want to push Zuul refs back to Gerrit, set the following
88permissions for your project (or ``All-Projects``) in Gerrit (where
89``CI Tools`` is a group of which the user you created above is a
90member)::
91
92 [access "refs/zuul/*"]
93 create = group CI Tools
94 push = +force CI Tools
95 pushMerge = group CI Tools
96 forgeAuthor = group CI Tools
97 [access "refs/for/refs/zuul/*"]
98 pushMerge = group CI Tools
99
100And set the following in ``zuul.conf``:
101
102 [replication]
103 url1=ssh://user@review.example.com:29418/
104
105Pushing to Another Location
106"""""""""""""""""""""""""""
107
108Simply set one or more destination URLs in the ``replication`` section
109of zuul.conf as above.
110
James E. Blair63bb0ef2013-07-29 17:14:51 -0700111Timer
112-----
113
114A simple timer trigger is available as well. It supports triggering
115jobs in a pipeline based on cron-style time instructions.