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