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