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