James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 1 | :title: Job Content |
| 2 | |
| 3 | Job Content |
| 4 | =========== |
| 5 | |
David Shrewsbury | c50cb57 | 2017-08-04 11:55:01 -0400 | [diff] [blame] | 6 | Zuul jobs are implemented as Ansible playbooks. Zuul prepares the |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 7 | repositories used for a job, installs any required Ansible roles, and |
| 8 | then executes the job's playbooks. Any setup or artifact collection |
| 9 | required is the responsibility of the job itself. While this flexible |
| 10 | arrangement allows for almost any kind of job to be run by Zuul, |
| 11 | batteries are included. Zuul has a standard library of jobs upon |
| 12 | which to build. |
| 13 | |
| 14 | Working Directory |
| 15 | ----------------- |
| 16 | |
| 17 | Before starting each job, the Zuul executor creates a directory to |
| 18 | hold all of the content related to the job. This includes some |
| 19 | directories which are used by Zuul to configure and run Ansible and |
| 20 | may not be accessible, as well as a directory tree, under ``work/``, |
| 21 | that is readable and writable by the job. The hierarchy is: |
| 22 | |
| 23 | **work/** |
| 24 | The working directory of the job. |
| 25 | |
| 26 | **work/src/** |
| 27 | Contains the prepared git repositories for the job. |
| 28 | |
| 29 | **work/logs/** |
| 30 | Where the Ansible log for the job is written; your job |
| 31 | may place other logs here as well. |
| 32 | |
| 33 | Git Repositories |
| 34 | ---------------- |
| 35 | |
| 36 | The git repositories in ``work/src`` contain the repositories for all |
| 37 | of the projects specified in the ``required-projects`` section of the |
| 38 | job, plus the project associated with the queue item if it isn't |
| 39 | already in that list. In the case of a proposed change, that change |
| 40 | and all of the changes ahead of it in the pipeline queue will already |
| 41 | be merged into their respective repositories and target branches. The |
| 42 | change's project will have the change's branch checked out, as will |
| 43 | all of the other projects, if that branch exists (otherwise, a |
| 44 | fallback or default branch will be used). If your job needs to |
| 45 | operate on multiple branches, simply checkout the appropriate branches |
| 46 | of these git repos to ensure that the job results reflect the proposed |
| 47 | future state that Zuul is testing, and all dependencies are present. |
| 48 | Do not use any git remotes; the local repositories are guaranteed to |
| 49 | be up to date. |
| 50 | |
James E. Blair | 4d5dd25 | 2017-06-23 21:40:56 +0100 | [diff] [blame] | 51 | The repositories will be placed on the filesystem in directories |
| 52 | corresponding with the canonical hostname of their source connection. |
| 53 | For example:: |
| 54 | |
| 55 | work/src/git.example.com/project1 |
| 56 | work/src/github.com/project2 |
| 57 | |
| 58 | Is the layout that would be present for a job which included project1 |
| 59 | from the connection associated to git.example.com and project2 from |
| 60 | GitHub. This helps avoid collisions between projects with the same |
| 61 | name, and some language environments, such as Go, expect repositories |
| 62 | in this format. |
| 63 | |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 64 | Note that these git repositories are located on the executor; in order |
| 65 | to be useful to most kinds of jobs, they will need to be present on |
| 66 | the test nodes. The ``base`` job in the standard library contains a |
| 67 | pre-playbook which copies the repositories to all of the job's nodes. |
| 68 | It is recommended to always inherit from this base job to ensure that |
| 69 | behavior. |
| 70 | |
| 71 | .. TODO: link to base job documentation and/or document src (and logs?) directory |
| 72 | |
James E. Blair | 28c8e3b | 2017-07-17 16:27:50 -0700 | [diff] [blame] | 73 | Variables |
| 74 | --------- |
| 75 | |
Jamie Lennox | 7655b55 | 2017-03-17 12:33:38 +1100 | [diff] [blame] | 76 | There are several sources of variables which are available to Ansible: |
| 77 | variables defined in jobs, secrets, and site-wide variables. The |
| 78 | order of precedence is: |
| 79 | |
| 80 | * Site-wide variables |
| 81 | |
| 82 | * Secrets |
| 83 | |
| 84 | * Job variables |
| 85 | |
| 86 | Meaning that a site-wide variable with the same name as any other will |
| 87 | override its value, and similarly, secrets override job variables of |
| 88 | the same name. Each of the three sources is described below. |
| 89 | |
| 90 | |
| 91 | Job Variables |
| 92 | ~~~~~~~~~~~~~ |
| 93 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 94 | Any variables specified in the job definition (using the |
| 95 | :attr:`job.vars` attribute) are available as Ansible host variables. |
| 96 | They are added to the ``vars`` section of the inventory file under the |
| 97 | ``all`` hosts group, so they are available to all hosts. Simply refer |
| 98 | to them by the name specified in the job's ``vars`` section. |
James E. Blair | 28c8e3b | 2017-07-17 16:27:50 -0700 | [diff] [blame] | 99 | |
| 100 | Secrets |
| 101 | ~~~~~~~ |
| 102 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 103 | :ref:`Secrets <secret>` also appear as variables available to Ansible. |
| 104 | Unlike job variables, these are not added to the inventory file (so |
| 105 | that the inventory file may be kept for debugging purposes without |
| 106 | revealing secrets). But they are still available to Ansible as normal |
James E. Blair | 28c8e3b | 2017-07-17 16:27:50 -0700 | [diff] [blame] | 107 | variables. Because secrets are groups of variables, they will appear |
| 108 | as a dictionary structure in templates, with the dictionary itself |
| 109 | being the name of the secret, and its members the individual items in |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 110 | the secret. For example, a secret defined as: |
| 111 | |
| 112 | .. code-block:: yaml |
James E. Blair | 28c8e3b | 2017-07-17 16:27:50 -0700 | [diff] [blame] | 113 | |
| 114 | - secret: |
| 115 | name: credentials |
| 116 | data: |
| 117 | username: foo |
| 118 | password: bar |
| 119 | |
| 120 | Might be used in a template as:: |
| 121 | |
| 122 | {{ credentials.username }} {{ credentials.password }} |
| 123 | |
James E. Blair | 892cca6 | 2017-08-09 11:36:58 -0700 | [diff] [blame] | 124 | Secrets are only available to playbooks associated with the job |
| 125 | definition which uses the secret; they are not available to playbooks |
| 126 | associated with child jobs or job variants. |
James E. Blair | 28c8e3b | 2017-07-17 16:27:50 -0700 | [diff] [blame] | 127 | |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 128 | Zuul Variables |
James E. Blair | 28c8e3b | 2017-07-17 16:27:50 -0700 | [diff] [blame] | 129 | ~~~~~~~~~~~~~~ |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 130 | |
| 131 | Zuul supplies not only the variables specified by the job definition |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 132 | to Ansible, but also some variables from Zuul itself. |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 133 | |
James E. Blair | babefce | 2017-07-20 17:14:54 -0700 | [diff] [blame] | 134 | When a pipeline is triggered by an action, it enqueues items which may |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 135 | vary based on the pipeline's configuration. For example, when a new |
| 136 | change is created, that change may be enqueued into the pipeline, |
| 137 | while a tag may be enqueued into the pipeline when it is pushed. |
| 138 | |
| 139 | Information about these items is available to jobs. All of the items |
| 140 | enqueued in a pipeline are git references, and therefore share some |
| 141 | attributes in common. But other attributes may vary based on the type |
| 142 | of item. |
| 143 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 144 | .. var:: zuul |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 145 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 146 | All items provide the following information as Ansible variables |
| 147 | under the ``zuul`` key: |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 148 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 149 | .. var:: build |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 150 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 151 | The UUID of the build. A build is a single execution of a job. |
| 152 | When an item is enqueued into a pipeline, this usually results |
| 153 | in one build of each job configured for that item's project. |
| 154 | However, items may be re-enqueued in which case another build |
| 155 | may run. In dependent pipelines, the same job may run multiple |
| 156 | times for the same item as circumstances change ahead in the |
| 157 | queue. Each time a job is run, for whatever reason, it is |
| 158 | acompanied with a new unique id. |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 159 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 160 | .. var:: buildset |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 161 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 162 | The build set UUID. When Zuul runs jobs for an item, the |
| 163 | collection of those jobs is known as a buildset. If the |
| 164 | configuration of items ahead in a dependent pipeline changes, |
| 165 | Zuul creates a new buildset and restarts all of the jobs. |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 166 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 167 | .. var:: ref |
James E. Blair | 2ef29e9 | 2017-07-21 15:25:05 -0700 | [diff] [blame] | 168 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 169 | The git ref of the item. This will be the full path (e.g., |
| 170 | `refs/heads/master` or `refs/changes/...`). |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 171 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 172 | .. var:: pipeline |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 173 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 174 | The name of the pipeline in which the job is being run. |
Monty Taylor | 299f94b | 2017-07-28 17:16:36 -0500 | [diff] [blame] | 175 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 176 | .. var:: job |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 177 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 178 | The name of the job being run. |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 179 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 180 | .. var:: voting |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 181 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 182 | A boolean indicating whether the job is voting. |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 183 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 184 | .. var:: project |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 185 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 186 | The item's project. This is a data structure with the following |
| 187 | fields: |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 188 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 189 | .. var:: name |
Monty Taylor | 299f94b | 2017-07-28 17:16:36 -0500 | [diff] [blame] | 190 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 191 | The name of the project, excluding hostname. E.g., `org/project`. |
Monty Taylor | 299f94b | 2017-07-28 17:16:36 -0500 | [diff] [blame] | 192 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 193 | .. var:: short_name |
Monty Taylor | 299f94b | 2017-07-28 17:16:36 -0500 | [diff] [blame] | 194 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 195 | The name of the project, excluding directories or |
| 196 | organizations. E.g., `project`. |
Monty Taylor | 299f94b | 2017-07-28 17:16:36 -0500 | [diff] [blame] | 197 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 198 | .. var:: canonical_hostname |
Monty Taylor | 299f94b | 2017-07-28 17:16:36 -0500 | [diff] [blame] | 199 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 200 | The canonical hostname where the project lives. E.g., |
| 201 | `git.example.com`. |
Monty Taylor | 299f94b | 2017-07-28 17:16:36 -0500 | [diff] [blame] | 202 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 203 | .. var:: canonical_name |
| 204 | |
| 205 | The full canonical name of the project including hostname. |
| 206 | E.g., `git.example.com/org/project`. |
| 207 | |
Monty Taylor | 9e67bb7 | 2017-08-08 15:32:06 -0500 | [diff] [blame] | 208 | .. var:: src_dir |
| 209 | |
James E. Blair | ba46c06 | 2017-08-28 16:23:24 -0700 | [diff] [blame] | 210 | The path to the source code relative to the work dir. E.g., |
| 211 | `src/git.example.com/org/project`. |
Monty Taylor | 9e67bb7 | 2017-08-08 15:32:06 -0500 | [diff] [blame] | 212 | |
James E. Blair | ba46c06 | 2017-08-28 16:23:24 -0700 | [diff] [blame] | 213 | .. var:: projects |
| 214 | :type: list |
| 215 | |
| 216 | A list of all projects prepared by Zuul for the item. It |
| 217 | includes, at least, the item's own project. It also includes |
| 218 | the projects of any items this item depends on, as well as the |
| 219 | projects that appear in :attr:`job.required-projects`. |
| 220 | |
| 221 | This is a list of dictionaries, with each element consisting of: |
| 222 | |
| 223 | .. var:: name |
| 224 | |
| 225 | The name of the project, excluding hostname. E.g., `org/project`. |
| 226 | |
| 227 | .. var:: short_name |
| 228 | |
| 229 | The name of the project, excluding directories or |
| 230 | organizations. E.g., `project`. |
| 231 | |
| 232 | .. var:: canonical_hostname |
| 233 | |
| 234 | The canonical hostname where the project lives. E.g., |
| 235 | `git.example.com`. |
| 236 | |
| 237 | .. var:: canonical_name |
| 238 | |
| 239 | The full canonical name of the project including hostname. |
| 240 | E.g., `git.example.com/org/project`. |
| 241 | |
| 242 | .. var:: src_dir |
| 243 | |
| 244 | The path to the source code, relative to the work dir. E.g., |
| 245 | `src/git.example.com/org/project`. |
Monty Taylor | 9e67bb7 | 2017-08-08 15:32:06 -0500 | [diff] [blame] | 246 | |
James E. Blair | b3d3f2b | 2017-09-27 12:04:55 -0700 | [diff] [blame] | 247 | .. var:: required |
| 248 | |
| 249 | A boolean indicating whether this project appears in the |
| 250 | :attr:`job.required-projects` list for this job. |
| 251 | |
Ian Wienand | d61d98e | 2017-10-18 08:21:19 +1100 | [diff] [blame] | 252 | .. var:: _projects |
| 253 | :type: dict |
| 254 | |
| 255 | The same as ``projects`` but a dictionary indexed by the |
| 256 | ``name`` value of each entry. ``projects`` will be converted to |
| 257 | this. |
| 258 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 259 | .. var:: tenant |
| 260 | |
| 261 | The name of the current Zuul tenant. |
| 262 | |
James E. Blair | 93e57f7 | 2017-09-01 08:51:49 -0700 | [diff] [blame] | 263 | .. var:: timeout |
| 264 | |
| 265 | The job timeout, in seconds. |
| 266 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 267 | .. var:: jobtags |
| 268 | |
| 269 | A list of tags associated with the job. Not to be confused with |
| 270 | git tags, these are simply free-form text fields that can be |
| 271 | used by the job for reporting or classification purposes. |
| 272 | |
| 273 | .. var:: items |
| 274 | :type: list |
| 275 | |
| 276 | A list of dictionaries, each representing an item being tested |
| 277 | with this change with the format: |
| 278 | |
| 279 | .. var:: project |
| 280 | |
| 281 | The item's project. This is a data structure with the |
| 282 | following fields: |
| 283 | |
| 284 | .. var:: name |
| 285 | |
| 286 | The name of the project, excluding hostname. E.g., |
| 287 | `org/project`. |
| 288 | |
| 289 | .. var:: short_name |
| 290 | |
| 291 | The name of the project, excluding directories or |
| 292 | organizations. E.g., `project`. |
| 293 | |
| 294 | .. var:: canonical_hostname |
| 295 | |
| 296 | The canonical hostname where the project lives. E.g., |
| 297 | `git.example.com`. |
| 298 | |
| 299 | .. var:: canonical_name |
| 300 | |
| 301 | The full canonical name of the project including hostname. |
| 302 | E.g., `git.example.com/org/project`. |
| 303 | |
Monty Taylor | 9e67bb7 | 2017-08-08 15:32:06 -0500 | [diff] [blame] | 304 | .. var:: src_dir |
| 305 | |
| 306 | The path to the source code on the remote host, relative |
| 307 | to the home dir of the remote user. |
| 308 | E.g., `src/git.example.com/org/project`. |
| 309 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 310 | .. var:: branch |
| 311 | |
| 312 | The target branch of the change (without the `refs/heads/` prefix). |
| 313 | |
| 314 | .. var:: change |
| 315 | |
| 316 | The identifier for the change. |
| 317 | |
Monty Taylor | 4163444 | 2017-09-06 18:35:17 -0500 | [diff] [blame] | 318 | .. var:: change_url |
| 319 | |
| 320 | The URL to the source location of the given change. |
| 321 | E.g., `https://review.example.org/#/c/123456/` or |
| 322 | `https://github.com/example/example/pull/1234`. |
| 323 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 324 | .. var:: patchset |
| 325 | |
| 326 | The patchset identifier for the change. If a change is |
| 327 | revised, this will have a different value. |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 328 | |
Jesse Keating | a49ddaf | 2017-09-11 18:17:47 -0600 | [diff] [blame] | 329 | .. var:: zuul_success |
| 330 | |
| 331 | Post run playbook(s) will be passed this variable to indicate if the run |
| 332 | phase of the job was successful or not. This variable is meant to be used |
| 333 | with the `boolean` filter. |
| 334 | |
| 335 | |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 336 | Change Items |
| 337 | ++++++++++++ |
| 338 | |
| 339 | A change to the repository. Most often, this will be a git reference |
| 340 | which has not yet been merged into the repository (e.g., a gerrit |
| 341 | change or a GitHub pull request). The following additional variables |
| 342 | are available: |
| 343 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 344 | .. var:: zuul |
| 345 | :hidden: |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 346 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 347 | .. var:: branch |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 348 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 349 | The target branch of the change (without the `refs/heads/` prefix). |
| 350 | |
| 351 | .. var:: change |
| 352 | |
| 353 | The identifier for the change. |
| 354 | |
| 355 | .. var:: patchset |
| 356 | |
| 357 | The patchset identifier for the change. If a change is revised, |
| 358 | this will have a different value. |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 359 | |
Monty Taylor | 4163444 | 2017-09-06 18:35:17 -0500 | [diff] [blame] | 360 | .. var:: change_url |
| 361 | |
| 362 | The URL to the source location of the given change. |
| 363 | E.g., `https://review.example.org/#/c/123456/` or |
| 364 | `https://github.com/example/example/pull/1234`. |
| 365 | |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 366 | Branch Items |
| 367 | ++++++++++++ |
| 368 | |
| 369 | This represents a branch tip. This item may have been enqueued |
| 370 | because the branch was updated (via a change having merged, or a |
| 371 | direct push). Or it may have been enqueued by a timer for the purpose |
| 372 | of verifying the current condition of the branch. The following |
| 373 | additional variables are available: |
| 374 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 375 | .. var:: zuul |
| 376 | :hidden: |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 377 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 378 | .. var:: branch |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 379 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 380 | The name of the item's branch (without the `refs/heads/` |
| 381 | prefix). |
| 382 | |
| 383 | .. var:: oldrev |
| 384 | |
| 385 | If the item was enqueued as the result of a change merging or |
| 386 | being pushed to the branch, the git sha of the old revision will |
| 387 | be included here. Otherwise, this variable will be undefined. |
| 388 | |
| 389 | .. var:: newrev |
| 390 | |
| 391 | If the item was enqueued as the result of a change merging or |
| 392 | being pushed to the branch, the git sha of the new revision will |
| 393 | be included here. Otherwise, this variable will be undefined. |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 394 | |
| 395 | Tag Items |
| 396 | +++++++++ |
| 397 | |
| 398 | This represents a git tag. The item may have been enqueued because a |
| 399 | tag was created or deleted. The following additional variables are |
| 400 | available: |
| 401 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 402 | .. var:: zuul |
| 403 | :hidden: |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 404 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 405 | .. var:: tag |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 406 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 407 | The name of the item's tag (without the `refs/tags/` prefix). |
| 408 | |
| 409 | .. var:: oldrev |
| 410 | |
| 411 | If the item was enqueued as the result of a tag being deleted, |
| 412 | the previous git sha of the tag will be included here. If the |
| 413 | tag was created, this variable will be undefined. |
| 414 | |
| 415 | .. var:: newrev |
| 416 | |
| 417 | If the item was enqueued as the result of a tag being created, |
| 418 | the new git sha of the tag will be included here. If the tag |
| 419 | was deleted, this variable will be undefined. |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 420 | |
| 421 | Ref Items |
| 422 | +++++++++ |
| 423 | |
| 424 | This represents a git reference that is neither a change, branch, or |
| 425 | tag. Note that all items include a `ref` attribute which may be used |
| 426 | to identify the ref. The following additional variables are |
| 427 | available: |
| 428 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 429 | .. var:: zuul |
| 430 | :hidden: |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 431 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 432 | .. var:: oldrev |
| 433 | |
| 434 | If the item was enqueued as the result of a ref being deleted, |
| 435 | the previous git sha of the ref will be included here. If the |
| 436 | ref was created, this variable will be undefined. |
| 437 | |
| 438 | .. var:: newrev |
| 439 | |
| 440 | If the item was enqueued as the result of a ref being created, |
| 441 | the new git sha of the ref will be included here. If the ref |
| 442 | was deleted, this variable will be undefined. |
James E. Blair | 2103778 | 2017-07-19 11:56:55 -0700 | [diff] [blame] | 443 | |
| 444 | Working Directory |
| 445 | +++++++++++++++++ |
| 446 | |
| 447 | Additionally, some information about the working directory and the |
| 448 | executor running the job is available: |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 449 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 450 | .. var:: zuul |
| 451 | :hidden: |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 452 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 453 | .. var:: executor |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 454 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 455 | A number of values related to the executor running the job are |
| 456 | available: |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 457 | |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 458 | .. var:: hostname |
| 459 | |
| 460 | The hostname of the executor. |
| 461 | |
| 462 | .. var:: src_root |
| 463 | |
| 464 | The path to the source directory. |
| 465 | |
| 466 | .. var:: log_root |
| 467 | |
| 468 | The path to the logs directory. |
| 469 | |
| 470 | .. var:: work_root |
| 471 | |
| 472 | The path to the working directory. |
Jamie Lennox | 7655b55 | 2017-03-17 12:33:38 +1100 | [diff] [blame] | 473 | |
| 474 | .. _user_sitewide_variables: |
| 475 | |
| 476 | Site-wide Variables |
| 477 | ~~~~~~~~~~~~~~~~~~~ |
| 478 | |
| 479 | The Zuul administrator may define variables which will be available to |
| 480 | all jobs running in the system. These are statically defined and may |
| 481 | not be altered by jobs. See the :ref:`Administrator's Guide |
| 482 | <admin_sitewide_variables>` for information on how a site |
| 483 | administrator may define these variables. |
| 484 | |
| 485 | |
James E. Blair | eff5a9d | 2017-06-20 00:00:37 -0700 | [diff] [blame] | 486 | SSH Keys |
| 487 | -------- |
| 488 | |
| 489 | Zuul starts each job with an SSH agent running and the key used to |
| 490 | access the job's nodes added to that agent. Generally you won't need |
| 491 | to be aware of this since Ansible will use this when performing any |
| 492 | tasks on remote nodes. However, under some circumstances you may want |
| 493 | to interact with the agent. For example, you may wish to add a key |
| 494 | provided as a secret to the job in order to access a specific host, or |
| 495 | you may want to, in a pre-playbook, replace the key used to log into |
| 496 | the assigned nodes in order to further protect it from being abused by |
| 497 | untrusted job content. |
| 498 | |
| 499 | .. TODO: describe standard lib and link to published docs for it. |
| 500 | |
James E. Blair | 88e79c0 | 2017-07-07 13:36:54 -0700 | [diff] [blame] | 501 | .. _return_values: |
| 502 | |
James E. Blair | 196f61a | 2017-06-30 15:42:29 -0700 | [diff] [blame] | 503 | Return Values |
| 504 | ------------- |
| 505 | |
| 506 | The job may return some values to Zuul to affect its behavior. To |
| 507 | return a value, use the *zuul_return* Ansible module in a job |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 508 | playbook. For example: |
| 509 | |
| 510 | .. code-block:: yaml |
James E. Blair | 196f61a | 2017-06-30 15:42:29 -0700 | [diff] [blame] | 511 | |
| 512 | tasks: |
| 513 | - zuul_return: |
| 514 | data: |
| 515 | foo: bar |
| 516 | |
| 517 | Will return the dictionary "{'foo': 'bar'}" to Zuul. |
| 518 | |
| 519 | .. TODO: xref to section describing formatting |
| 520 | |
| 521 | Several uses of these values are planned, but the only currently |
| 522 | implemented use is to set the log URL for a build. To do so, set the |
James E. Blair | d9f0efb | 2017-08-02 16:07:44 -0700 | [diff] [blame] | 523 | **zuul.log_url** value. For example: |
| 524 | |
| 525 | .. code-block:: yaml |
James E. Blair | 196f61a | 2017-06-30 15:42:29 -0700 | [diff] [blame] | 526 | |
| 527 | tasks: |
| 528 | - zuul_return: |
| 529 | data: |
| 530 | zuul: |
| 531 | log_url: http://logs.example.com/path/to/build/logs |