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