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