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