James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 1 | :title: Launchers |
| 2 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 3 | .. _Gearman: http://gearman.org/ |
Antoine Musso | d06f2a6 | 2012-11-16 17:40:58 +0100 | [diff] [blame] | 4 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 5 | .. _`Gearman Plugin`: |
| 6 | https://wiki.jenkins-ci.org/display/JENKINS/Gearman+Plugin |
| 7 | |
Joshua Hesketh | 6a0a618 | 2014-03-13 13:23:30 +1100 | [diff] [blame] | 8 | .. _`Turbo-Hipster`: |
| 9 | http://git.openstack.org/cgit/stackforge/turbo-hipster/ |
| 10 | |
| 11 | .. _`Turbo-Hipster Documentation`: |
| 12 | http://turbo-hipster.rtfd.org/ |
| 13 | |
Joshua Hesketh | 36c3fa5 | 2014-01-22 11:40:52 +1100 | [diff] [blame] | 14 | .. _FormPost: http://docs.openstack.org/developer/swift/misc.html#module-swift.common.middleware.formpost |
| 15 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 16 | .. _launchers: |
Antoine Musso | d06f2a6 | 2012-11-16 17:40:58 +0100 | [diff] [blame] | 17 | |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 18 | Launchers |
| 19 | ========= |
| 20 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 21 | Zuul has a modular architecture for launching jobs. Currently, the |
| 22 | only supported module interfaces with Gearman_. This design allows |
| 23 | any system to run jobs for Zuul simply by interfacing with a Gearman |
| 24 | server. The recommended way of integrating a new job-runner with Zuul |
| 25 | is via this method. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 26 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 27 | If Gearman is unsuitable, Zuul may be extended with a new launcher |
| 28 | module. Zuul makes very few assumptions about the interface to a |
| 29 | launcher -- if it can trigger jobs, cancel them, and receive success |
| 30 | or failure reports, it should be able to be used with Zuul. Patches |
| 31 | to this effect are welcome. |
| 32 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 33 | Zuul Parameters |
| 34 | --------------- |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 35 | |
Joshua Hesketh | e898716 | 2014-03-13 13:05:33 +1100 | [diff] [blame] | 36 | Zuul will pass some parameters with every job it launches. These are |
| 37 | for workers to be able to get the repositories into the state they are |
| 38 | intended to be tested in. Builds can be triggered either by an action |
| 39 | on a change or by a reference update. Both events share a common set |
| 40 | of parameters and more specific parameters as follows: |
Antoine Musso | e0f5bb4 | 2014-03-04 11:30:37 +0100 | [diff] [blame] | 41 | |
| 42 | Common parameters |
| 43 | ~~~~~~~~~~~~~~~~~ |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 44 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 45 | **ZUUL_UUID** |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 46 | Zuul provided key to link builds with Gerrit events. |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 47 | **ZUUL_REF** |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 48 | Zuul provided ref that includes commit(s) to build. |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 49 | **ZUUL_COMMIT** |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 50 | The commit SHA1 at the head of ZUUL_REF. |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 51 | **ZUUL_PROJECT** |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 52 | The project that triggered this build. |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 53 | **ZUUL_PIPELINE** |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 54 | The Zuul pipeline that is building this job. |
Arx Cruz | b1b010d | 2013-10-28 19:49:59 -0200 | [diff] [blame] | 55 | **ZUUL_URL** |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 56 | The URL for the zuul server as configured in zuul.conf. |
Joshua Hesketh | ba8776a | 2014-01-12 14:35:40 +0800 | [diff] [blame] | 57 | A test runner may use this URL as the basis for fetching |
Arx Cruz | b1b010d | 2013-10-28 19:49:59 -0200 | [diff] [blame] | 58 | git commits. |
Joshua Hesketh | 6c21dd1 | 2014-03-31 12:23:21 +1100 | [diff] [blame] | 59 | **BASE_LOG_PATH** |
| 60 | zuul suggests a path to store and address logs. This is deterministic |
| 61 | and hence useful for where you want workers to upload to a specific |
| 62 | destination or need them to have a specific final URL you can link to |
| 63 | in advanced. For changes it is: |
| 64 | "last-two-digits-of-change/change-number/patchset-number". |
| 65 | For reference updates it is: "first-two-digits-of-newrev/newrev" |
| 66 | **LOG_PATH** |
| 67 | zuul also suggests a unique path for logs to the worker. This is |
| 68 | "BASE_LOG_PATH/pipeline-name/job-name/uuid" |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 69 | |
Antoine Musso | e0f5bb4 | 2014-03-04 11:30:37 +0100 | [diff] [blame] | 70 | Change related parameters |
| 71 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 72 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 73 | The following additional parameters will only be provided for builds |
| 74 | associated with changes (i.e., in response to patchset-created or |
| 75 | comment-added events): |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 76 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 77 | **ZUUL_BRANCH** |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 78 | The target branch for the change that triggered this build. |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 79 | **ZUUL_CHANGE** |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 80 | The Gerrit change ID for the change that triggered this build. |
Julia Kreger | 012c1c5 | 2015-04-21 20:11:39 -0400 | [diff] [blame] | 81 | **ZUUL_CHANGES** |
| 82 | A caret character separated list of the changes upon which this build |
| 83 | is dependent upon in the form of a colon character separated list |
| 84 | consisting of project name, target branch, and revision ref. |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 85 | **ZUUL_CHANGE_IDS** |
| 86 | All of the Gerrit change IDs that are included in this build (useful |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 87 | when the DependentPipelineManager combines changes for testing). |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 88 | **ZUUL_PATCHSET** |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 89 | The Gerrit patchset number for the change that triggered this build. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 90 | |
Antoine Musso | e0f5bb4 | 2014-03-04 11:30:37 +0100 | [diff] [blame] | 91 | Reference updated parameters |
| 92 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 93 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 94 | The following additional parameters will only be provided for |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 95 | post-merge (ref-updated) builds: |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 96 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 97 | **ZUUL_OLDREV** |
| 98 | The SHA1 of the old revision at this ref (recall the ref name is |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 99 | in ZUUL_REF). |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 100 | **ZUUL_NEWREV** |
| 101 | The SHA1 of the new revision at this ref (recall the ref name is |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 102 | in ZUUL_REF). |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 103 | **ZUUL_SHORT_OLDREV** |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 104 | The shortened (7 character) SHA1 of the old revision. |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 105 | **ZUUL_SHORT_NEWREV** |
Łukasz Jernaś | 048acb4 | 2014-03-02 18:49:41 +0100 | [diff] [blame] | 106 | The shortened (7 character) SHA1 of the new revision. |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 107 | |
Antoine Musso | e0f5bb4 | 2014-03-04 11:30:37 +0100 | [diff] [blame] | 108 | Unset revisions default to 00000000000000000000000000000000. |
| 109 | |
| 110 | Examples: |
| 111 | |
| 112 | When a reference is created:: |
| 113 | |
| 114 | ZUUL_OLDREV=00000000000000000000000000000000 |
| 115 | ZUUL_NEWREV=123456789abcdef123456789abcdef12 |
| 116 | ZUUL_SHORT_OLDREV=0000000 |
| 117 | ZUUL_SHORT_NEWREV=1234567 |
| 118 | |
| 119 | When a reference is deleted:: |
| 120 | |
| 121 | ZUUL_OLDREV=123456789abcdef123456789abcdef12 |
| 122 | ZUUL_NEWREV=00000000000000000000000000000000 |
| 123 | ZUUL_SHORT_OLDREV=1234567 |
| 124 | ZUUL_SHORT_NEWREV=0000000 |
| 125 | |
| 126 | And finally a reference being altered:: |
| 127 | |
| 128 | ZUUL_OLDREV=123456789abcdef123456789abcdef12 |
| 129 | ZUUL_NEWREV=abcdef123456789abcdef123456789ab |
| 130 | ZUUL_SHORT_OLDREV=1234567 |
| 131 | ZUUL_SHORT_NEWREV=abcdef1 |
| 132 | |
| 133 | Your jobs can check whether the parameters are ``000000`` to act |
| 134 | differently on each kind of event. |
| 135 | |
Joshua Hesketh | 36c3fa5 | 2014-01-22 11:40:52 +1100 | [diff] [blame] | 136 | Swift parameters |
| 137 | ~~~~~~~~~~~~~~~~ |
| 138 | |
| 139 | If swift information has been configured for the job zuul will also |
| 140 | provide signed credentials for the builder to upload results and |
| 141 | assets into containers using the `FormPost`_ middleware. |
| 142 | |
| 143 | Each zuul container/instruction set will contain each of the following |
| 144 | parameters where $NAME is the ``name`` defined in the layout. |
| 145 | |
| 146 | *SWIFT_$NAME_URL* |
| 147 | The swift destination URL. This will be the entire URL including |
| 148 | the AUTH, container and path prefix (folder). |
| 149 | *SWIFT_$NAME_HMAC_BODY* |
| 150 | The information signed in the HMAC body. The body is as follows:: |
| 151 | |
| 152 | PATH TO OBJECT PREFIX (excluding domain) |
| 153 | BLANK LINE (zuul implements no form redirect) |
| 154 | MAX FILE SIZE |
| 155 | MAX FILE COUNT |
| 156 | SIGNATURE EXPIRY |
| 157 | |
| 158 | *SWIFT_$NAME_SIGNATURE* |
| 159 | The HMAC body signed with the configured key. |
| 160 | *SWIFT_$NAME_LOGSERVER_PREFIX* |
| 161 | The URL to prepend to the object path when returning the results |
| 162 | from a build. |
| 163 | |
Joshua Hesketh | e898716 | 2014-03-13 13:05:33 +1100 | [diff] [blame] | 164 | Gearman |
| 165 | ------- |
| 166 | |
| 167 | Gearman_ is a general-purpose protocol for distributing jobs to any |
| 168 | number of workers. Zuul works with Gearman by sending specific |
| 169 | information with job requests to Gearman, and expects certain |
| 170 | information to be returned on completion. This protocol is described |
| 171 | in `Zuul-Gearman Protocol`_. |
| 172 | |
| 173 | In order for Zuul to run any jobs, you will need a running Gearman |
| 174 | server. Zuul includes a Gearman server, and it is recommended that it |
| 175 | be used as it supports the following features needed by Zuul: |
| 176 | |
| 177 | * Canceling jobs in the queue (admin protocol command "cancel job"). |
| 178 | * Strict FIFO queue operation (gearmand's round-robin mode may be |
| 179 | sufficient, but is untested). |
| 180 | |
| 181 | To enable the built-in server, see the ``gearman_server`` section of |
| 182 | ``zuul.conf``. Be sure that the host allows connections from Zuul and |
| 183 | any workers (e.g., Jenkins masters) on TCP port 4730, and nowhere else |
| 184 | (as the Gearman protocol does not include any provision for |
| 185 | authentication). |
| 186 | |
| 187 | Gearman Jenkins Plugin |
| 188 | ~~~~~~~~~~~~~~~~~~~~~~ |
| 189 | |
| 190 | The `Gearman Jenkins Plugin`_ makes it easy to use Jenkins with Zuul |
| 191 | by providing an interface between Jenkins and Gearman. In this |
| 192 | configuration, Zuul asks Gearman to run jobs, and Gearman can then |
| 193 | distribute those jobs to any number of Jenkins systems (including |
| 194 | multiple Jenkins masters). |
| 195 | |
| 196 | The `Gearman Plugin`_ can be installed in Jenkins in order to |
| 197 | facilitate Jenkins running jobs for Zuul. Install the plugin and |
| 198 | configure it with the hostname or IP address of your Gearman server |
| 199 | and the port on which it is listening (4730 by default). It will |
| 200 | automatically register all known Jenkins jobs as functions that Zuul |
| 201 | can invoke via Gearman. |
| 202 | |
| 203 | Any number of masters can be configured in this way, and Gearman will |
| 204 | distribute jobs to all of them as appropriate. |
| 205 | |
| 206 | No special Jenkins job configuration is needed to support triggering |
| 207 | by Zuul. |
| 208 | |
| 209 | The Gearman Plugin will ensure the `Zuul Parameters`_ are supplied as |
| 210 | Jenkins build parameters, so they will be available for use in the job |
| 211 | configuration as well as to the running job as environment variables. |
| 212 | |
Antoine Musso | e0f5bb4 | 2014-03-04 11:30:37 +0100 | [diff] [blame] | 213 | Jenkins git plugin configuration |
Joshua Hesketh | e898716 | 2014-03-13 13:05:33 +1100 | [diff] [blame] | 214 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Antoine Musso | e0f5bb4 | 2014-03-04 11:30:37 +0100 | [diff] [blame] | 215 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 216 | In order to test the correct build, configure the Jenkins Git SCM |
| 217 | plugin as follows:: |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 218 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 219 | Source Code Management: |
| 220 | Git |
| 221 | Repositories: |
| 222 | Repository URL: <your Gerrit or Zuul repository URL> |
| 223 | Advanced: |
| 224 | Refspec: ${ZUUL_REF} |
| 225 | Branches to build: |
| 226 | Branch Specifier: ${ZUUL_COMMIT} |
James E. Blair | e281901 | 2013-06-28 17:17:26 -0400 | [diff] [blame] | 227 | Advanced: |
| 228 | Clean after checkout: True |
James E. Blair | cdd0007 | 2012-06-08 19:17:28 -0700 | [diff] [blame] | 229 | |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 230 | That should be sufficient for a job that only builds a single project. |
| 231 | If you have multiple interrelated projects (i.e., they share a Zuul |
| 232 | Change Queue) that are built together, you may be able to configure |
| 233 | the Git plugin to prepare them, or you may chose to use a shell script |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 234 | instead. As an example, the OpenStack project uses the following |
| 235 | script to prepare the workspace for its integration testing: |
James E. Blair | 81515ad | 2012-10-01 18:29:08 -0700 | [diff] [blame] | 236 | |
K Jonathan Harker | 97e457e | 2013-02-26 13:29:38 -0800 | [diff] [blame] | 237 | https://github.com/openstack-infra/devstack-gate/blob/master/devstack-vm-gate-wrap.sh |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 238 | |
Joshua Hesketh | 6a0a618 | 2014-03-13 13:23:30 +1100 | [diff] [blame] | 239 | Turbo Hipster Worker |
| 240 | ~~~~~~~~~~~~~~~~~~~~ |
| 241 | |
| 242 | As an alternative to Jenkins, `Turbo-Hipster`_ is a small python |
| 243 | project designed specifically as a zuul job worker which can be |
| 244 | registered with gearman as a job runner. Please see the |
| 245 | `Turbo-Hipster Documentation`_ for details on how to set it up. |
| 246 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 247 | Zuul-Gearman Protocol |
Joshua Hesketh | e898716 | 2014-03-13 13:05:33 +1100 | [diff] [blame] | 248 | ~~~~~~~~~~~~~~~~~~~~~ |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 249 | |
| 250 | This section is only relevant if you intend to implement a new kind of |
| 251 | worker that runs jobs for Zuul via Gearman. If you just want to use |
| 252 | Jenkins, see `Gearman Jenkins Plugin`_ instead. |
| 253 | |
| 254 | The Zuul protocol as used with Gearman is as follows: |
| 255 | |
| 256 | Starting Builds |
Joshua Hesketh | e898716 | 2014-03-13 13:05:33 +1100 | [diff] [blame] | 257 | ^^^^^^^^^^^^^^^ |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 258 | |
| 259 | To start a build, Zuul invokes a Gearman function with the following |
| 260 | format: |
| 261 | |
| 262 | build:FUNCTION_NAME |
| 263 | |
| 264 | where **FUNCTION_NAME** is the name of the job that should be run. If |
| 265 | the job should run on a specific node (or class of node), Zuul will |
| 266 | instead invoke: |
| 267 | |
| 268 | build:FUNCTION_NAME:NODE_NAME |
| 269 | |
| 270 | where **NODE_NAME** is the name or class of node on which the job |
| 271 | should be run. This can be specified by setting the ZUUL_NODE |
Antoine Musso | 7c5db97 | 2013-09-26 11:48:26 +0200 | [diff] [blame] | 272 | parameter in a parameter-function (see :ref:`includes` section in |
| 273 | :ref:`zuulconf`). |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 274 | |
| 275 | Zuul sends the ZUUL_* parameters described in `Zuul Parameters`_ |
| 276 | encoded in JSON format as the argument included with the |
| 277 | SUBMIT_JOB_UNIQ request to Gearman. A unique ID (equal to the |
| 278 | ZUUL_UUID parameter) is also supplied to Gearman, and is accessible as |
| 279 | an added Gearman parameter with GRAB_JOB_UNIQ. |
| 280 | |
| 281 | When a Gearman worker starts running a job for Zuul, it should |
| 282 | immediately send a WORK_DATA packet with the following information |
| 283 | encoded in JSON format: |
| 284 | |
James E. Blair | 3c483cf | 2013-06-04 16:30:43 -0700 | [diff] [blame] | 285 | **name** |
| 286 | The name of the job. |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 287 | |
| 288 | **number** |
| 289 | The build number (unique to this job). |
| 290 | |
James E. Blair | 3c483cf | 2013-06-04 16:30:43 -0700 | [diff] [blame] | 291 | **manager** |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 292 | A unique identifier associated with the Gearman worker that can |
| 293 | abort this build. See `Stopping Builds`_ for more information. |
| 294 | |
James E. Blair | 3c483cf | 2013-06-04 16:30:43 -0700 | [diff] [blame] | 295 | **url** (optional) |
| 296 | The URL with the status or results of the build. Will be used in |
| 297 | the status page and the final report. |
| 298 | |
Joshua Hesketh | ba8776a | 2014-01-12 14:35:40 +0800 | [diff] [blame] | 299 | To help with debugging builds a worker may send back some optional |
| 300 | metadata: |
| 301 | |
| 302 | **worker_name** (optional) |
| 303 | The name of the worker. |
| 304 | |
| 305 | **worker_hostname** (optional) |
| 306 | The hostname of the worker. |
| 307 | |
| 308 | **worker_ips** (optional) |
| 309 | A list of IPs for the worker. |
| 310 | |
| 311 | **worker_fqdn** (optional) |
| 312 | The FQDN of the worker. |
| 313 | |
| 314 | **worker_program** (optional) |
| 315 | The program name of the worker. For example Jenkins or turbo-hipster. |
| 316 | |
| 317 | **worker_version** (optional) |
| 318 | The version of the software running the job. |
| 319 | |
| 320 | **worker_extra** (optional) |
| 321 | A dictionary of any extra metadata you may want to pass along. |
| 322 | |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 323 | It should then immediately send a WORK_STATUS packet with a value of 0 |
| 324 | percent complete. It may then optionally send subsequent WORK_STATUS |
| 325 | packets with updated completion values. |
| 326 | |
| 327 | When the build is complete, it should send a final WORK_DATA packet |
| 328 | with the following in JSON format: |
| 329 | |
| 330 | **result** |
| 331 | Either the string 'SUCCESS' if the job succeeded, or any other value |
| 332 | that describes the result if the job failed. |
| 333 | |
| 334 | Finally, it should send either a WORK_FAIL or WORK_COMPLETE packet as |
| 335 | appropriate. A WORK_EXCEPTION packet will be interpreted as a |
| 336 | WORK_FAIL, but the exception will be logged in Zuul's error log. |
| 337 | |
| 338 | Stopping Builds |
Joshua Hesketh | e898716 | 2014-03-13 13:05:33 +1100 | [diff] [blame] | 339 | ^^^^^^^^^^^^^^^ |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 340 | |
| 341 | If Zuul needs to abort a build already in progress, it will invoke the |
| 342 | following function through Gearman: |
| 343 | |
James E. Blair | 3c483cf | 2013-06-04 16:30:43 -0700 | [diff] [blame] | 344 | stop:MANAGER_NAME |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 345 | |
James E. Blair | 3c483cf | 2013-06-04 16:30:43 -0700 | [diff] [blame] | 346 | Where **MANAGER_NAME** is the name of the manager worker supplied in |
| 347 | the initial WORK_DATA packet when the job started. This is used to |
| 348 | direct the stop: function invocation to the correct Gearman worker |
| 349 | that is capable of stopping that particular job. The argument to the |
| 350 | function should be the following encoded in JSON format: |
| 351 | |
| 352 | **name** |
| 353 | The job name of the build to stop. |
| 354 | |
| 355 | **number** |
| 356 | The build number of the build to stop. |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 357 | |
| 358 | The original job is expected to complete with a WORK_DATA and |
| 359 | WORK_FAIL packet as described in `Starting Builds`_. |
| 360 | |
| 361 | Build Descriptions |
Joshua Hesketh | e898716 | 2014-03-13 13:05:33 +1100 | [diff] [blame] | 362 | ^^^^^^^^^^^^^^^^^^ |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 363 | |
| 364 | In order to update the job running system with a description of the |
| 365 | current state of all related builds, the job runner may optionally |
| 366 | implement the following Gearman function: |
| 367 | |
James E. Blair | 3c483cf | 2013-06-04 16:30:43 -0700 | [diff] [blame] | 368 | set_description:MANAGER_NAME |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 369 | |
James E. Blair | 3c483cf | 2013-06-04 16:30:43 -0700 | [diff] [blame] | 370 | Where **MANAGER_NAME** is used as described in `Stopping Builds`_. |
| 371 | The argument to the function is the following encoded in JSON format: |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 372 | |
James E. Blair | 3c483cf | 2013-06-04 16:30:43 -0700 | [diff] [blame] | 373 | **name** |
| 374 | The job name of the build to describe. |
| 375 | |
| 376 | **number** |
| 377 | The build number of the build to describe. |
James E. Blair | 1f4c2bb | 2013-04-26 08:40:46 -0700 | [diff] [blame] | 378 | |
| 379 | **html_description** |
| 380 | The description of the build in HTML format. |