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