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