Editing devstack daily job template
[releng/builder.git] / src / site / markdown / jenkins.md
1 The [Release Engineering project][0] consolidates the Jenkins jobs from
2 project-specific VMs to a single Jenkins server. Each OpenDaylight project
3 has a tab for their jobs on the [RelEng Jenkins server][3]. The system utilizes
4 [Jenkins Job Builder][11] \(JJB\) for the creation and management of the
5 Jenkins jobs.
6
7 Sections:
8
9 * [Jenkins Master](#jenkins_master)
10 * [Build Slaves](#build_slaves)
11 * [Creating Jenkins Jobs](#creating_jenkins_jobs)
12     * [Getting Jenkins Job Builder](#jjb)
13         * [Installing Jenkins Job Builder](#jjb_install)
14             * [Virtual Environments](#jjb_install_venv)
15             * [Installing JJB using pip](#jjb_install_pip)
16             * [Installing JJB Manually](#jjb_install_manual)
17         * [Jenkins Job Builder Docker Image](#jjb_install_docker)
18     * [Jenkins Job Templates](#jjb_templates)
19     * [Jenkins Job Basic Configuration](#jjb_basic_configuration)
20     * [Jenkins Job Maven Properties](#jjb_maven_properties)
21 * [Jenkins Sandbox](#jenkins_sandbox)
22     * [Configuration](#sandbox_config)
23     * [Manual Method](#jjb_use_manual)
24     * [Docker Method](#jjb_use_docker)
25
26 # <a name="jenkins_master">Jenkins Master</a>
27
28 The [Jenkins master server][3] is the home for all project's Jenkins jobs. All
29 maintenance and configuration of these jobs must be done via JJB through the
30 [RelEng repo][4]. Project contributors can no longer edit the Jenkins jobs
31 directly on the server.
32
33 # <a name="build_slaves">Build Slaves</a>
34
35 The Jenkins jobs are run on build slaves (executors) which are created on an
36 as-needed basis. If no idle build slaves are available a new VM is brought
37 up. This process can take up to 2 minutes. Once the build slave has finished a
38 job, it will remain online for 45 minutes before shutting down. Subsequent
39 jobs will use an idle build slave if available.
40
41 Our Jenkins master supports many types of dynamic build slaves. If you are
42 creating custom jobs then you will need to have an idea of what type of slaves
43 are available. The following are the current slave types and descriptions.
44 Slave Template Names are needed for jobs that take advantage of multiple
45 slaves as they must be specifically called out by template name instead of
46 label.
47
48 ## Adding New Components to the Slaves
49
50 If your project needs something added to one of the slaves used during build
51 and test you can help us get things added faster by doing one of the following:
52
53 * Submit a patch to RelEng/Builder for the [Jenkins spinup script][5] that
54   configures your new piece of software.
55 * Submit a patch to RelEng/Builder for the [Vagrant template's bootstrap.sh][6]
56   that configures your new piece of software.
57
58 Going the first route will be faster in the short term as we can inspect the
59 changes and make test modifications in the sandbox to verify that it works.
60
61 The second route, however, is better for the community as a whole as it will
62 allow others that utilize our Vagrant setups to replicate our systems more
63 closely. It is, however, more time consuming as an image snapshot needs to be
64 created based on the updated Vagrant definition before it can be attached to
65 the sandbox for validation testing.
66
67 In either case, the changes must be validated in the sandbox with tests to
68 make sure that we don't break current jobs and that the new software features
69 are operating as intended. Once this is done the changes will be merged and
70 the updates applied to the RelEng Jenkins production silo.
71
72 Please note that the combination of a Vagrant slave snapshot and a Jenkins
73 spinup script is what defines a given slave. For instance, a slave may be
74 defined by the [`releng/builder/vagrant/basic-java-node/`][8] Vagrant definition
75 and the [`releng/builder/jenkins-script/controller.sh`][9] Jenkins spinup script
76 (as the dynamic\_controller slave is). The pair provides the full definition of
77 the realized slave. Jenkins starts a slave using the last-spun Vagrant snapshot
78 for the specified definition. Once the base Vagrant instance is online Jenkins
79 checks out the RelEng/Builder repo on it and executes two scripts. The first is
80 [`basic_settings.sh`][10], which is a baseline for all of the slaves. The second is
81 the specialized spinup script, which handles any system updates, new software
82 installs or extra environment tweaks that don't make sense in a snapshot. After
83 all of these scripts have executed Jenkins will finally attach the slave as an
84 actual slave and start handling jobs on it.
85
86 ### Pool: Rackspace - Docker
87
88 <table class="table table-bordered">
89   <tr>
90     <td><b>Jenkins Label</b><br/> dynamic_docker</td>
91     <td><b>Slave Template name</b><br/> rk-f20-docker</td>
92     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/ovsdb-docker</td>
93     <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/docker.sh</td>
94   </tr>
95   <tr>
96     <td colspan="4">
97       A Fedora 20 system that is configured with OpenJDK 1.7 (aka Java7) and
98       Docker. This system was originally custom built for the test needs of
99       the OVSDB project but other projects have expressed interest in using
100       it.
101     </td>
102   </tr>
103 </table>
104
105 ### Pool: Rackspace DFW
106
107 <table class="table table-bordered">
108   <tr>
109     <td><b>Jenkins Label</b><br/> dynamic_verify</td>
110     <td><b>Slave Template name</b><br/> rk-c-el65-build</td>
111     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/basic-builder</td>
112     <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/builder.sh</td>
113   </tr>
114   <tr>
115     <td colspan="4">
116       A CentOS 6 build slave. This system has OpenJDK 1.7 (Java7) and OpenJDK
117       1.8 (Java8) installed on it along with all the other components and
118       libraries needed for building any current OpenDaylight project. This is
119       the label that is used for all basic -verify and -daily- builds for
120       projects.
121     </td>
122   </tr>
123 </table>
124
125 <table class="table table-bordered">
126   <tr>
127     <td><b>Jenkins Label</b><br/> dynamic_merge</td>
128     <td><b>Slave Template name</b><br/> rk-c-el65-build</td>
129     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/basic-builder</td>
130     <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/builder.sh</td>
131   </tr>
132   <tr>
133     <td colspan="4">
134       See dynamic_verify (same image on the back side). This is the label that
135       is used for all basic -merge and -integration- builds for projects.
136     </td>
137   </tr>
138 </table>
139
140 ### Pool: Rackspace DFW - Devstack
141
142 <table class="table table-bordered">
143   <tr>
144     <td><b>Jenkins Label</b><br/> dynamic_devstack</td>
145     <td><b>Slave Template name</b><br/> rk-c7-devstack</td>
146     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/ovsdb-devstack</td>
147     <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/devstack.sh</td>
148   </tr>
149   <tr>
150     <td colspan="4">
151       A CentOS 7 system purpose built for doing OpenStack testing using
152       DevStack. This slave is primarily targeted at the needs of the OVSDB
153       project. It has OpenJDK 1.7 (aka Java7) and other basic DevStack related
154       bits installed.
155     </td>
156   </tr>
157 </table>
158
159 ### Pool: Rackspace DFW - Integration
160
161 <table class="table table-bordered">
162   <tr>
163     <td><b>Jenkins Label</b><br/> dynamic_robot</td>
164     <td><b>Slave Template name</b><br/> rk-c-el6-robot</td>
165     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/integration-robotframework</td>
166     <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/robot.sh</td>
167   </tr>
168   <tr>
169     <td colspan="4">
170       A CentOS 6 slave that is configured with OpenJDK 1.7 (Java7) and all the
171       current packages used by the integration project for doing robot driven
172       jobs. If you are executing robot framework jobs then your job should be
173       using this as the slave that you are tied to. This image does not
174       contain the needed libraries for building components of OpenDaylight,
175       only for executing robot tests.
176     </td>
177   </tr>
178 </table>
179
180 ### Pool: Rackspace DFW - Integration Dynamic Lab
181
182 <table class="table table-bordered">
183   <tr>
184     <td><b>Jenkins Label</b><br/> dynamic_controller</td>
185     <td><b>Slave Template name</b><br/> rk-c-el6-java</td>
186     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/basic-java-node</td>
187     <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/controller.sh</td>
188   </tr>
189   <tr>
190     <td colspan="4">
191       A CentOS 6 slave that has the basic OpenJDK 1.7 (Java7) installed and is
192       capable of running the controller, not building.
193     </td>
194   </tr>
195 </table>
196
197 <table class="table table-bordered">
198   <tr>
199     <td><b>Jenkins Label</b><br/> dynamic_java</td>
200     <td><b>Slave Template name</b><br/> rk-c-el6-java</td>
201     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/basic-java-node</td>
202     <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/controller.sh</td>
203   </tr>
204   <tr>
205     <td colspan="4">
206       See dynamic_controller as it is currently the same image.
207     </td>
208   </tr>
209 </table>
210
211 <table class="table table-bordered">
212   <tr>
213     <td><b>Jenkins Label</b><br/> dynamic_mininet</td>
214     <td><b>Slave Template name</b><br/> rk-c-el6-mininet</td>
215     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/basic-mininet-node</td>
216     <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/mininet.sh</td>
217   </tr>
218   <tr>
219     <td colspan="4">
220       A CentOS 6 image that has mininet, openvswitch v2.0.x, netopeer and
221       PostgreSQL 9.3 installed. This system is targeted at playing the role of
222       a mininet system for integration tests. Netopeer is installed as it is
223       needed for various tests by Integration. PostgreSQL 9.3 is installed as
224       the system is also capable of being used as a VTN project controller and
225       VTN requires PostgreSQL 9.3.
226     </td>
227   </tr>
228 </table>
229
230 <table class="table table-bordered">
231   <tr>
232     <td><b>Jenkins Label</b><br/> dynamic_mininet_fedora</td>
233     <td><b>Slave Template name</b><br/> rk-f21-mininet</td>
234     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/basic-mininet-fedora-node</td>
235     <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/mininet-fedora.sh</td>
236   </tr>
237   <tr>
238     <td colspan="4">
239       Basic Fedora 21 system with ovs v2.3.x and mininet 2.2.1
240     </td>
241   </tr>
242 </table>
243
244 <table class="table table-bordered">
245   <tr>
246     <td><b>Jenkins Label</b><br/> ubuntu_mininet</td>
247     <td><b>Slave Template name</b><br/> ubuntu-trusty-mininet</td>
248     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/ubuntu-mininet</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.0.2 and mininet 2.1.0
254     </td>
255   </tr>
256 </table>
257
258 <table class="table table-bordered">
259   <tr>
260     <td><b>Jenkins Label</b><br/> ubuntu_mininet_ovs_23</td>
261     <td><b>Slave Template name</b><br/> ubuntu-trusty-mininet-ovs-23</td>
262     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/ubuntu-mininet-ovs-23</td>
263     <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/mininet-ubuntu.sh</td>
264   </tr>
265   <tr>
266     <td colspan="4">
267       Basic Ubuntu system with ovs 2.3 and mininet 2.2.1
268     </td>
269   </tr>
270 </table>
271
272 ### Pool: Rackspace DFW - Matrix
273
274 <table class="table table-bordered">
275   <tr>
276     <td><b>Jenkins Label</b><br/> matrix_master</td>
277     <td><b>Slave Template name</b><br/> rk-c-el6-matrix</td>
278     <td><b>Vagrant Definition</b><br/> releng/builder/vagrant/basic-java-node</td>
279     <td><b>Spinup Script</b><br/> releng/builder/jenkins-scripts/matrix.sh</td>
280   </tr>
281   <tr>
282     <td colspan="4">
283       This is a very minimal system that is designed to spin up with 2 build
284       instances on it. The purpose is to have a location that is not the
285       Jenkins master itself for jobs that are executing matrix operations
286       since they need a director location. This image should not be used for
287       anything but tying matrix jobs before the matrx defined label ties.
288     </td>
289   </tr>
290 </table>
291
292 # <a name="creating_jenkins_jobs">Creating Jenkins Jobs</a>
293
294 Jenkins Job Builder takes simple descriptions of Jenkins jobs in YAML format
295 and uses them to configure Jenkins.
296
297 * [Jenkins Job Builder][11] \(JJB\) documentation
298 * [RelEng/Builder Gerrit][12]
299 * [RelEng/Builder Git repository][13]
300
301 ## <a name="jjb">Getting Jenkins Job Builder</a>
302
303 OpenDaylight uses Jenkins Job Builder to translate our in-repo YAML job
304 configuration into job descriptions suitable for consumption by Jenkins.
305 When testing new Jenkins Jobs in the [sandbox](#jenkins_sandbox), you'll
306 need to use the `jenkins-jobs` executable to translate a set of jobs into
307 their XML descriptions and upload them to the sandbox Jenkins server.
308
309 We document [installing](#jjb_install) `jenkins-jobs` below. We also provide
310 a [pre-built Docker image](#jjb_docker) with `jenkins-jobs` already installed.
311
312 ### <a name="jjb_install">Installing Jenkins Job Builder</a>
313
314 For users who aren't already experienced with Docker or otherwise don't want
315 to use our [pre-built JJB Docker image](#jjb_docker), installing JJB into a
316 virtual environment is an equally good option.
317
318 We recommend using [pip](#jjb_install_pip) to assist with JJB installs, but we
319 also document [installing from a git repository manually](#jjb_install_manual).
320 For both, we [recommend][17] using [virtual environments](#jjb_install_venv)
321 to isolate JJB and its dependencies.
322
323 The [`builder/jjb/requirements.txt`][33] file contains the currently
324 recommended JJB version. Because JJB is fairly unstable, it may be necessary
325 to debug things by installing different versions. This is documented for both
326 [pip-assisted](#jjb_install_pip) and [manual](#jjb_install_manual) installs.
327
328 #### <a name="jjb_install_venv">Virtual Environments</a>
329
330 For both [pip-assisted](#jjb_install_pip) and [manual](#jjb_install_manual) JJB
331 installs, we [recommend using virtual environments][17] to manage JJB and its
332 Python dependencies. The [Virtualenvwrapper][30] tool can help you do so.
333
334 There are good docs for [installing Virtualenvwrapper][31]. On Linux systems
335 with pip (typical), they amount to:
336
337     sudo pip install virtualenvwrapper
338
339 A virtual environment is simply a directory that you install Python programs
340 into and then append to the front of your path, causing those copies to be
341 found before any system-wide versions.
342
343 Create a new virtual environment for JJB.
344
345     # Virtaulenvwrapper uses this dir for virtual environments
346     $ echo $WORKON_HOME
347     /home/daniel/.virtualenvs
348     # Make a new virtual environment
349     $ mkvirtualenv jjb
350     # A new venv dir was created
351     (jjb)$ ls -rc $WORKON_HOME | tail -n 1
352     jjb
353     # The new venv was added to the front of this shell's path
354     (jjb)$ echo $PATH
355     /home/daniel/.virtualenvs/jjb/bin:<my normal path>
356     # Software installed to venv, like pip, is found before system-wide copies
357     (jjb)$ command -v pip
358     /home/daniel/.virtualenvs/jjb/bin/pip
359
360 With your virtual environment active, you should install JJB. Your install will
361 be isolated to that virtual environment's directory and only visible when the
362 virtual environment is active.
363
364 You can easily leave and return to your venv. Make sure you activate it before
365 each use of JJB.
366
367     (jjb)$ deactivate
368     $ command -v jenkins-jobs
369     # No jenkins-jobs executable found
370     $ workon jjb
371     (jjb)$ command -v jenkins-jobs
372     $WORKON_HOME/jjb/bin/jenkins-jobs
373
374 #### <a name="jjb_install_pip">Installing JJB using pip</a>
375
376 The recommended way to install JJB is via pip.
377
378 First, clone the latest version of the [`releng/builder`][4] repo.
379
380     $ git clone https://git.opendaylight.org/gerrit/p/releng/builder.git
381
382 Before actually installing JJB and its dependencies, make sure you've [created
383 and activated](#jjb_install_venv) a virtual environment for JJB.
384
385     $ mkvirtualenv jjb
386
387 The recommended version of JJB to install is the version specified in the
388 [`builder/jjb/requirements.txt`][33] file.
389
390     # From the root of the releng/builder repo
391     (jjb)$ pip install -r jjb/requirements.txt
392
393 To validate that JJB was successfully installed you can run this command:
394
395     (jjb)$ jenkins-jobs --version
396
397 To change the version of JJB specified by [`builder/jjb/requirements.txt`][33]
398 to install from the latest commit to the master branch of JJB's git repository:
399
400     $ cat jjb/requirements.txt
401     -e git+https://git.openstack.org/openstack-infra/jenkins-job-builder#egg=jenkins-job-builder
402
403 To install from a tag, like 1.4.0:
404
405     $ cat jjb/requirements.txt
406     -e git+https://git.openstack.org/openstack-infra/jenkins-job-builder@1.4.0#egg=jenkins-job-builder
407
408 #### <a name="jjb_install_manual">Installing JJB Manually</a>
409
410 This section documents installing JJB from its manually cloned repository.
411
412 Note that [installing via pip](#jjb_install_pip) is typically simpler.
413
414 Checkout the version of JJB's source you'd like to build.
415
416 For example, using master:
417
418     $ git clone https://git.openstack.org/openstack-infra/jenkins-job-builder
419
420 Using a tag, like 1.4.0:
421
422     $ git clone https://git.openstack.org/openstack-infra/jenkins-job-builder
423     $ cd jenkins-job-builder
424     $ git checkout tags/1.4.0
425
426 Before actually installing JJB and its dependencies, make sure you've [created
427 and activated](#jjb_install_venv) a virtual environment for JJB.
428
429     $ mkvirtualenv jjb
430
431 You can then use [JJB's `requirements.txt`][20] file to install its
432 dependencies. Note that we're not using `sudo` to install as root, since we want
433 to make use of the venv we've configured for our current user.
434
435     # In the cloned JJB repo, with the desired version of the code checked out
436     (jjb)$ pip install -r requirements.txt
437
438 Then install JJB from the repo with:
439
440     (jjb)$ pip install .
441
442 To validate that JJB was successfully installed you can run this command:
443
444     (jjb)$ jenkins-jobs --version
445
446 ### <a name="jjb_install_docker">JJB Docker Image</a>
447
448 [Docker][14] is an open platform used to create virtualized Linux containers
449 for shipping self-contained applications. Docker leverages LinuX Containers
450 \(LXC\) running on the same operating system as the host machine, whereas a
451 traditional VM runs an operating system over the host.
452
453     docker pull zxiiro/jjb-docker
454     docker run --rm -v ${PWD}:/jjb jjb-docker
455
456 [This Dockerfile][15] created the [zxiiro/jjb-docker image][29]. By default it
457 will run:
458
459     jenkins-jobs test .
460
461 You'll need to use the `-v/--volume=[]` parameter to mount a directory
462 containing your YAML files, as well as a configured `jenkins.ini` file if you
463 wish to upload your jobs to the [sandbox](#jenkins_sandbox).
464
465 ## <a name="jjb_templates">Jenkins Job Templates</a>
466
467 The OpenDaylight [RelEng/Builder][21] project provides [JJB job templates][2]
468 that can be used to define basic jobs.
469
470 ### Verify Job Template
471
472 Trigger: **recheck**
473
474 The Verify job template creates a Gerrit Trigger job that will trigger when a
475 new patch is submitted to Gerrit.
476
477 Verify jobs can be retriggered in Gerrit by leaving a comment that says
478 **recheck**.
479
480 ### Merge Job Template
481
482 Trigger: **remerge**
483
484 The Merge job template is similar to the Verify Job Template except it will
485 trigger once a Gerrit patch is merged into the repo. It also automatically
486 runs the Maven goals **source:jar** and **javadoc:jar**.
487
488 This job will upload artifacts to [OpenDaylight's Nexus][22] on completion.
489
490 Merge jobs can be retriggered in Gerrit by leaving a comment that says
491 **remerge**.
492
493 ### Daily Job Template
494
495 The Daily (or Nightly) Job Template creates a job which will run on a build on
496 a Daily basis as a sanity check to ensure the build is still working day to
497 day.
498
499 ### Sonar Job Template
500
501 Trigger: **run-sonar**
502
503 This job runs Sonar analysis and reports the results to [OpenDaylight's Sonar
504 dashboard][23].
505
506 **Note:** Running the "run-sonar" trigger will cause Jenkins to remove its
507 existing vote if it's already -1'd or +1'd a comment. You will need to re-run
508 your verify job (recheck) after running this to get Jenkins to re-vote.
509
510 The Sonar Job Template creates a job which will run against the master branch,
511 or if BRANCHES are specified in the CFG file it will create a job for the
512 **First** branch listed.
513
514 ### Integration Job Template
515
516 The Integration Job Template creates a job which runs when a project that your
517 project depends on is successfully built. This job type is basically the same
518 as a verify job except that it triggers from other Jenkins jobs instead of via
519 Gerrit review updates. The dependencies that triger integration jobs are listed
520 in your project.cfg file under the **DEPENDENCIES** variable.
521
522 If no dependencies are listed then this job type is disabled by default.
523
524 ### <a name="distribution_test_job">Distribution Test Job</a>
525
526 Trigger: **test-distribution**
527
528 This job builds a distrbution against your patch, passes distribution sanity test
529 and reports back the results to Gerrit. Leave a comment with trigger keyword above
530 to activate it for a particular patch.
531
532 This job is maintained by the [Integration/Test][1] project.
533
534 **Note:** Running the "test-distribution" trigger will cause Jenkins to remove
535 it's existing vote if it's already -1 or +1'd a comment. You will need to
536 re-run your verify job (recheck) after running this to get Jenkins to put back
537 the correct vote.
538
539 ### <a name="patch_test_job">Patch Test Job</a>
540
541 Trigger: **test-integration**
542
543 This job runs a full integration test suite against your patch and reports
544 back the results to Gerrit. Leave a comment with trigger keyword above to activate it
545 for a particular patch.
546
547 This job is maintained by the [Integration/Test][1] project.
548
549 **Note:** Running the "test-integration" trigger will cause Jenkins to remove
550 it's existing vote if it's already -1 or +1'd a comment. You will need to
551 re-run your verify job (recheck) after running this to get Jenkins to put back
552 the correct vote.
553
554 Some considerations when using this job:
555
556 * The patch test verification takes some time (~2 hours) + consumes a lot of
557   resources so it is not meant to be used for every patch.
558 * The system tests for master patches will fail most of the times because both
559   code and test are unstable during the release cycle (should be good by the
560   end of the cycle).
561 * Because of the above, patch test results typically have to be interpreted by
562   system test experts. The [Integration/Test][1] project can help with that.
563
564
565 ### Autorelease Validate Job
566
567 Trigger: **revalidate**
568
569 This job runs the PROJECT-validate-autorelease-BRANCH job which is used as a
570 quick sanity test to ensure that a patch does not depend on features that do
571 not exist in the current release.
572
573 The **revalidate** trigger is useful in cases where a project's verify job
574 passed however validate failed due to infra problems or intermittent issues.
575 It will retrigger just the validate-autorelease job.
576
577 ## <a name="jjb_basic_configuration">Basic Job Configuration</a>
578
579 To create jobs based on existing [templates](#jjb_templates), use the
580 [`jjb-init-project.py`][24] helper script. When run from the root of
581 [RelEng/Builder's repo][13], it will produce a file in
582 `jjb/<project>/<project>.yaml` containing your project's base template.
583
584     $ python scripts/jjb-init-project.py --help
585     usage: jjb-init-project.py [-h] [-c CONF] [-d DEPENDENCIES] [-t TEMPLATES]
586                                [-s STREAMS] [-p POM] [-g MVN_GOALS] [-o MVN_OPTS]
587                                [-a ARCHIVE_ARTIFACTS]
588                                project
589
590     positional arguments:
591       project               project
592
593     optional arguments:
594       -h, --help            show this help message and exit
595       -c CONF, --conf CONF  Config file
596       -d DEPENDENCIES, --dependencies DEPENDENCIES
597                             Project dependencies A comma-seperated (no spaces)
598                             list of projects your project depends on. This is used
599                             to create an integration job that will trigger when a
600                             dependent project-merge job is built successfully.
601                             Example: aaa,controller,yangtools
602       -t TEMPLATES, --templates TEMPLATES
603                             Job templates to use
604       -s STREAMS, --streams STREAMS
605                             Release streams to fill with default options
606       -p POM, --pom POM     Path to pom.xml to use in Maven build (Default:
607                             pom.xml
608       -g MVN_GOALS, --mvn-goals MVN_GOALS
609                             Maven Goals
610       -o MVN_OPTS, --mvn-opts MVN_OPTS
611                             Maven Options
612       -a ARCHIVE_ARTIFACTS, --archive-artifacts ARCHIVE_ARTIFACTS
613                             Comma-seperated list of patterns of artifacts to
614                             archive on build completion. See:
615                             http://ant.apache.org/manual/Types/fileset.html
616
617 If all your project requires is the basic verify, merge, and daily jobs then
618 using the job template should be all you need to configure for your jobs.
619
620 ### Auto-Update Job Templates
621
622 The first line of the job YAML file produced by the [init script][24] will
623 contain the words `# REMOVE THIS LINE IF...`. Leaving this line will allow the
624 RelEng/Builder [auto-update script][25] to maintain this file for your project,
625 should the base templates ever change. It is a good idea to leave this line if
626 you do not plan to create any complex jobs outside of the provided template.
627
628 However, if your project needs more control over your jobs or if you have any
629 additional configuration outside of the standard configuration provided by the
630 template, then this line should be removed.
631
632 #### Tuning Templates
633
634 Allowing the auto-updated to manage your templates doesn't prevent you from
635 doing some configuration changes. Parameters can be passed to templates via
636 a `<project>.cfg` in your `builder/jjb/<project>` directory. An example is
637 provided below, others can be found in the repos of other projects. Tune as
638 necessary. Unnecessary paramaters can be removed or commented out with a "#"
639 sign.
640
641     JOB_TEMPLATES: verify,merge,sonar
642     STREAMS:
643     - beryllium:
644         branch: master
645         jdks: openjdk7,openjdk8
646         autorelease: true
647     - stable-lithium:
648         branch: stable/lithium
649         jdks: openjdk7
650     POM: dfapp/pom.xml
651     MVN_GOALS: clean install javadoc:aggregate -DrepoBuild -Dmaven.repo.local=$WORKSPACE/.m2repo -Dorg.ops4j.pax.url.mvn.localRepository=$WORKSPACE/.m2repo
652     MVN_OPTS: -Xmx1024m -XX:MaxPermSize=256m
653     DEPENDENCIES: aaa,controller,yangtools
654     ARCHIVE_ARTIFACTS: *.logs, *.patches
655
656 Note: [STREAMS][26] is a list of branches you want JJB to generate jobs for.
657 The first branch will be the branch that reports Sonar analysis. Each branch
658 must define a "jdks:" section listing the JDKs the verify jobs should run tests
659 against for the branch. The first JDK listed will be used as the default JDK
660 for non-verify type jobs.
661
662 Note: Projects that are participating in the simultanious release should set
663 "autorelease: true" under the streams they are participating in autorelease
664 for. This enables a new job type validate-autorelease which is used to help
665 identify if Gerrit patches might break autorelease or not.
666
667 #### Advanced
668
669 It is also possible to take advantage of both the auto-updater and creating
670 your own jobs. To do this, create a YAML file in your project's sub-directory
671 with any name other than \<project\>.yaml. The auto-update script will only
672 search for files with the name \<project\>.yaml. The normal \<project\>.yaml
673 file can then be left in tact with the "# REMOVE THIS LINE IF..." comment so
674 it will be automatically updated.
675
676 ## <a name="jjb_maven_properties">Maven Properties</a>
677
678 We provide a properties which your job can take advantage of if you want to do
679 something different depending on the job type that is run. If you create a
680 profile that activates on a property listed blow. The JJB templated jobs will
681 be able to activate the profile during the build to run any custom code you
682 wish to run in your project.
683
684     -Dmerge   : This flag is passed in our Merge job and is equivalent to the
685                 Maven property
686                 <merge>true</merge>.
687     -Dsonar   : This flag is passed in our Sonar job and is equivalent to the
688                 Maven property
689                 <sonar>true</sonar>.
690
691 # <a name="jenkins_sandbox">Jenkins Sandbox</a>
692
693 The [sandbox instance][27]'s purpose is to allow projects to test their JJB
694 setups before merging their code over to the RelEng master silo. It is
695 configured similarly to the master instance, although it cannot publish
696 artifacts or vote in Gerrit.
697
698 If your project requires access to the sandbox please open an OpenDaylight
699 Helpdesk ticket (<helpdesk@opendaylight.org>) and provide your ODL ID.
700
701 ## Notes Regarding the Sandbox
702
703 * Jobs are automatically deleted every Saturday at 08:00 UTC
704 * Committers can login and configure Jenkins jobs in the sandbox directly
705   (unlike with the master silo)
706 * Sandbox configuration mirrors the master silo when possible
707 * Sandbox jobs can NOT upload artifacts to Nexus
708 * Sandbox jobs can NOT vote on Gerrit
709
710 ## <a name="sandbox_config">Configuration</a>
711
712 Make sure you have Jenkins Job Builder [properly installed](#jjb_install).
713
714 If you do not already have access, open an OpenDaylight Helpdesk ticket
715 (<helpdesk@opendaylight.org>) to request access to ODL's sandbox instance.
716 [Integration/Test][1] committers have access by default.
717
718 JJB reads user-specific configuration from a [`jenkins.ini` file][7]. An
719 example is provided at [`builder/jenkins.ini.example`][28].
720
721     # If you don't have RelEng/Builder's repo, clone it
722     $ git clone https://git.opendaylight.org/gerrit/p/releng/builder.git
723     # Make a copy of the example JJB config file (in the builder/ directory)
724     $ cp jenkins.ini.example jenkins.ini
725     # Edit jenkins.ini with your username, API token and ODL's sandbox URL
726     $ cat jenkins.ini
727     <snip>
728     [jenkins]
729     user=<your ODL username>
730     password=<your ODL Jenkins sandbox API token>
731     url=https://jenkins.opendaylight.org/sandbox
732     <snip>
733
734 To get your API token, [login to the Jenkins **sandbox** instance][32] (_not
735 the main master Jenkins instance, different tokens_), go to your user page (by
736 clicking on your username, for example), click "Configure" and then "Show API
737 Token".
738
739 ## <a name="jjb_use_manual">Manual Method</a>
740
741 If you [installed JJB locally into a virtual environment](#jjb_install),
742 you should now activate that virtual environment to access the `jenkins-jobs`
743 executable.
744
745     $ workon jjb
746     (jjb)$
747
748 You'll want to work from the root of the RelEng/Builder repo, and you should
749 have your `jenkins.ini` file [properly configured](#sandbox_config).
750
751 ### <a name="jjb_manual_test">Testing Jobs</a>
752
753 It's good practice to use the `test` command to validate your JJB files before
754 pushing them.
755
756     jenkins-jobs --conf jenkins.ini test jjb/ <job-name>
757
758 If the job you'd like to test is a template with variables in its name, it
759 must be manually expanded before use. For example, the commonly used template
760 `{project}-csit-verify-1node-{functionality}` might expand to
761 `ovsdb-csit-verify-1node-netvirt`.
762
763     jenkins-jobs --conf jenkins.ini test jjb/ ovsdb-csit-verify-1node-netvirt
764
765 Successful tests output the XML description of the Jenkins job described by
766 the specified JJB job name.
767
768 ### <a name="jjb_manual_push">Pushing Jobs</a>
769
770 Once you've [configured your `jenkins.ini`](#sandbox_config) and [verified your
771 JJB jobs](#jjb_manual_test) produce valid XML descriptions of Jenkins jobs you
772 can push them to the Jenkins sandbox.
773
774 > _**Important Note:** When pushing with `jenkins-jobs`, a log message with
775 > the number of jobs you're pushing will be issued, typically to stdout.
776 > **If the number is greater than 1** (or the number of jobs you passed to
777 > the command to push) then you are pushing too many jobs and should **`ctrl+c`
778 > to cancel the upload**. Else you will flood the system with jobs._
779
780 >       INFO:jenkins_jobs.builder:Number of jobs generated:  1
781
782 > _**Failing to provide the final `<job-name>` param will push all jobs!**_
783
784     # Don't push all jobs by omitting the final param! (ctrl+c to abort)
785     jenkins-jobs --conf jenkins.ini update jjb/ <job-name>
786
787 ## <a name="jjb_use_docker">Docker Method</a>
788
789 If [using Docker](#jjb_install_docker):
790
791     # To test
792     docker run --rm -v ${PWD}:/jjb zxiiro/jjb-docker
793
794 > _**Important Note:** When pushing with `jenkins-jobs`, a log message with
795 > the number of jobs you're pushing will be issued, typically to stdout.
796 > **If the number is greater than 1** (or the number of jobs you passed to
797 > the command to push) then you are pushing too many jobs and should **`ctrl+c`
798 > to cancel the upload**. Else you will flood the system with jobs._
799
800 >       INFO:jenkins_jobs.builder:Number of jobs generated:  1
801
802 > _**Failing to provide the final `<job-name>` param will push all jobs!**_
803
804     # To upload jobs to the sandbox
805     # Please ensure that you include a configured jenkins.ini in your volume mount
806     # Making sure not to push more jobs than expected, ctrl+c to abort
807     docker run --rm -v ${PWD}:/jjb zxiiro/jjb-docker jenkins-jobs --conf jenkins.ini update . openflowplugin-csit-periodic-1node-cds-longevity-only-master
808
809 [0]: https://wiki.opendaylight.org/view/RelEng:Main "ODL RelEng parent project wiki"
810 [1]: https://wiki.opendaylight.org/view/Integration/Test "ODL Integration/Test wiki"
811 [2]: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=tree;f=jenkins-scripts;h=371193b89f418de2ca0ffcb78be4a2d8046701ae;hb=refs/heads/master "JJB Templates Directory"
812 [3]: https://jenkins.opendaylight.org/releng "RelEng Jenkins"
813 [4]: https://git.opendaylight.org/gerrit/gitweb?p=releng%2Fbuilder.git;a=summary "RelEng/Builder gitweb"
814 [5]: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=tree;f=jenkins-scripts;h=69252dd61ece511bd2018039b40e7836a8d49d21;hb=HEAD "Directory of Jenkins slave spinup scripts"
815 [6]: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=tree;f=vagrant;h=409a2915d48bbdeea9edc811e1661ae17ca28280;hb=HEAD "Directory of Jenkins slave Vagrant definitions"
816 [7]: http://docs.openstack.org/infra/jenkins-job-builder/execution.html#configuration-file "JJB config file docs"
817 [8]: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=tree;f=vagrant/basic-java-node;h=7197b26b747deba38c08f30a569c233fd9636d72;hb=HEAD "Example Jenkins slave Vagrant defition"
818 [9]: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jenkins-scripts/controller.sh;h=893a04118a9bd9c55ae2a4a6af833fa089e0e0b4;hb=HEAD "Jenkins spinup script specialized for a slave"
819 [10]: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jenkins-scripts/basic_settings.sh;h=9f6d2a89948d0a25a8a4a24102630ada494e8623;hb=HEAD "Jenkins spinup script common to all slaves"
820 [11]: http://ci.openstack.org/jenkins-job-builder/ "JJB docs"
821 [12]: https://git.opendaylight.org/gerrit/#/admin/projects/releng/builder "ODL RelEng/Builder Gerrit"
822 [13]: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=summary "ODL RelEng/Builder repo"
823 [14]: https://www.docker.com/whatisdocker/ "Docker docs"
824 [15]: https://github.com/zxiiro/jjb-docker/blob/master/Dockerfile "Custom ODL JJB Dockerfile"
825 [16]: https://github.com/openstack-infra/jenkins-job-builder "JJB repo"
826 [17]: https://lists.opendaylight.org/pipermail/integration-dev/2015-April/003016.html "Recommendation to use venvs"
827 [18]: https://virtualenv.readthedocs.org/en/latest/ "Virtualenv docs"
828 [19]: http://virtualenv.readthedocs.org/en/latest/installation.html "Virtualenv install docs"
829 [20]: https://github.com/openstack-infra/jenkins-job-builder/blob/master/requirements.txt "JJB Python dependencies"
830 [21]: https://wiki.opendaylight.org/view/RelEng/Builder "ODL RelEng/Builder wiki"
831 [22]: https://nexus.opendaylight.org "OpenDaylight's Nexus portal"
832 [23]: https://sonar.opendaylight.org "OpenDaylight's Sonar portal"
833 [24]: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=scripts/jjb-init-project.py;h=2133475a4ff9e1f4b18cc288654a4dc050bf808f;hb=refs/heads/master "JJB project config init helper script"
834 [25]: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=scripts/jjb-autoupdate-project.py;h=56769bdb7ad5149404f4f50923f4d10af98d8248;hb=refs/heads/master "JJB project config auto-update helper script"
835 [26]: https://lists.opendaylight.org/pipermail/release/2015-July/003139.html "STREAMS vs BRANCHES design background"
836 [27]: https://jenkins.opendaylight.org/sandbox/ "OpenDaylight JJB Sandbox"
837 [28]: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jenkins.ini.example;h=c8486f89af99741f4706c23cd6717df9b417ae10;hb=refs/heads/master "JJB sandbox user config example"
838 [29]: https://hub.docker.com/r/zxiiro/jjb-docker/ "Custom JJB Docker image"
839 [30]: https://virtualenvwrapper.readthedocs.org/en/latest/ "Virtualenvwrapper docs"
840 [31]: https://virtualenvwrapper.readthedocs.org/en/latest/install.html "Virtualenvwrapper install docs"
841 [32]: https://jenkins.opendaylight.org/sandbox/login "ODL Jenkins sandbox login"
842 [33]: https://git.opendaylight.org/gerrit/gitweb?p=releng/builder.git;a=blob;f=jjb/requirements.txt;h=0a4df2c2a575eb10d3abddb0fb2f4d048645e378;hb=refs/heads/master "ODL JJB requirements.txt file"