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