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