Merge "Update docs with new Ubuntu 16.04 images"
[releng/builder.git] / docs / jenkins.rst
1 Jenkins
2 =======
3
4 The `Release Engineering Project <releng-wiki_>`_ consolidates the Jenkins jobs from
5 project-specific VMs to a single Jenkins server. Each OpenDaylight project
6 has a tab for their jobs on the `jenkins-master`_. The system utilizes
7 `Jenkins Job Builder <jjb-docs_>`_ for the creation and management of the
8 Jenkins jobs.
9
10 Sections:
11
12 .. contents::
13    :depth: 3
14    :local:
15
16 New Project Quick Start
17 -----------------------
18
19 This section attempts to provide details on how to get going as a new project
20 quickly with minimal steps. The rest of the guide should be read and understood
21 by those who need to create and contribute new job types that is not already
22 covered by the existing job templates provided by OpenDaylight's JJB repo.
23
24 As a new project you will be mainly interested in getting your jobs to appear
25 in the jenkins-master_ silo and this can be achieved by simply creating a
26 <project>.yaml in the releng/builder project's jjb directory.
27
28 .. code-block:: bash
29
30     git clone https://git.opendaylight.org/gerrit/releng/builder
31     cd builder
32     mkdir jjb/<new-project>
33
34 Where <new-project> should be the same name as your project's git repo in
35 Gerrit. So if your project is called "aaa" then create a new jjb/aaa directory.
36
37 Next we will create <new-project>.yaml as follows:
38
39 .. code-block:: yaml
40
41     ---
42     - project:
43         name: <NEW_PROJECT>-carbon
44         jobs:
45           - '{project-name}-clm-{stream}'
46           - '{project-name}-integration-{stream}'
47           - '{project-name}-merge-{stream}'
48           - '{project-name}-verify-{stream}-{maven}-{jdks}'
49
50         project: '<NEW_PROJECT>'
51         project-name: '<NEW_PROJECT>'
52         stream: carbon
53         branch: 'master'
54         jdk: openjdk8
55         jdks:
56           - openjdk8
57         maven:
58           - mvn33:
59               mvn-version: 'mvn33'
60         mvn-settings: '<NEW_PROJECT>-settings'
61         mvn-goals: 'clean install -Dmaven.repo.local=/tmp/r -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r'
62         mvn-opts: '-Xmx1024m -XX:MaxPermSize=256m'
63         dependencies: 'odlparent-merge-{stream},yangtools-merge-{stream},controller-merge-{stream}'
64         email-upstream: '[<NEW_PROJECT>] [odlparent] [yangtools] [controller]'
65         archive-artifacts: ''
66
67     - project:
68         name: <NEW_PROJECT>-sonar
69         jobs:
70           - '{project-name}-sonar'
71
72         project: '<NEW_PROJECT>'
73         project-name: '<NEW_PROJECT>'
74         branch: 'master'
75         mvn-settings: '<NEW_PROJECT>-settings'
76         mvn-goals: 'clean install -Dmaven.repo.local=/tmp/r -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r'
77         mvn-opts: '-Xmx1024m -XX:MaxPermSize=256m'
78
79 Replace all instances of <new-project> with the name of your project. This will
80 create the jobs with the default job types we recommend for Java projects. If
81 your project is participating in the simultanious-release and ultimately will
82 be included in the final distribution, it is required to add the following job
83 types into the job list for the release you are participating.
84
85
86 .. code-block:: yaml
87
88     - '{project-name}-distribution-check-{stream}'
89     - '{project-name}-validate-autorelease-{stream}'
90
91 If you'd like to explore the additional tweaking options available
92 please refer to the `Jenkins Job Templates`_ section.
93
94 Finally we need to push these files to Gerrit for review by the releng/builder
95 team to push your jobs to Jenkins.
96
97 .. code-block:: bash
98
99     git add jjb/<new-project>
100     git commit -sm "Add <new-project> jobs to Jenkins"
101     git review
102
103 This will push the jobs to Gerrit and your jobs will appear in Jenkins once the
104 releng/builder team has reviewed and merged your patch.
105
106 Jenkins Master
107 --------------
108
109 The `jenkins-master`_ is the home for all project's Jenkins jobs. All
110 maintenance and configuration of these jobs must be done via JJB through the
111 `releng-builder-repo`_. Project contributors can no longer edit the Jenkins jobs
112 directly on the server.
113
114 Build Minions
115 -------------
116
117 The Jenkins jobs are run on build minions (executors) which are created on an
118 as-needed basis. If no idle build minions are available a new VM is brought
119 up. This process can take up to 2 minutes. Once the build minion has finished a
120 job, it will be destroyed.
121
122 Our Jenkins master supports many types of dynamic build minions. If you are
123 creating custom jobs then you will need to have an idea of what type of minions
124 are available. The following are the current minion types and descriptions.
125 Minion Template Names are needed for jobs that take advantage of multiple
126 minions as they must be specifically called out by template name instead of
127 label.
128
129 Adding New Components to the Minions
130 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131
132 If your project needs something added to one of the minions, you can help us
133 get things added faster by doing one of the following:
134
135 * Submit a patch to RelEng/Builder for the appropriate `jenkins-scripts`
136   definition which configure software during minion boot up.
137 * Submit a patch to RelEng/Builder for the `packer/provision` scripts that
138   configures software during minion instance imaging.
139 * Submit a patch to RelEng/Builder for the Packer's templates  in
140   the `packer/templates` directory that configures a new instance definition
141   along with changes in `packer/provision`.
142
143 Going the first route will be faster in the short term as we can inspect the
144 changes and make test modifications in the sandbox to verify that it works.
145
146 .. note::
147
148    The first route may add additional setup time considering this is run every
149    time the minion is booted.
150
151 The second and third routes, however, is better for the community as a whole as
152 it will allow others to utilize our Packer setups to replicate our systems more
153 closely. It is, however, more time consuming as an image snapshot needs to be
154 created based on the updated Packer definitions before it can be attached to the
155 Jenkins configuration on sandbox for validation testing.
156
157 In either case, the changes must be validated in the sandbox with tests to
158 make sure that we don't break current jobs and that the new software features
159 are operating as intended. Once this is done the changes will be merged and
160 the updates applied to the RelEng Jenkins production silo. Any changes to
161 files under `releng/builder/packer` will be validated and images would be built
162 triggered by verify-packer and merge-packer jobs.
163
164 Please note that the combination of a Packer definitions from `vars`, `templates`
165 and the `provision` scripts is what defines a given minion. For instance, a minion
166 may be defined as `centos7-java-builder` which is a combination of Packer OS image
167 definitions from `vars/centos.json`, Packer template definitions from
168 `templates/java-buidler.json` and spinup scripts from `provision/java-builder.sh`.
169 This combination provides the full definition of the realized minion.
170
171 Jenkins starts a minion using the latest image which is built and linked into the
172 Jenkins configuration. Once the base instance is online Jenkins checks out the
173 RelEng/Builder repo on it and executes two scripts. The first is
174 `provision/baseline.sh`, which is a baseline for all of the minions.
175
176 The second is the specialized script, which handles any system updates,
177 new software installs or extra environment tweaks that don't make sense in a
178 snapshot. Examples could include installing new package or setting up a virtual
179 environment. Its imperative to ensure modifications to these spinup scripts have
180 considered time taken to install the packages, as this could increase the build
181 time for every job which runs on the image. After all of these scripts have
182 executed Jenkins will finally attach the minion as an actual minion and start
183 handling jobs on it.
184
185 Pool: ODLRPC
186 ^^^^^^^^^^^^
187
188 .. raw:: html
189
190     <table class="table table-bordered">
191       <tr class="warning">
192         <td><b>Jenkins Labels</b><br/> centos7-java-builder-2c-4g,
193           centos7-java-builder-2c-8g, centos7-java-builder-4c-8g,
194           centos7-java-builder-8c-8g, centos7-java-builder-4c-16g</td>
195         <td><b>Minion Template names</b><br/> centos7-java-builder-2c-4g,
196           centos7-java-builder-2c-4g, centos7-java-builder-2c-8g,
197           centos7-java-builder-4c-8g, centos7-java-builder-8c-8g,
198           centos7-java-builder-4c-16g</td>
199         <td><b>Packer Template</b><br/>
200         releng/builder/packer/templates/java-builder.json</td>
201         <td><b>Spinup Script</b><br/>
202         releng/builder/jenkins-scripts/builder.sh</td>
203       </tr>
204       <tr>
205         <td colspan="4">
206           CentOS 7 build minion configured with OpenJDK 1.7 (Java7) and OpenJDK
207           1.8 (Java8) along with all the other components and libraries needed
208           for building any current OpenDaylight project. This is the label that
209           is used for all basic verify, merge and daily builds for
210           projects.
211         </td>
212       </tr>
213
214       <tr class="warning">
215         <td><b>Jenkins Labels</b><br/> centos7-robot-2c-2g</td>
216         <td><b>Minion Template names</b><br/> centos7-robot-2c-2g</td>
217         <td><b>Packer Template</b><br/>
218         releng/builder/packer/templates/robot.json</td>
219         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/robot.sh</td>
220       </tr>
221       <tr>
222         <td colspan="4">
223           CentOS 7 minion configured with OpenJDK 1.7 (Java7), OpenJDK
224           1.8 (Java8) and all the current packages used by the integration
225           project for doing robot driven jobs. If you are executing robot
226           framework jobs then your job should be using this as the minion that
227           you are tied to. This image does not contain the needed libraries for
228           building components of OpenDaylight, only for executing robot tests.
229         </td>
230       </tr>
231
232       <tr class="warning">
233         <td><b>Jenkins Labels</b><br/> ubuntu1404-mininet-2c-2g</td>
234         <td><b>Minion Template names</b><br/> ubuntu1404-mininet-2c-2g</td>
235         <td><b>Packer Template</b><br/>
236         releng/builder/packer/teamplates/mininet.json</td>
237         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/mininet-ubuntu.sh</td>
238       </tr>
239       <tr>
240         <td colspan="4">
241           Basic Ubuntu 14.04 (Trusty) system with ovs 2.0.2 and mininet 2.1.0
242         </td>
243       </tr>
244
245       <tr class="warning">
246         <td><b>Jenkins Labels</b><br/> ubuntu1404-mininet-ovs-23-2c-2g</td>
247         <td><b>Minion Template names</b><br/> ubuntu1404-mininet-ovs-23-2c-2g</td>
248         <td><b>Packer Template</b><br/> releng/builder/packer/templates/mininet-ovs-2.3.json</td>
249         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/mininet-ubuntu.sh</td>
250       </tr>
251       <tr>
252         <td colspan="4">
253           Ubuntu 14.04 (Trusty) system with ovs 2.3 and mininet 2.2.1
254         </td>
255       </tr>
256
257       <tr class="warning">
258         <td><b>Jenkins Labels</b><br/> ubuntu1404-mininet-ovs-25-2c-2g</td>
259         <td><b>Minion Template names</b><br/> ubuntu1404-mininet-ovs-25-2c-2g</td>
260         <td><b>Packer Template</b><br/> releng/builder/packer/templates/mininet-ovs-2.5.json</td>
261         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/mininet-ubuntu.sh</td>
262       </tr>
263       <tr>
264         <td colspan="4">
265           Ubuntu 14.04 (Trusty) system with ovs 2.5 and mininet 2.2.2
266         </td>
267       </tr>
268
269       <tr class="warning">
270         <td><b>Jenkins Labels</b><br/> ubuntu1604-mininet-ovs-25-2c-4g</td>
271         <td><b>Minion Template names</b><br/> ubuntu1604-mininet-ovs-25-2c-4g</td>
272         <td><b>Packer Template</b><br/> releng/builder/packer/templates/mininet-ovs-2.5.json</td>
273         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/mininet-ubuntu.sh</td>
274       </tr>
275       <tr>
276         <td colspan="4">
277           Ubuntu 16.04 (Xenial) system with ovs 2.5 and mininet 2.2.1
278         </td>
279       </tr>
280
281       <tr class="warning">
282         <td><b>Jenkins Labels</b><br/> centos7-devstack-2c-4g</td>
283         <td><b>Minion Template names</b><br/> centos7-devstack-2c-4g</td>
284         <td><b>Packer Template</b><br/> releng/builder/packer/templates/devstack.json</td>
285         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/devstack.sh</td>
286       </tr>
287       <tr>
288         <td colspan="4">
289           CentOS 7 system purpose built for doing OpenStack testing using
290           DevStack. This minion is primarily targeted at the needs of the OVSDB
291           project. It has OpenJDK 1.7 (aka Java7) and OpenJDK 1.8 (Java8) and
292           other basic DevStack related bits installed.
293         </td>
294       </tr>
295
296       <tr class="warning">
297         <td><b>Jenkins Labels</b><br/> centos7-docker-2c-4g</td>
298         <td><b>Minion Template names</b><br/> centos7-docker-2c-4g</td>
299         <td><b>Packer Template</b><br/> releng/builder/packer/templates/docker.json</td>
300         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/docker.sh</td>
301       </tr>
302       <tr>
303         <td colspan="4">
304           CentOS 7 system configured with OpenJDK 1.7 (aka Java7),
305           OpenJDK 1.8 (Java8) and Docker. This system was originally custom
306           built for the test needs of the OVSDB project but other projects have
307           expressed interest in using it.
308         </td>
309       </tr>
310
311       <tr class="warning">
312         <td><b>Jenkins Labels</b><br/> ubuntu1404-gbp-2c-2g</td>
313         <td><b>Minion Template names</b><br/> ubuntu1404-gbp-2c-2g</td>
314         <td><b>Packer Template</b><br/> releng/builder/packer/templates/gbp.json</td>
315         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/ubuntu-docker-ovs.sh</td>
316       </tr>
317       <tr>
318         <td colspan="4">
319           Ubuntu 14.04 (Trusty) node with latest OVS and docker installed. Used by Group Based Policy.
320         </td>
321       </tr>
322
323       <tr class="warning">
324         <td><b>Jenkins Labels</b><br/> ubuntu1604-gbp-2c-4g</td>
325         <td><b>Minion Template names</b><br/> ubuntu1604-gbp-2c-4g</td>
326         <td><b>Packer Template</b><br/> releng/builder/packer/templates/gbp.json</td>
327         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/ubuntu-docker-ovs.sh</td>
328       </tr>
329       <tr>
330         <td colspan="4">
331           Ubuntu 16.04 (Xenial) node with latest OVS and docker installed. Used by Group Based Policy.
332         </td>
333       </tr>
334
335     </table>
336
337 Pool: ODLPUB - HOT (Heat Orchestration Templates)
338 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
339
340 HOT integration enables to spin up integration labs servers for CSIT jobs
341 using heat, rathar than using jclouds (deprecated). Image names are updated
342 on the project specific job templates using the variable
343 `{odl,docker,openstack,tools}_system_image` followed by image name in the
344 format `<platform> - <template> - <date-stamp>`.
345
346 .. code-block:: yaml
347
348     CentOS 7 - docker - 20161031-0802
349
350 .. include:: cloud-images.rst
351
352 Creating Jenkins Jobs
353 ---------------------
354
355 Jenkins Job Builder takes simple descriptions of Jenkins jobs in YAML format
356 and uses them to configure Jenkins.
357
358 * `Jenkins Job Builder (JJB) documentation <jjb-docs_>`_
359 * `RelEng/Builder Gerrit <releng-builder-gerrit_>`_
360 * `RelEng/Builder Git repository <releng-builder-repo_>`_
361
362 Getting Jenkins Job Builder
363 ---------------------------
364
365 OpenDaylight uses Jenkins Job Builder to translate our in-repo YAML job
366 configuration into job descriptions suitable for consumption by Jenkins.
367 When testing new Jenkins Jobs in the `Jenkins Sandbox`_, you'll
368 need to use the `jenkins-jobs` executable to translate a set of jobs into
369 their XML descriptions and upload them to the sandbox Jenkins server.
370
371 We document `installing <Installing Jenkins Job Builder_>`_ `jenkins-jobs`
372 below. We also provide
373 a `pre-built Docker image <jjb-docker_>`_ with `jenkins-jobs` already installed.
374
375 Installing Jenkins Job Builder
376 ------------------------------
377
378 For users who aren't already experienced with Docker or otherwise don't want
379 to use our `pre-built JJB Docker image <jjb-docker_>`_, installing JJB into a
380 virtual environment is an equally good option.
381
382 We recommend using `pip <Installing JJB using pip_>`_ to assist with JJB
383 installs, but we
384 also document `installing from a git repository manually
385 <Installing JJB Manually_>`_.
386 For both, we recommend using Python `Virtual Environments`_
387 to isolate JJB and its dependencies.
388
389 The `builder/jjb/requirements.txt <odl-jjb-requirements.txt_>`_ file contains the currently
390 recommended JJB version. Because JJB is fairly unstable, it may be necessary
391 to debug things by installing different versions. This is documented for both
392 `pip-assisted <Installing JJB using pip_>`_ and `manual
393 <Installing JJB Manually_>`_ installs.
394
395 Virtual Environments
396 --------------------
397
398 For both `pip-assisted <Installing JJB using pip_>`_ and `manual
399 <Installing JJB Manually_>`_ JJB
400 installs, we recommend using `Python Virtual Environments <python-virtualenv_>`_
401 to manage JJB and its
402 Python dependencies. The `python-virtualenvwrapper`_ tool can help you do so.
403
404 There are good docs for installing `python-virtualenvwrapper`_. On Linux systems
405 with pip (typical), they amount to:
406
407 .. code-block:: bash
408
409     sudo pip install virtualenvwrapper
410
411 A virtual environment is simply a directory that you install Python programs
412 into and then append to the front of your path, causing those copies to be
413 found before any system-wide versions.
414
415 Create a new virtual environment for JJB.
416
417 .. code-block:: bash
418
419     # Virtaulenvwrapper uses this dir for virtual environments
420     $ echo $WORKON_HOME
421     /home/daniel/.virtualenvs
422     # Make a new virtual environment
423     $ mkvirtualenv jjb
424     # A new venv dir was created
425     (jjb)$ ls -rc $WORKON_HOME | tail -n 1
426     jjb
427     # The new venv was added to the front of this shell's path
428     (jjb)$ echo $PATH
429     /home/daniel/.virtualenvs/jjb/bin:<my normal path>
430     # Software installed to venv, like pip, is found before system-wide copies
431     (jjb)$ command -v pip
432     /home/daniel/.virtualenvs/jjb/bin/pip
433
434 With your virtual environment active, you should install JJB. Your install will
435 be isolated to that virtual environment's directory and only visible when the
436 virtual environment is active.
437
438 You can easily leave and return to your venv. Make sure you activate it before
439 each use of JJB.
440
441 .. code-block:: bash
442
443     (jjb)$ deactivate
444     $ command -v jenkins-jobs
445     # No jenkins-jobs executable found
446     $ workon jjb
447     (jjb)$ command -v jenkins-jobs
448     $WORKON_HOME/jjb/bin/jenkins-jobs
449
450 Installing JJB using pip
451 ------------------------
452
453 The recommended way to install JJB is via pip.
454
455 First, clone the latest version of the `releng-builder-repo`_.
456
457 .. code-block:: bash
458
459     $ git clone https://git.opendaylight.org/gerrit/p/releng/builder.git
460
461 Before actually installing JJB and its dependencies, make sure you've `created
462 and activated <Virtual Environments_>`_ a virtual environment for JJB.
463
464 .. code-block:: bash
465
466     $ mkvirtualenv jjb
467
468 The recommended version of JJB to install is the version specified in the
469 `builder/jjb/requirements.txt <odl-jjb-requirements.txt_>`_ file.
470
471 .. code-block:: bash
472
473     # From the root of the releng/builder repo
474     (jjb)$ pip install -r jjb/requirements.txt
475
476 To validate that JJB was successfully installed you can run this command:
477
478 .. code-block:: bash
479
480     (jjb)$ jenkins-jobs --version
481
482 TODO: Explain that only the currently merged jjb/requirements.txt is supported,
483 other options described below are for troubleshooting only.
484
485 To change the version of JJB specified by `builder/jjb/requirements.txt
486 <odl-jjb-requirements.txt_>`_
487 to install from the latest commit to the master branch of JJB's git repository:
488
489 .. code-block:: bash
490
491     $ cat jjb/requirements.txt
492     -e git+https://git.openstack.org/openstack-infra/jenkins-job-builder#egg=jenkins-job-builder
493
494 To install from a tag, like 1.4.0:
495
496 .. code-block:: bash
497
498     $ cat jjb/requirements.txt
499     -e git+https://git.openstack.org/openstack-infra/jenkins-job-builder@1.4.0#egg=jenkins-job-builder
500
501 Installing JJB Manually
502 -----------------------
503
504 This section documents installing JJB from its manually cloned repository.
505
506 Note that `installing via pip <Installing JJB using pip_>`_ is typically simpler.
507
508 Checkout the version of JJB's source you'd like to build.
509
510 For example, using master:
511
512 .. code-block:: bash
513
514     $ git clone https://git.openstack.org/openstack-infra/jenkins-job-builder
515
516 Using a tag, like 1.4.0:
517
518 .. code-block:: bash
519
520     $ git clone https://git.openstack.org/openstack-infra/jenkins-job-builder
521     $ cd jenkins-job-builder
522     $ git checkout tags/1.4.0
523
524 Before actually installing JJB and its dependencies, make sure you've `created
525 and activated <Virtual Environments_>`_ a virtual environment for JJB.
526
527 .. code-block:: bash
528
529     $ mkvirtualenv jjb
530
531 You can then use JJB's `requirements.txt <jjb-requirements.txt_>`_ file to
532 install its
533 dependencies. Note that we're not using `sudo` to install as root, since we want
534 to make use of the venv we've configured for our current user.
535
536 .. code-block:: bash
537
538     # In the cloned JJB repo, with the desired version of the code checked out
539     (jjb)$ pip install -r requirements.txt
540
541 Then install JJB from the repo with:
542
543 .. code-block:: bash
544
545     (jjb)$ pip install .
546
547 To validate that JJB was successfully installed you can run this command:
548
549 .. code-block:: bash
550
551     (jjb)$ jenkins-jobs --version
552
553 JJB Docker Image
554 ----------------
555
556 `Docker <docker-docs_>`_ is an open platform used to create virtualized Linux containers
557 for shipping self-contained applications. Docker leverages LinuX Containers
558 \(LXC\) running on the same operating system as the host machine, whereas a
559 traditional VM runs an operating system over the host.
560
561 .. code-block:: bash
562
563     docker pull zxiiro/jjb-docker
564     docker run --rm -v ${PWD}:/jjb jjb-docker
565
566 This `Dockerfile <jjb-dockerfile_>`_ created the
567 `zxiiro/jjb-docker image <jjb-docker_>`_.
568 By default it will run:
569
570 .. code-block:: bash
571
572     jenkins-jobs test .
573
574 You'll need to use the `-v/--volume=[]` parameter to mount a directory
575 containing your YAML files, as well as a configured `jenkins.ini` file if you
576 wish to upload your jobs to the `Jenkins Sandbox`_.
577
578 Jenkins Job Templates
579 ---------------------
580
581 The OpenDaylight `RelEng/Builder <releng-builder-wiki_>`_ project provides
582 `jjb-templates`_ that can be used to define basic jobs.
583
584 The *Gerrit Trigger* listed in the jobs are keywords that can be used to
585 trigger the job to run manually by simply leaving a comment in Gerrit for the
586 patch you wish to trigger against.
587
588 All jobs have a default build-timeout value of 360 minutes (6 hrs) but can be
589 overrided via the opendaylight-infra-wrappers' build-timeout property.
590
591 TODO: Group jobs into categories: every-patch, after-merge, on-demand, etc.
592 TODO: Reiterate that "remerge" triggers all every-patch jobs at once,
593 because when only a subset of jobs is triggered, Gerrit forgets valid -1 from jobs outside the subset.
594 TODO: Document that only drafts and commit-message-only edits do not trigger every-patch jobs.
595 TODO: Document test-{project}-{feature} and test-{project}-all.
596
597 .. raw:: html
598
599     <table class="table table-bordered">
600       <tr class="warning">
601         <td><b>Job Template</b><br/>{project}-distribution-check-{stream}</td>
602         <td><b>Gerrit Trigger</b><br/>recheck</td>
603       </tr>
604       <tr>
605         <td colspan="2">
606           This job runs the PROJECT-distribution-check-BRANCH job which is
607           building also integration/distribution project in order to run SingleFeatureTest.
608           It also performs various other checks in order to prevent the change to break autorelease.
609         </td>
610       </tr>
611
612       <tr class="warning">
613         <td><b>Job Template</b><br/>{project}-integration-{stream}</td>
614         <td></td>
615       </tr>
616       <tr>
617         <td colspan="2">
618           The Integration Job Template creates a job which runs when a project that your
619           project depends on is successfully built. This job type is basically the same
620           as a verify job except that it triggers from other Jenkins jobs instead of via
621           Gerrit review updates. The dependencies that triger integration jobs are listed
622           in your project.cfg file under the <b>DEPENDENCIES</b> variable.
623
624           If no dependencies are listed then this job type is disabled by default.
625         </td>
626       </tr>
627
628       <tr class="warning">
629         <td><b>Job Template</b><br/>{project}-merge-{stream}</td>
630         <td><b>Gerrit Trigger</b><br/>remerge</td>
631       </tr>
632       <tr>
633         <td colspan="2">
634           This job will trigger once a Gerrit patch is merged into the repo.
635           It will build HEAD of the current project branch and also run the Maven goals
636           <b>source:jar</b> and <b>javadoc:jar</b>.
637           Artifacts are uploaded to OpenDaylight's
638           <a href="https://nexus.opendaylight.org">Nexus</a> on completion.
639
640           A distribution-merge-{stream} job is triggered to add the new artifacts to the
641           integration distribution.
642
643           Running the "remerge" trigger is possible before a Change is merged,
644           it would still build the actual HEAD. This job does not alter Gerrit votes.
645         </td>
646       </tr>
647
648       <tr class="warning">
649         <td><b>Job Template</b><br/>{project}-sonar</td>
650         <td><b>Gerrit Trigger</b><br/>run-sonar</td>
651       </tr>
652       <tr>
653         <td colspan="2">
654           This job runs Sonar analysis and reports the results to
655           OpenDaylight's <a href="https://sonar.opendaylight.org">Sonar</a>
656           dashboard.
657
658           The Sonar Job Template creates a job which will run against the
659           master branch, or if BRANCHES are specified in the CFG file it will
660           create a job for the <b>First</b> branch listed.
661
662           <div class="admonition note">
663             <p class="first admonition-title">Note</p>
664             <p>
665               Running the "run-sonar" trigger will cause Jenkins to remove
666               its existing vote if it's already -1'd or +1'd a comment. You
667               will need to re-run your verify job (recheck) after running
668               this to get Jenkins to re-vote.
669             </p>
670           </div>
671         </td>
672       </tr>
673
674       <tr class="warning">
675         <td><b>Job Template</b><br/>{project}-validate-autorelease-{stream}</td>
676         <td><b>Gerrit Trigger</b><br/>recheck</td>
677       </tr>
678       <tr>
679         <td colspan="2">
680           This job runs the PROJECT-validate-autorelease-BRANCH job which is
681           used as a quick sanity test to ensure that a patch does not depend on
682           features that do not exist in the current release.
683         </td>
684       </tr>
685
686       <tr class="warning">
687         <td><b>Job Template</b><br/>{project}-verify-{stream}-{maven}-{jdks}</td>
688         <td><b>Gerrit Trigger</b><br/>recheck</td>
689       </tr>
690       <tr>
691         <td colspan="2">
692           The Verify job template creates a Gerrit Trigger job that will
693           trigger when a new patch is submitted to Gerrit.
694           The job only builds the project code (including unit and integration tests).
695         </td>
696       </tr>
697
698       <tr class="warning">
699         <td><b>Job Template</b><br/>{project}-verify-node-{stream}</td>
700         <td><b>Gerrit Trigger</b><br/>recheck</td>
701       </tr>
702       <tr>
703         <td colspan="2">
704           This job template can be used by a project that is NodeJS based. It
705           simply installs a python virtualenv and uses that to install nodeenv
706           which is then used to install another virtualenv for nodejs. It then
707           calls <b>npm install</b> and <b>npm test</b> to run the unit tests.
708           When  using this template you need to provide a {nodedir} and
709           {nodever} containing the directory relative to the project root
710           containing the nodejs package.json and version of node you wish to
711           run tests with.
712         </td>
713       </tr>
714
715       <tr class="warning">
716         <td><b>Job Template</b><br/>{project}-verify-python-{stream} | {project}-verify-tox-{stream}</td>
717         <td><b>Gerrit Trigger</b><br/>recheck</td>
718       </tr>
719       <tr>
720         <td colspan="2">
721           This job template can be used by a project that uses Tox to build. It
722           simply installs a Python virtualenv and uses tox to run the tests
723           defined in the project's tox.ini file. If the tox.ini is anywhere
724           other than the project's repo root, the path to its directory
725           relative to the project's repo root should be passed as {toxdir}.
726
727           The 2 template names verify-python & verify-tox are identical and are
728           aliases to each other. This allows the project to use the naming that
729           is most reasonable for them.
730         </td>
731       </tr>
732
733       <tr class="warning">
734         <td><b>Job Template</b><br/>integration-patch-test-{stream}</td>
735         <td><b>Gerrit Trigger</b><br/>test-integration</td>
736       </tr>
737       <tr>
738         <td colspan="2">
739         </td>
740       </tr>
741
742       <tr class="warning">
743         <td><b>Job Template</b><br/>integration-patch-test-{stream}</td>
744         <td><b>Gerrit Trigger</b><br/>test-integration</td>
745       </tr>
746       <tr>
747         <td colspan="2">
748           This job builds a distribution against your Java patch and triggers distribution sanity CSIT jobs.
749           Leave a comment with trigger keyword above to activate it for a particular patch.
750           This job should not alter Gerrit votes for a given patch.
751
752           The list of CSIT jobs to trigger is defined in csit-list
753           <a href="https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jjb/integration/integration-test-jobs.yaml">here</a>.
754
755           Some considerations when using this job:
756           <ul>
757             <li>
758               The patch test verification takes some time (~2 hours) + consumes a lot of
759               resources so it is not meant to be used for every patch.
760             </li>
761             <li>
762               The system tests for master patches will fail most of the times because both
763               code and test are unstable during the release cycle (should be good by the
764               end of the cycle).
765             </li>
766             <li>
767               Because of the above, patch test results typically have to be interpreted by
768               system test experts. The <a href="https://wiki.opendaylight.org/view/Integration/Test">Integration/Test</a>
769               project can help with that.
770             </li>
771         </td>
772       </tr>
773     </table>
774
775 Maven Properties
776 ----------------
777
778 We provide a properties which your job can take advantage of if you want to do
779 something different depending on the job type that is run. If you create a
780 profile that activates on a property listed blow. The JJB templated jobs will
781 be able to activate the profile during the build to run any custom code you
782 wish to run in your project.
783
784 .. code-block:: bash
785
786     -Dmerge   : This flag is passed in our Merge job and is equivalent to the
787                 Maven property
788                 <merge>true</merge>.
789     -Dsonar   : This flag is passed in our Sonar job and is equivalent to the
790                 Maven property
791                 <sonar>true</sonar>.
792
793 Jenkins Sandbox
794 ---------------
795
796 The `jenkins-sandbox`_ instance's purpose is to allow projects to test their JJB
797 setups before merging their code over to the RelEng master silo. It is
798 configured similarly to the master instance, although it cannot publish
799 artifacts or vote in Gerrit.
800
801 If your project requires access to the sandbox please open an OpenDaylight
802 Helpdesk ticket (<helpdesk@opendaylight.org>) and provide your ODL ID.
803
804 Notes Regarding the Sandbox
805 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
806
807 * Jobs are automatically deleted every Saturday at 08:00 UTC
808 * Committers can login and configure Jenkins jobs in the sandbox directly
809   (unlike with the master silo)
810 * Sandbox configuration mirrors the master silo when possible
811 * Sandbox jobs can NOT upload artifacts to Nexus
812 * Sandbox jobs can NOT vote on Gerrit
813
814 Configuration
815 ^^^^^^^^^^^^^
816
817 Make sure you have Jenkins Job Builder [properly installed](#jjb_install).
818
819 If you do not already have access, open an OpenDaylight Helpdesk ticket
820 (<helpdesk@opendaylight.org>) to request access to ODL's sandbox instance.
821 Integration/Test (`integration-test-wiki`_) committers have access by default.
822
823 JJB reads user-specific configuration from a `jenkins.ini`_. An
824 example is provided by releng/builder at `example-jenkins.ini`_.
825
826 .. code-block:: bash
827
828     # If you don't have RelEng/Builder's repo, clone it
829     $ git clone https://git.opendaylight.org/gerrit/p/releng/builder.git
830     # Make a copy of the example JJB config file (in the builder/ directory)
831     $ cp jenkins.ini.example jenkins.ini
832     # Edit jenkins.ini with your username, API token and ODL's sandbox URL
833     $ cat jenkins.ini
834     <snip>
835     [jenkins]
836     user=<your ODL username>
837     password=<your ODL Jenkins sandbox API token>
838     url=https://jenkins.opendaylight.org/sandbox
839     <snip>
840
841 To get your API token, `login to the Jenkins **sandbox** instance
842 <jenkins-sandbox-login_>`_ (*not
843 the main master Jenkins instance, different tokens*), go to your user page (by
844 clicking on your username, for example), click "Configure" and then "Show API
845 Token".
846
847 Manual Method
848 ^^^^^^^^^^^^^
849
850 If you `installed JJB locally into a virtual environment
851 <Installing Jenkins Job Builder_>`_,
852 you should now activate that virtual environment to access the `jenkins-jobs`
853 executable.
854
855 .. code-block:: bash
856
857     $ workon jjb
858     (jjb)$
859
860 You'll want to work from the root of the RelEng/Builder repo, and you should
861 have your `jenkins.ini` file [properly configured](#sandbox_config).
862
863 Testing Jobs
864 ^^^^^^^^^^^^
865
866 It's good practice to use the `test` command to validate your JJB files before
867 pushing them.
868
869 .. code-block:: bash
870
871     jenkins-jobs --conf jenkins.ini test jjb/ <job-name>
872
873 If the job you'd like to test is a template with variables in its name, it
874 must be manually expanded before use. For example, the commonly used template
875 `{project}-csit-verify-1node-{functionality}` might expand to
876 `ovsdb-csit-verify-1node-netvirt`.
877
878 .. code-block:: bash
879
880     jenkins-jobs --conf jenkins.ini test jjb/ ovsdb-csit-verify-1node-netvirt
881
882 Successful tests output the XML description of the Jenkins job described by
883 the specified JJB job name.
884
885 Pushing Jobs
886 ^^^^^^^^^^^^
887
888 Once you've `configured your \`jenkins.ini\` <Configuration_>`_ and `verified your
889 JJB jobs <Testing Jobs_>`_ produce valid XML descriptions of Jenkins jobs you
890 can push them to the Jenkins sandbox.
891
892 .. important::
893
894     When pushing with `jenkins-jobs`, a log message with the number
895     of jobs you're pushing will be issued, typically to stdout.
896     **If the number is greater than 1** (or the number of jobs you
897     passed to the command to push) then you are pushing too many
898     jobs and should **`ctrl+c` to cancel the upload**. Else you will
899     flood the system with jobs.
900
901     .. code-block:: bash
902
903         INFO:jenkins_jobs.builder:Number of jobs generated:  1
904
905     **Failing to provide the final `<job-name>` param will push all
906     jobs!**
907
908     .. code-block:: bash
909
910         # Don't push all jobs by omitting the final param! (ctrl+c to abort)
911         jenkins-jobs --conf jenkins.ini update jjb/ <job-name>
912
913 Running Jobs
914 ^^^^^^^^^^^^
915
916 Once you have your Jenkins job configuration `pushed to the
917 Sandbox <Pushing Jobs_>`_ you can trigger it to run.
918
919 Find your newly-pushed job on the `Sandbox's web UI <jenkins-sandbox_>`_. Click
920 on its name to see the job's details.
921
922 Make sure you're `logged in <jenkins-sandbox-login_>`_ to the Sandbox.
923
924 Click "Build with Parameters" and then "Build".
925
926 Wait for your job to be scheduled and run. Click on the job number to see
927 details, including console output.
928
929 Make changes to your JJB configuration, re-test, re-push and re-run until
930 your job is ready.
931
932 Docker Method
933 ^^^^^^^^^^^^^
934
935 If `using Docker <JJB Docker image_>`_:
936
937 .. code-block:: bash
938
939     # To test
940     docker run --rm -v ${PWD}:/jjb zxiiro/jjb-docker
941
942 .. important::
943
944     When pushing with `jenkins-jobs`, a log message with
945     the number of jobs you're pushing will be issued, typically to stdout.
946     **If the number is greater than 1** (or the number of jobs you passed to
947     the command to push) then you are pushing too many jobs and should **`ctrl+c`
948     to cancel the upload**. Else you will flood the system with jobs.
949
950     .. code-block:: bash
951
952           INFO:jenkins_jobs.builder:Number of jobs generated:  1
953
954     **Failing to provide the final `<job-name>` param will push all jobs!**
955
956     .. code-block:: bash
957
958         # To upload jobs to the sandbox
959         # Please ensure that you include a configured jenkins.ini in your volume mount
960         # Making sure not to push more jobs than expected, ctrl+c to abort
961         docker run --rm -v ${PWD}:/jjb zxiiro/jjb-docker jenkins-jobs --conf jenkins.ini update . openflowplugin-csit-periodic-1node-cds-longevity-only-master
962
963 .. _docker-docs: https://www.docker.com/whatisdocker/
964 .. _example-jenkins.ini: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jenkins.ini.example
965 .. _integration-test-wiki: https://wiki.opendaylight.org/view/Integration/Test
966 .. _jenkins-master: https://jenkins.opendaylight.org/releng
967 .. _jenkins-sandbox: https://jenkins.opendaylight.org/sandbox
968 .. _jenkins-sandbox-login: https://jenkins.opendaylight.org/sandbox/login
969 .. _jenkins.ini: http://docs.openstack.org/infra/jenkins-job-builder/execution.html#configuration-file
970 .. _jjb-autoupdate-project.py: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=scripts/jjb-autoupdate-project.py
971 .. _jjb-docker: https://hub.docker.com/r/zxiiro/jjb-docker/
972 .. _jjb-dockerfile: https://github.com/zxiiro/jjb-docker/blob/master/Dockerfile
973 .. _jjb-docs: http://ci.openstack.org/jenkins-job-builder/
974 .. _jjb-init-project.py: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=scripts/jjb-init-project.py
975 .. _jjb-repo: https://github.com/openstack-infra/jenkins-job-builder
976 .. _jjb-requirements.txt: https://github.com/openstack-infra/jenkins-job-builder/blob/master/requirements.txt
977 .. _jjb-templates: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=tree;f=jjb
978 .. _odl-jjb-requirements.txt: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jjb/requirements.txt
979 .. _odl-nexus: https://nexus.opendaylight.org
980 .. _odl-sonar: https://sonar.opendaylight.org
981 .. _python-virtualenv: https://virtualenv.readthedocs.org/en/latest/
982 .. _python-virtualenvwrapper: https://virtualenvwrapper.readthedocs.org/en/latest/
983 .. _releng-wiki: https://wiki.opendaylight.org/view/RelEng:Main
984 .. _releng-builder-gerrit: https://git.opendaylight.org/gerrit/#/admin/projects/releng/builder
985 .. _releng-builder-repo: https://git.opendaylight.org/gerrit/gitweb?p=releng%2Fbuilder.git;a=summary
986 .. _releng-builder-wiki: https://wiki.opendaylight.org/view/RelEng/Builder
987 .. _streams-design-background: https://lists.opendaylight.org/pipermail/release/2015-July/003139.html
988 .. _spinup-scripts: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=tree;f=jenkins-scripts
989 .. _spinup-scripts-basic_settings.sh: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jenkins-scripts/basic_settings.sh
990 .. _spinup-scripts-controller.sh: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jenkins-scripts/controller.sh