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