94e285e5797a4f51a1bf7ebcb0d0aaa6bd35585e
[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/> ubuntu_mininet_ovs_25</td>
266         <td><b>Minion Template name</b><br/> ubuntu-trusty-mininet-ovs-25</td>
267         <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/ubuntu-mininet-ovs-25</td>
268         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/mininet-ubuntu.sh</td>
269       </tr>
270       <tr>
271         <td colspan="4">
272           Basic Ubuntu system with ovs 2.5 and mininet 2.2.2
273         </td>
274       </tr>
275
276       <tr class="warning">
277         <td><b>Jenkins Label</b><br/> dynamic_controller</td>
278         <td><b>Minion Template name</b><br/> centos7-java</td>
279         <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/basic-java-node</td>
280         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/controller.sh</td>
281       </tr>
282       <tr>
283         <td colspan="4">
284           A CentOS 7 minion that has the basic OpenJDK 1.7 (Java7) and OpenJDK
285           1.8 (Java8) installed and is capable of running the controller, not
286           building.
287         </td>
288       </tr>
289
290       <tr class="warning">
291         <td><b>Jenkins Label</b><br/> dynamic_java</td>
292         <td><b>Minion Template name</b><br/> centos7-java</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.
299         </td>
300       </tr>
301
302       <tr class="warning">
303         <td><b>Jenkins Label</b><br/> dynamic_java_8g</td>
304         <td><b>Minion Template name</b><br/> centos7-java-8g</td>
305         <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/basic-java-node</td>
306         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/controller.sh</td>
307       </tr>
308       <tr>
309         <td colspan="4">
310           See dynamic_controller as it is currently the same image but with 8G of RAM.
311         </td>
312       </tr>
313
314       <tr class="warning">
315         <td><b>Jenkins Label</b><br/> dynamic_devstack</td>
316         <td><b>Minion Template name</b><br/> centos7-devstack</td>
317         <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/ovsdb-devstack</td>
318         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/devstack.sh</td>
319       </tr>
320       <tr>
321         <td colspan="4">
322           A CentOS 7 system purpose built for doing OpenStack testing using
323           DevStack. This minion is primarily targeted at the needs of the OVSDB
324           project. It has OpenJDK 1.7 (aka Java7) and OpenJDK 1.8 (Java8) and
325           other basic DevStack related bits installed.
326         </td>
327       </tr>
328
329       <tr class="warning">
330         <td><b>Jenkins Label</b><br/> dynamic_docker</td>
331         <td><b>Minion Template name</b><br/> centos7-docker</td>
332         <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/ovsdb-docker</td>
333         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/docker.sh</td>
334       </tr>
335       <tr>
336         <td colspan="4">
337           A CentOS 7 system that is configured with OpenJDK 1.7 (aka Java7),
338           OpenJDK 1.8 (Java8) and Docker. This system was originally custom
339           built for the test needs of the OVSDB project but other projects have
340           expressed interest in using it.
341         </td>
342       </tr>
343
344       <tr class="warning">
345         <td><b>Jenkins Label</b><br/> gbp_trusty</td>
346         <td><b>Minion Template name</b><br/> gbp_trusty</td>
347         <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/gbp-ubuntu-docker-ovs-node</td>
348         <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/ubuntu-docker-ovs.sh</td>
349       </tr>
350       <tr>
351         <td colspan="4">
352           A basic Ubuntu node with latest OVS and docker installed. Used by Group Based Policy.
353         </td>
354       </tr>
355     </table>
356
357 Creating Jenkins Jobs
358 ---------------------
359
360 Jenkins Job Builder takes simple descriptions of Jenkins jobs in YAML format
361 and uses them to configure Jenkins.
362
363 * `Jenkins Job Builder (JJB) documentation <jjb-docs_>`_
364 * `RelEng/Builder Gerrit <releng-builder-gerrit_>`_
365 * `RelEng/Builder Git repository <releng-builder-repo_>`_
366
367 Getting Jenkins Job Builder
368 ---------------------------
369
370 OpenDaylight uses Jenkins Job Builder to translate our in-repo YAML job
371 configuration into job descriptions suitable for consumption by Jenkins.
372 When testing new Jenkins Jobs in the `Jenkins Sandbox`_, you'll
373 need to use the `jenkins-jobs` executable to translate a set of jobs into
374 their XML descriptions and upload them to the sandbox Jenkins server.
375
376 We document `installing <Installing Jenkins Job Builder_>`_ `jenkins-jobs`
377 below. We also provide
378 a `pre-built Docker image <jjb-docker_>`_ with `jenkins-jobs` already installed.
379
380 Installing Jenkins Job Builder
381 ------------------------------
382
383 For users who aren't already experienced with Docker or otherwise don't want
384 to use our `pre-built JJB Docker image <jjb-docker_>`_, installing JJB into a
385 virtual environment is an equally good option.
386
387 We recommend using `pip <Installing JJB using pip_>`_ to assist with JJB
388 installs, but we
389 also document `installing from a git repository manually
390 <Installing JJB Manually_>`_.
391 For both, we recommend using Python `Virtual Environments`_
392 to isolate JJB and its dependencies.
393
394 The `builder/jjb/requirements.txt <odl-jjb-requirements.txt_>`_ file contains the currently
395 recommended JJB version. Because JJB is fairly unstable, it may be necessary
396 to debug things by installing different versions. This is documented for both
397 `pip-assisted <Installing JJB using pip_>`_ and `manual
398 <Installing JJB Manually_>`_ installs.
399
400 Virtual Environments
401 --------------------
402
403 For both `pip-assisted <Installing JJB using pip_>`_ and `manual
404 <Installing JJB Manually_>`_ JJB
405 installs, we recommend using `Python Virtual Environments <python-virtualenv_>`_
406 to manage JJB and its
407 Python dependencies. The `python-virtualenvwrapper`_ tool can help you do so.
408
409 There are good docs for installing `python-virtualenvwrapper`_. On Linux systems
410 with pip (typical), they amount to:
411
412 .. code-block:: bash
413
414     sudo pip install virtualenvwrapper
415
416 A virtual environment is simply a directory that you install Python programs
417 into and then append to the front of your path, causing those copies to be
418 found before any system-wide versions.
419
420 Create a new virtual environment for JJB.
421
422 .. code-block:: bash
423
424     # Virtaulenvwrapper uses this dir for virtual environments
425     $ echo $WORKON_HOME
426     /home/daniel/.virtualenvs
427     # Make a new virtual environment
428     $ mkvirtualenv jjb
429     # A new venv dir was created
430     (jjb)$ ls -rc $WORKON_HOME | tail -n 1
431     jjb
432     # The new venv was added to the front of this shell's path
433     (jjb)$ echo $PATH
434     /home/daniel/.virtualenvs/jjb/bin:<my normal path>
435     # Software installed to venv, like pip, is found before system-wide copies
436     (jjb)$ command -v pip
437     /home/daniel/.virtualenvs/jjb/bin/pip
438
439 With your virtual environment active, you should install JJB. Your install will
440 be isolated to that virtual environment's directory and only visible when the
441 virtual environment is active.
442
443 You can easily leave and return to your venv. Make sure you activate it before
444 each use of JJB.
445
446 .. code-block:: bash
447
448     (jjb)$ deactivate
449     $ command -v jenkins-jobs
450     # No jenkins-jobs executable found
451     $ workon jjb
452     (jjb)$ command -v jenkins-jobs
453     $WORKON_HOME/jjb/bin/jenkins-jobs
454
455 Installing JJB using pip
456 ------------------------
457
458 The recommended way to install JJB is via pip.
459
460 First, clone the latest version of the `releng-builder-repo`_.
461
462 .. code-block:: bash
463
464     $ git clone https://git.opendaylight.org/gerrit/p/releng/builder.git
465
466 Before actually installing JJB and its dependencies, make sure you've `created
467 and activated <Virtual Environments_>`_ a virtual environment for JJB.
468
469 .. code-block:: bash
470
471     $ mkvirtualenv jjb
472
473 The recommended version of JJB to install is the version specified in the
474 `builder/jjb/requirements.txt <odl-jjb-requirements.txt_>`_ file.
475
476 .. code-block:: bash
477
478     # From the root of the releng/builder repo
479     (jjb)$ pip install -r jjb/requirements.txt
480
481 To validate that JJB was successfully installed you can run this command:
482
483 .. code-block:: bash
484
485     (jjb)$ jenkins-jobs --version
486
487 To change the version of JJB specified by `builder/jjb/requirements.txt
488 <odl-jjb-requirements.txt_>`_
489 to install from the latest commit to the master branch of JJB's git repository:
490
491 .. code-block:: bash
492
493     $ cat jjb/requirements.txt
494     -e git+https://git.openstack.org/openstack-infra/jenkins-job-builder#egg=jenkins-job-builder
495
496 To install from a tag, like 1.4.0:
497
498 .. code-block:: bash
499
500     $ cat jjb/requirements.txt
501     -e git+https://git.openstack.org/openstack-infra/jenkins-job-builder@1.4.0#egg=jenkins-job-builder
502
503 Installing JJB Manually
504 -----------------------
505
506 This section documents installing JJB from its manually cloned repository.
507
508 Note that `installing via pip <Installing JJB using pip_>`_ is typically simpler.
509
510 Checkout the version of JJB's source you'd like to build.
511
512 For example, using master:
513
514 .. code-block:: bash
515
516     $ git clone https://git.openstack.org/openstack-infra/jenkins-job-builder
517
518 Using a tag, like 1.4.0:
519
520 .. code-block:: bash
521
522     $ git clone https://git.openstack.org/openstack-infra/jenkins-job-builder
523     $ cd jenkins-job-builder
524     $ git checkout tags/1.4.0
525
526 Before actually installing JJB and its dependencies, make sure you've `created
527 and activated <Virtual Environments_>`_ a virtual environment for JJB.
528
529 .. code-block:: bash
530
531     $ mkvirtualenv jjb
532
533 You can then use JJB's `requirements.txt <jjb-requirements.txt_>`_ file to
534 install its
535 dependencies. Note that we're not using `sudo` to install as root, since we want
536 to make use of the venv we've configured for our current user.
537
538 .. code-block:: bash
539
540     # In the cloned JJB repo, with the desired version of the code checked out
541     (jjb)$ pip install -r requirements.txt
542
543 Then install JJB from the repo with:
544
545 .. code-block:: bash
546
547     (jjb)$ pip install .
548
549 To validate that JJB was successfully installed you can run this command:
550
551 .. code-block:: bash
552
553     (jjb)$ jenkins-jobs --version
554
555 JJB Docker Image
556 ----------------
557
558 `Docker <docker-docs_>`_ is an open platform used to create virtualized Linux containers
559 for shipping self-contained applications. Docker leverages LinuX Containers
560 \(LXC\) running on the same operating system as the host machine, whereas a
561 traditional VM runs an operating system over the host.
562
563 .. code-block:: bash
564
565     docker pull zxiiro/jjb-docker
566     docker run --rm -v ${PWD}:/jjb jjb-docker
567
568 This `Dockerfile <jjb-dockerfile_>`_ created the
569 `zxiiro/jjb-docker image <jjb-docker_>`_.
570 By default it will run:
571
572 .. code-block:: bash
573
574     jenkins-jobs test .
575
576 You'll need to use the `-v/--volume=[]` parameter to mount a directory
577 containing your YAML files, as well as a configured `jenkins.ini` file if you
578 wish to upload your jobs to the `Jenkins Sandbox`_.
579
580 Jenkins Job Templates
581 ---------------------
582
583 The OpenDaylight `RelEng/Builder <releng-builder-wiki_>`_ project provides
584 `jjb-templates`_ that can be used to define basic jobs.
585
586 The *Gerrit Trigger* listed in the jobs are keywords that can be used to
587 trigger the job to run manually by simply leaving a comment in Gerrit for the
588 patch you wish to trigger against.
589
590 All jobs have a default build-timeout value of 360 minutes (6 hrs) but can be
591 overrided via the opendaylight-infra-wrappers' build-timeout property.
592
593 .. raw:: html
594
595     <table class="table table-bordered">
596       <tr class="warning">
597         <td><b>Job Template</b><br/>{project}-distribution-{stream}</td>
598         <td><b>Gerrit Trigger</b><br/>test-distribution</td>
599       </tr>
600       <tr>
601         <td colspan="2">
602           This job builds a distrbution against your patch, passes distribution sanity test
603           and reports back the results to Gerrit. Leave a comment with trigger keyword above
604           to activate it for a particular patch.
605
606           This job is maintained by the <a href="https://wiki.opendaylight.org/view/Integration/Test">Integration/Test</a>
607           project.
608
609           <div class="admonition note">
610             <p class="first admonition-title">Note</p>
611             <p>
612               Running the "test-distribution" trigger will cause Jenkins to
613               remove it's existing vote if it's already -1 or +1'd a comment.
614               You will need to re-run your verify job (recheck) after running
615               this to get Jenkins to put back the correct vote.
616             </p>
617           </div>
618         </td>
619       </tr>
620
621       <tr class="warning">
622         <td><b>Job Template</b><br/>{project}-integration-{stream}</td>
623         <td></td>
624       </tr>
625       <tr>
626         <td colspan="2">
627           The Integration Job Template creates a job which runs when a project that your
628           project depends on is successfully built. This job type is basically the same
629           as a verify job except that it triggers from other Jenkins jobs instead of via
630           Gerrit review updates. The dependencies that triger integration jobs are listed
631           in your project.cfg file under the <b>DEPENDENCIES</b> variable.
632
633           If no dependencies are listed then this job type is disabled by default.
634         </td>
635       </tr>
636
637       <tr class="warning">
638         <td><b>Job Template</b><br/>{project}-merge-{stream}</td>
639         <td><b>Gerrit Trigger</b><br/>remerge</td>
640       </tr>
641       <tr>
642         <td colspan="2">
643           The Merge job template is similar to the Verify Job Template except
644           it will trigger once a Gerrit patch is merged into the repo. It
645           also automatically runs the Maven goals <b>source:jar</b> and
646           <b>javadoc:jar</b>.
647
648           This job will upload artifacts to OpenDaylight's
649           <a href="https://nexus.opendaylight.org">Nexus</a> on completion.
650         </td>
651       </tr>
652
653       <tr class="warning">
654         <td><b>Job Template</b><br/>{project}-sonar</td>
655         <td><b>Gerrit Trigger</b><br/>run-sonar</td>
656       </tr>
657       <tr>
658         <td colspan="2">
659           This job runs Sonar analysis and reports the results to
660           OpenDaylight's <a href="https://sonar.opendaylight.org">Sonar</a>
661           dashboard.
662
663           The Sonar Job Template creates a job which will run against the
664           master branch, or if BRANCHES are specified in the CFG file it will
665           create a job for the <b>First</b> branch listed.
666
667           <div class="admonition note">
668             <p class="first admonition-title">Note</p>
669             <p>
670               Running the "run-sonar" trigger will cause Jenkins to remove
671               its existing vote if it's already -1'd or +1'd a comment. You
672               will need to re-run your verify job (recheck) after running
673               this to get Jenkins to re-vote.
674             </p>
675           </div>
676         </td>
677       </tr>
678
679       <tr class="warning">
680         <td><b>Job Template</b><br/>{project}-validate-autorelease-{stream}</td>
681         <td><b>Gerrit Trigger</b><br/>recheck | reverify</td>
682       </tr>
683       <tr>
684         <td colspan="2">
685           This job runs the PROJECT-validate-autorelease-BRANCH job which is
686           used as a quick sanity test to ensure that a patch does not depend on
687           features that do not exist in the current release.
688
689           The <b>revalidate</b> trigger is useful in cases where a project's
690           verify job passed however validate failed due to infra problems or
691           intermittent issues. It will retrigger just the validate-autorelease
692           job.
693         </td>
694       </tr>
695
696       <tr class="warning">
697         <td><b>Job Template</b><br/>{project}-verify-{stream}-{maven}-{jdks}</td>
698         <td><b>Gerrit Trigger</b><br/>recheck | reverify</td>
699       </tr>
700       <tr>
701         <td colspan="2">
702             The Verify job template creates a Gerrit Trigger job that will
703             trigger when a new patch is submitted to Gerrit.
704         </td>
705       </tr>
706
707       <tr class="warning">
708         <td><b>Job Template</b><br/>{project}-verify-node-{stream}</td>
709         <td><b>Gerrit Trigger</b><br/>recheck | reverify</td>
710       </tr>
711       <tr>
712         <td colspan="2">
713           This job template can be used by a project that is NodeJS based. It
714           simply installs a python virtualenv and uses that to install nodeenv
715           which is then used to install another virtualenv for nodejs. It then
716           calls <b>npm install</b> and <b>npm test</b> to run the unit tests.
717           When  using this template you need to provide a {nodedir} and
718           {nodever} containing the directory relative to the project root
719           containing the nodejs package.json and version of node you wish to
720           run tests with.
721         </td>
722       </tr>
723
724       <tr class="warning">
725         <td><b>Job Template</b><br/>{project}-verify-python-{stream}</td>
726         <td><b>Gerrit Trigger</b><br/>recheck | reverify</td>
727       </tr>
728       <tr>
729         <td colspan="2">
730           This job template can be used by a project that contains Python. It
731           simply installs a Python virtualenv and uses tox to run the tests
732           defined in the project's tox.ini file. If the tox.ini is anywhere
733           other than the project's repo root, the path to its directory
734           relative to the project's repo root should be passed as {toxdir}.
735         </td>
736       </tr>
737
738       <tr class="warning">
739         <td><b>Job Template</b><br/>integration-patch-test-{stream}</td>
740         <td><b>Gerrit Trigger</b><br/>test-integration</td>
741       </tr>
742       <tr>
743         <td colspan="2">
744           This job runs a full integration test suite against your patch and
745           reports back the results to Gerrit. Leave a comment with trigger
746           keyword above to activate it for a particular patch.
747
748           It then spawns the list of jobs in csit-list defined
749           <a href="https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jjb/integration/integration-test-jobs.yaml">here</a>.
750
751           This job is maintained by the <a href="https://wiki.opendaylight.org/view/Integration/Test">Integration/Test</a>
752           project.
753
754           <div class="admonition note">
755             <p class="first admonition-title">Note</p>
756             <p>
757               Running the "test-integration" trigger will cause Jenkins to remove
758               it's existing vote if it's already -1 or +1'd a comment. You will need
759               to re-run your verify job (recheck) after running this to get Jenkins
760               to put back the correct vote.
761             </p>
762           </div>
763
764           Some considerations when using this job:
765           <ul>
766             <li>
767               The patch test verification takes some time (~2 hours) + consumes a lot of
768               resources so it is not meant to be used for every patch.
769             </li>
770             <li>
771               The system tests for master patches will fail most of the times because both
772               code and test are unstable during the release cycle (should be good by the
773               end of the cycle).
774             </li>
775             <li>
776               Because of the above, patch test results typically have to be interpreted by
777               system test experts. The <a href="https://wiki.opendaylight.org/view/Integration/Test">Integration/Test</a>
778               project can help with that.
779             </li>
780         </td>
781       </tr>
782     </table>
783
784 Maven Properties
785 ----------------
786
787 We provide a properties which your job can take advantage of if you want to do
788 something different depending on the job type that is run. If you create a
789 profile that activates on a property listed blow. The JJB templated jobs will
790 be able to activate the profile during the build to run any custom code you
791 wish to run in your project.
792
793 .. code-block:: bash
794
795     -Dmerge   : This flag is passed in our Merge job and is equivalent to the
796                 Maven property
797                 <merge>true</merge>.
798     -Dsonar   : This flag is passed in our Sonar job and is equivalent to the
799                 Maven property
800                 <sonar>true</sonar>.
801
802 Jenkins Sandbox
803 ---------------
804
805 The `jenkins-sandbox`_ instance's purpose is to allow projects to test their JJB
806 setups before merging their code over to the RelEng master silo. It is
807 configured similarly to the master instance, although it cannot publish
808 artifacts or vote in Gerrit.
809
810 If your project requires access to the sandbox please open an OpenDaylight
811 Helpdesk ticket (<helpdesk@opendaylight.org>) and provide your ODL ID.
812
813 Notes Regarding the Sandbox
814 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
815
816 * Jobs are automatically deleted every Saturday at 08:00 UTC
817 * Committers can login and configure Jenkins jobs in the sandbox directly
818   (unlike with the master silo)
819 * Sandbox configuration mirrors the master silo when possible
820 * Sandbox jobs can NOT upload artifacts to Nexus
821 * Sandbox jobs can NOT vote on Gerrit
822
823 Configuration
824 ^^^^^^^^^^^^^
825
826 Make sure you have Jenkins Job Builder [properly installed](#jjb_install).
827
828 If you do not already have access, open an OpenDaylight Helpdesk ticket
829 (<helpdesk@opendaylight.org>) to request access to ODL's sandbox instance.
830 Integration/Test (`integration-test-wiki`_) committers have access by default.
831
832 JJB reads user-specific configuration from a `jenkins.ini`_. An
833 example is provided by releng/builder at `example-jenkins.ini`_.
834
835 .. code-block:: bash
836
837     # If you don't have RelEng/Builder's repo, clone it
838     $ git clone https://git.opendaylight.org/gerrit/p/releng/builder.git
839     # Make a copy of the example JJB config file (in the builder/ directory)
840     $ cp jenkins.ini.example jenkins.ini
841     # Edit jenkins.ini with your username, API token and ODL's sandbox URL
842     $ cat jenkins.ini
843     <snip>
844     [jenkins]
845     user=<your ODL username>
846     password=<your ODL Jenkins sandbox API token>
847     url=https://jenkins.opendaylight.org/sandbox
848     <snip>
849
850 To get your API token, `login to the Jenkins **sandbox** instance
851 <jenkins-sandbox-login_>`_ (*not
852 the main master Jenkins instance, different tokens*), go to your user page (by
853 clicking on your username, for example), click "Configure" and then "Show API
854 Token".
855
856 Manual Method
857 ^^^^^^^^^^^^^
858
859 If you `installed JJB locally into a virtual environment
860 <Installing Jenkins Job Builder_>`_,
861 you should now activate that virtual environment to access the `jenkins-jobs`
862 executable.
863
864 .. code-block:: bash
865
866     $ workon jjb
867     (jjb)$
868
869 You'll want to work from the root of the RelEng/Builder repo, and you should
870 have your `jenkins.ini` file [properly configured](#sandbox_config).
871
872 Testing Jobs
873 ^^^^^^^^^^^^
874
875 It's good practice to use the `test` command to validate your JJB files before
876 pushing them.
877
878 .. code-block:: bash
879
880     jenkins-jobs --conf jenkins.ini test jjb/ <job-name>
881
882 If the job you'd like to test is a template with variables in its name, it
883 must be manually expanded before use. For example, the commonly used template
884 `{project}-csit-verify-1node-{functionality}` might expand to
885 `ovsdb-csit-verify-1node-netvirt`.
886
887 .. code-block:: bash
888
889     jenkins-jobs --conf jenkins.ini test jjb/ ovsdb-csit-verify-1node-netvirt
890
891 Successful tests output the XML description of the Jenkins job described by
892 the specified JJB job name.
893
894 Pushing Jobs
895 ^^^^^^^^^^^^
896
897 Once you've `configured your \`jenkins.ini\` <Configuration_>`_ and `verified your
898 JJB jobs <Testing Jobs_>`_ produce valid XML descriptions of Jenkins jobs you
899 can push them to the Jenkins sandbox.
900
901 .. important::
902
903     When pushing with `jenkins-jobs`, a log message with the number
904     of jobs you're pushing will be issued, typically to stdout.
905     **If the number is greater than 1** (or the number of jobs you
906     passed to the command to push) then you are pushing too many
907     jobs and should **`ctrl+c` to cancel the upload**. Else you will
908     flood the system with jobs.
909
910     .. code-block:: bash
911
912         INFO:jenkins_jobs.builder:Number of jobs generated:  1
913
914     **Failing to provide the final `<job-name>` param will push all
915     jobs!**
916
917     .. code-block:: bash
918
919         # Don't push all jobs by omitting the final param! (ctrl+c to abort)
920         jenkins-jobs --conf jenkins.ini update jjb/ <job-name>
921
922 Running Jobs
923 ^^^^^^^^^^^^
924
925 Once you have your Jenkins job configuration `pushed to the
926 Sandbox <Pushing Jobs_>`_ you can trigger it to run.
927
928 Find your newly-pushed job on the `Sandbox's web UI <jenkins-sandbox_>`_. Click
929 on its name to see the job's details.
930
931 Make sure you're `logged in <jenkins-sandbox-login_>`_ to the Sandbox.
932
933 Click "Build with Parameters" and then "Build".
934
935 Wait for your job to be scheduled and run. Click on the job number to see
936 details, including console output.
937
938 Make changes to your JJB configuration, re-test, re-push and re-run until
939 your job is ready.
940
941 Docker Method
942 ^^^^^^^^^^^^^
943
944 If `using Docker <JJB Docker image_>`_:
945
946 .. code-block:: bash
947
948     # To test
949     docker run --rm -v ${PWD}:/jjb zxiiro/jjb-docker
950
951 .. important::
952
953     When pushing with `jenkins-jobs`, a log message with
954     the number of jobs you're pushing will be issued, typically to stdout.
955     **If the number is greater than 1** (or the number of jobs you passed to
956     the command to push) then you are pushing too many jobs and should **`ctrl+c`
957     to cancel the upload**. Else you will flood the system with jobs.
958
959     .. code-block:: bash
960
961           INFO:jenkins_jobs.builder:Number of jobs generated:  1
962
963     **Failing to provide the final `<job-name>` param will push all jobs!**
964
965     .. code-block:: bash
966
967         # To upload jobs to the sandbox
968         # Please ensure that you include a configured jenkins.ini in your volume mount
969         # Making sure not to push more jobs than expected, ctrl+c to abort
970         docker run --rm -v ${PWD}:/jjb zxiiro/jjb-docker jenkins-jobs --conf jenkins.ini update . openflowplugin-csit-periodic-1node-cds-longevity-only-master
971
972 .. _docker-docs: https://www.docker.com/whatisdocker/
973 .. _example-jenkins.ini: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jenkins.ini.example
974 .. _integration-test-wiki: https://wiki.opendaylight.org/view/Integration/Test
975 .. _jenkins-master: https://jenkins.opendaylight.org/releng
976 .. _jenkins-sandbox: https://jenkins.opendaylight.org/sandbox
977 .. _jenkins-sandbox-login: https://jenkins.opendaylight.org/sandbox/login
978 .. _jenkins.ini: http://docs.openstack.org/infra/jenkins-job-builder/execution.html#configuration-file
979 .. _jjb-autoupdate-project.py: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=scripts/jjb-autoupdate-project.py
980 .. _jjb-docker: https://hub.docker.com/r/zxiiro/jjb-docker/
981 .. _jjb-dockerfile: https://github.com/zxiiro/jjb-docker/blob/master/Dockerfile
982 .. _jjb-docs: http://ci.openstack.org/jenkins-job-builder/
983 .. _jjb-init-project.py: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=scripts/jjb-init-project.py
984 .. _jjb-repo: https://github.com/openstack-infra/jenkins-job-builder
985 .. _jjb-requirements.txt: https://github.com/openstack-infra/jenkins-job-builder/blob/master/requirements.txt
986 .. _jjb-templates: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=tree;f=jjb
987 .. _odl-jjb-requirements.txt: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jjb/requirements.txt
988 .. _odl-nexus: https://nexus.opendaylight.org
989 .. _odl-sonar: https://sonar.opendaylight.org
990 .. _python-virtualenv: https://virtualenv.readthedocs.org/en/latest/
991 .. _python-virtualenvwrapper: https://virtualenvwrapper.readthedocs.org/en/latest/
992 .. _releng-wiki: https://wiki.opendaylight.org/view/RelEng:Main
993 .. _releng-builder-gerrit: https://git.opendaylight.org/gerrit/#/admin/projects/releng/builder
994 .. _releng-builder-repo: https://git.opendaylight.org/gerrit/gitweb?p=releng%2Fbuilder.git;a=summary
995 .. _releng-builder-wiki: https://wiki.opendaylight.org/view/RelEng/Builder
996 .. _streams-design-background: https://lists.opendaylight.org/pipermail/release/2015-July/003139.html
997 .. _spinup-scripts: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=tree;f=jenkins-scripts
998 .. _spinup-scripts-basic_settings.sh: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jenkins-scripts/basic_settings.sh
999 .. _spinup-scripts-controller.sh: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jenkins-scripts/controller.sh
1000 .. _vagrant-basic-java-node: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=tree;f=vagrant/basic-java-node
1001 .. _vagrant-definitions: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=tree;f=vagrant