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. |
| 32 | You will need this later when configuring Zuul. Make sure that this |
| 33 | user has appropriate permission to build any jobs that you want Zuul |
| 34 | to trigger. |
| 35 | |
| 36 | Make sure the notification plugin is installed. Visit the plugin |
| 37 | manager on your jenkins: |
| 38 | |
| 39 | https://jenkins.example.com/pluginManager/ |
| 40 | |
| 41 | And install **Jenkins Notification plugin**. The homepage for the |
| 42 | plugin is at: |
| 43 | |
| 44 | https://wiki.jenkins-ci.org/display/JENKINS/Notification+Plugin |
| 45 | |
| 46 | Jenkins Job Configuration |
| 47 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 48 | |
| 49 | For each job that you want Zuul to trigger, you will need to add a |
| 50 | notification endpoint for the job on that job's configuration page. |
| 51 | Click **Add Endpoint** and enter the following values: |
| 52 | |
| 53 | **Protocol** |
| 54 | ``HTTP`` |
| 55 | **URL** |
| 56 | ``http://127.0.0.1:8001/jenkins_endpoint`` |
| 57 | |
| 58 | If you are running Zuul on a different server than Jenkins, enter the |
| 59 | appropriate URL. Note that Zuul itself has no access controls, so |
| 60 | ensure that only Jenkins is permitted to access that URL. |
| 61 | |
| 62 | Zuul will pass some parameters to Jenkins for every job it launches. |
| 63 | Check **This build is parameterized**, and add the following fields |
| 64 | with the type **String Parameter**: |
| 65 | |
| 66 | **UUID** |
| 67 | Zuul provided key to link builds with Gerrit events |
| 68 | **GERRIT_PROJECT** |
| 69 | Zuul provided project name |
| 70 | **GERRIT_BRANCH** |
| 71 | Zuul provided branch name |
| 72 | **GERRIT_CHANGES** |
| 73 | Zuul provided list of dependent changes to merge |
| 74 | |
| 75 | You may find it useful to use the ``GERRIT_*`` variables in your job. |
| 76 | In particular, ``GERRIT_CHANGES`` indicates the change or changes that |
| 77 | should be tested. If Zuul has decided that more than one change |
| 78 | should be merged and tested together, they will all be listed in |
| 79 | ``GERRIT_CHANGES``. The format for the description of one change is:: |
| 80 | |
| 81 | project:branch:refspec |
| 82 | |
| 83 | And multiple changes are separated by a carat ("^"). E.g.:: |
| 84 | |
| 85 | testproject:master:refs/changes/20/420/1^testproject:master:refs/changes/21/421/1" |
| 86 | |
| 87 | The OpenStack project uses the following script to update the |
| 88 | repository in a workspace and merge appropriate changes: |
| 89 | |
Antoine Musso | fec5c7a | 2012-09-22 12:32:37 +0200 | [diff] [blame] | 90 | https://github.com/openstack/openstack-ci-puppet/blob/master/modules/jenkins/files/slave_scripts/gerrit-git-prep.sh |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 91 | |
| 92 | Gerrit events that do not include a change (e.g., ref-updated events |
| 93 | which are emitted after a git ref is updated (i.e., a commit is merged |
| 94 | to master)) require a slightly different set of parameters: |
| 95 | |
| 96 | **UUID** |
| 97 | Zuul provided key to link builds with Gerrit events |
| 98 | **GERRIT_PROJECT** |
| 99 | Zuul provided project name |
| 100 | **GERRIT_REFNAME** |
| 101 | Zuul provided ref name |
| 102 | **GERRIT_OLDREV** |
| 103 | Zuul provided old reference for ref-updated |
| 104 | **GERRIT_NEWREV** |
| 105 | Zuul provided new reference for ref-updated |
| 106 | |