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