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