James E. Blair | 172c076 | 2012-10-02 15:35:54 -0700 | [diff] [blame] | 1 | .. _launchers: |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 2 | :title: Launchers |
| 3 | |
| 4 | Launchers |
| 5 | ========= |
| 6 | |
| 7 | Zuul has a modular architecture for launching jobs. Currently only |
| 8 | Jenkins is supported, but it should be fairly easy to add a module to |
| 9 | support other systems. Zuul makes very few assumptions about the |
| 10 | interface to a launcher -- if it can trigger jobs, cancel them, and |
| 11 | receive success or failure reports, it should be able to be used with |
| 12 | Zuul. Patches to this effect are welcome. |
| 13 | |
| 14 | Jenkins |
| 15 | ------- |
| 16 | |
| 17 | Zuul works with Jenkins using the Jenkins API and the notification |
| 18 | module. It uses the Jenkins API to trigger jobs, passing in |
| 19 | parameters indicating what should be tested. It recieves |
| 20 | notifications on job completion via the notification API (so jobs must |
| 21 | be conifigured to notify Zuul). |
| 22 | |
| 23 | Jenkins Configuration |
| 24 | ~~~~~~~~~~~~~~~~~~~~~ |
| 25 | |
| 26 | Zuul will need access to a Jenkins user. Create a user in Jenkins, |
| 27 | and then visit the configuration page for the user: |
| 28 | |
| 29 | https://jenkins.example.com/user/USERNAME/configure |
| 30 | |
| 31 | And click **Show API Token** to retrieve the API token for that user. |
Antoine Musso | 2b2d2c4 | 2012-11-20 15:07:07 +0100 | [diff] [blame] | 32 | You will need this later when configuring Zuul. Appropriate user |
| 33 | permissions must be set under the Jenkins security matrix: under the |
| 34 | ``Global`` group of permissions, check ``Read``, then under the ``Job`` |
| 35 | group of permissions, check ``Read`` and ``Build``. Finally, under |
| 36 | ``Run`` check ``Update``. If using a per project matrix, make sure the |
| 37 | user permissions are properly set for any jobs that you want Zuul to |
| 38 | trigger. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 39 | |
| 40 | Make sure the notification plugin is installed. Visit the plugin |
| 41 | manager on your jenkins: |
| 42 | |
| 43 | https://jenkins.example.com/pluginManager/ |
| 44 | |
| 45 | And install **Jenkins Notification plugin**. The homepage for the |
| 46 | plugin is at: |
| 47 | |
| 48 | https://wiki.jenkins-ci.org/display/JENKINS/Notification+Plugin |
| 49 | |
| 50 | Jenkins Job Configuration |
| 51 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 52 | |
| 53 | For each job that you want Zuul to trigger, you will need to add a |
| 54 | notification endpoint for the job on that job's configuration page. |
| 55 | Click **Add Endpoint** and enter the following values: |
| 56 | |
| 57 | **Protocol** |
| 58 | ``HTTP`` |
| 59 | **URL** |
| 60 | ``http://127.0.0.1:8001/jenkins_endpoint`` |
| 61 | |
| 62 | If you are running Zuul on a different server than Jenkins, enter the |
| 63 | appropriate URL. Note that Zuul itself has no access controls, so |
| 64 | ensure that only Jenkins is permitted to access that URL. |
| 65 | |
| 66 | Zuul will pass some parameters to Jenkins for every job it launches. |
| 67 | Check **This build is parameterized**, and add the following fields |
| 68 | with the type **String Parameter**: |
| 69 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 70 | **ZUUL_UUID** |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 71 | Zuul provided key to link builds with Gerrit events |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 72 | **ZUUL_REF** |
| 73 | Zuul provided ref that includes commit(s) to build |
| 74 | **ZUUL_COMMIT** |
| 75 | The commit SHA1 at the head of ZUUL_REF |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 76 | |
Antoine Musso | 76904f2 | 2012-10-11 12:19:40 +0200 | [diff] [blame] | 77 | Those are the only required parameters. The ZUUL_UUID is needed for Zuul to |
| 78 | keep track of the build, and the ZUUL_REF and ZUUL_COMMIT parameters are for |
| 79 | use in preparing the git repo for the build. |
| 80 | |
| 81 | .. note:: |
| 82 | The GERRIT_PROJECT and UUID parameters are deprecated respectively in |
| 83 | favor of ZUUL_PROJECT and ZUUL_UUID. |
| 84 | |
| 85 | The following parameters will be sent for all builds, but are not required so |
| 86 | you do not need to configure Jenkins to accept them if you do not plan on using |
| 87 | them: |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 88 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 89 | **ZUUL_PROJECT** |
| 90 | The project that triggered this build |
| 91 | **ZUUL_PIPELINE** |
| 92 | The Zuul pipeline that is building this job |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 93 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 94 | The following parameters are optional and will only be provided for |
| 95 | builds associated with changes (i.e., in response to patchset-created |
| 96 | or comment-added events): |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 97 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 98 | **ZUUL_BRANCH** |
| 99 | The target branch for the change that triggered this build |
| 100 | **ZUUL_CHANGE** |
| 101 | The Gerrit change ID for the change that triggered this build |
| 102 | **ZUUL_CHANGE_IDS** |
| 103 | All of the Gerrit change IDs that are included in this build (useful |
| 104 | when the DependentPipelineManager combines changes for testing) |
| 105 | **ZUUL_PATCHSET** |
| 106 | The Gerrit patchset number for the change that triggered this build |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 107 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 108 | The following parameters are optional and will only be provided for |
| 109 | post-merge (ref-updated) builds: |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 110 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 111 | **ZUUL_OLDREV** |
| 112 | The SHA1 of the old revision at this ref (recall the ref name is |
| 113 | in ZUUL_REF) |
| 114 | **ZUUL_NEWREV** |
| 115 | The SHA1 of the new revision at this ref (recall the ref name is |
| 116 | in ZUUL_REF) |
| 117 | **ZUUL_SHORT_OLDREV** |
| 118 | The shortened (7 character) SHA1 of the old revision |
| 119 | **ZUUL_SHORT_NEWREV** |
| 120 | The shortened (7 character) SHA1 of the new revision |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 121 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 122 | In order to test the correct build, configure the Jenkins Git SCM |
| 123 | plugin as follows:: |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 124 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 125 | Source Code Management: |
| 126 | Git |
| 127 | Repositories: |
| 128 | Repository URL: <your Gerrit or Zuul repository URL> |
| 129 | Advanced: |
| 130 | Refspec: ${ZUUL_REF} |
| 131 | Branches to build: |
| 132 | Branch Specifier: ${ZUUL_COMMIT} |
| 133 | Advanced: |
| 134 | Clean after checkout: True |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 135 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 136 | That should be sufficient for a job that only builds a single project. |
| 137 | If you have multiple interrelated projects (i.e., they share a Zuul |
| 138 | Change Queue) that are built together, you may be able to configure |
| 139 | the Git plugin to prepare them, or you may chose to use a shell script |
| 140 | instead. The OpenStack project uses the following script to prepare |
| 141 | the workspace for its integration testing: |
| 142 | |
| 143 | https://github.com/openstack-ci/devstack-gate/blob/master/devstack-vm-gate-wrap.sh |