Merge "Add view templates to manage Jenkins views"
[releng/global-jjb.git] / docs / jjb / lf-ci-jobs.rst
1 #######
2 CI Jobs
3 #######
4
5 Job Groups
6 ==========
7
8 .. include:: ../job-groups.rst
9
10 Below is a list of CI job groups:
11
12 .. literalinclude:: ../../jjb/lf-ci-job-groups.yaml
13    :language: yaml
14
15
16 Macros
17 ======
18
19 lf-infra-jjb-parameters
20 -----------------------
21
22 :Required Parameters:
23
24     :jjb-version: Version of Jenkins Job Builder (JJB) to install and use in
25         the jjb jobs.
26
27 lf-jenkins-cfg-clouds
28 ---------------------
29
30 Deploys Jenkins Cloud configuration read from the ``jenkins-clouds`` directory
31 in ci-management repositories.
32
33 .. note::
34
35    Requires the jjbini file in Jenkins CFP to contain JJB 2.0 style
36    config definitions for "production" and "sandbox" systems.
37
38 :Required Parameters:
39
40     :jenkins-silos: Space-separated list of Jenkins silos to update
41         configuration for as defined in ~/.config/jenkins_jobs/jenkins_jobs.ini
42
43 lf-jenkins-cfg-global-vars
44 --------------------------
45
46 Manages the Global Jenkins variables. This macro will clear all exist macros
47 in Jenkins and replaces them with the ones defined by the
48 ci-management/jenkins-config/global-vars-SILO.sh script.
49
50 .. note::
51
52    Requires the jjbini file in Jenkins CFP to contain JJB 2.0 style
53    config definitions for "production" and "sandbox" systems.
54
55 :Required parameters:
56
57     :jenkins-silos: Space-separated list of Jenkins silos to update
58         configuration for as defined in ~/.config/jenkins_jobs/jenkins_jobs.ini
59
60 lf-infra-jjbini
61 ---------------
62
63 Provides jenkins_jobs.ini configuration for Jenkins.
64
65 lf-infra-jjbini-sandbox
66 -----------------------
67
68 Provides jenkins_jobs.ini configuration for Jenkins sandbox.
69
70 .. todo:: This needs to be consolidated into lf-infra-jjbini when JJB 2.0 is available
71
72 lf-packer-common
73 ----------------
74
75 Common packer configuration.
76
77 lf-packer-file-paths
78 --------------------
79
80 Gerrit file-paths for packer jobs.
81
82 lf-packer-parameters
83 --------------------
84
85 Parameters useful for packer related tasks.
86
87 :Parameters:
88
89     :packer-version: Version of packer to install / use.
90         (shell: PACKER_VERSION)
91
92 lf-packer-verify-file-paths
93 ---------------------------
94
95 Gerrit file-paths for packer verify jobs.
96
97 Job Templates
98 =============
99
100 .. _gerrit-branch-lock:
101
102 Gerrit Branch Lock
103 ------------------
104
105 Job submits a patch to lock or unlock a project's branch.
106
107 :Template Names:
108     - {project-name}-gerrit-branch-lock-{stream}
109     - gerrit-branch-lock
110
111 :Comment Trigger:
112
113     * lock branch
114     * unlock branch
115
116 :Required parameters:
117
118     :build-node: The node to run build on.
119     :jenkins-ssh-credential: Credential to use for SSH. (Generally
120         should be configured in defaults.yaml)
121
122 :Optional parameters:
123
124     :branch: Git branch to build against. (default: master)
125     :git-url: URL to clone project from. (default: $GIT_URL/$GERRIT_PROJECT)
126     :stream: Keyword that can be used to represent a release code-name.
127         Often the same as the branch. (default: master)
128     :submodule-timeout: Timeout (in minutes) for checkout operation.
129         (default: 10)
130     :gerrit_merge_triggers: Override Gerrit Triggers.
131
132 .. _lf-global-jjb-jenkins-cfg-merge:
133
134 Jenkins Configuration Merge
135 ---------------------------
136
137 Jenkins job to manage Global Jenkins configuration.
138
139 .. note::
140
141    Requires the jjbini file in Jenkins CFP to contain JJB 2.0 style
142    config definitions for "production" and "sandbox" systems.
143
144 :Template names:
145
146     - {project-name}-jenkins-cfg-merge
147     - gerrit-jenkins-cfg-merge
148     - github-jenkins-cfg-merge
149
150 :Optional parameters:
151
152     :branch: Git branch to build against. (default: master)
153     :cron: How often to run the job on a cron schedule. (default: @daily)
154     :git-url: URL to clone project from. (default: $GIT_URL/$GERRIT_PROJECT)
155     :jenkins-silos: Space separated list of Jenkins silos to update
156         configuration for as defined in ~/.config/jenkins_jobs/jenkins_jobs.ini
157         (default: production sandbox)
158
159 Typically this template is automatically pulled in by the
160 "{project-name}-ci-jobs" job-group and does not need to be explicitly called if
161 the job group is being used.
162
163 Minimal Example:
164
165 .. literalinclude:: ../../.jjb-test/lf-ci-jobs/jenkins-cfg-merge-minimal.yaml
166    :language: yaml
167
168 Full Example:
169
170 .. literalinclude:: ../../.jjb-test/lf-ci-jobs/jenkins-cfg-merge-full.yaml
171    :language: yaml
172
173 .. _jenkins-cfg-envvar:
174
175 Global Environment Variables
176 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
177
178 Global Environment Variables are managed via the
179 ``jenkins-config/global-vars-SILO.sh`` file in ci-management. Replace SILO with
180 the name of the Jenkins silo the variable configuration is for.
181
182 The format for this file is ``KEY=value`` for example::
183
184     GERRIT_URL=https://git.opendaylight.org/gerrit
185     GIT_BASE=git://devvexx.opendaylight.org/mirror/$PROJECT
186     GIT_URL=git://devvexx.opendaylight.org/mirror
187     JENKINS_HOSTNAME=vex-yul-odl-jenkins-2
188     LOGS_SERVER=https://logs.opendaylight.org
189     NEXUS_URL=https://nexus.opendaylight.org
190     ODLNEXUSPROXY=https://nexus.opendaylight.org
191     SILO=sandbox
192     SONAR_URL=https://sonar.opendaylight.org
193
194 Cloud Configuration
195 ^^^^^^^^^^^^^^^^^^^
196
197 This configuration requires the OpenStack Cloud plugin in Jenkins and is
198 currently the only cloud plugin supported.
199
200 OpenStack Cloud plugin version supported:
201
202 * 2.30 - 2.34
203 * 2.35 - 2.37
204
205 Cloud configuration are managed via a directory structure in ci-management as
206 follows:
207
208 - jenkins-config/clouds/openstack/
209 - jenkins-config/clouds/openstack/cattle/cloud.cfg
210 - jenkins-config/clouds/openstack/cattle/centos7-builder-2c-2g.cfg
211 - jenkins-config/clouds/openstack/cattle/centos7-builder-4c-4g.cfg
212 - jenkins-config/clouds/openstack/cattle/centos7-docker-4c-4g.cfg
213
214 The directory name inside of the "openstack" directory is used as the name of
215 the cloud configuration. In this case "cattle" is being used as the cloud name.
216
217 The ``cloud.cfg`` file is a special file used to configure the main cloud
218 configuration in the format ``KEY=value``.
219
220 :Cloud Parameters:
221
222     :CLOUD_URL: API endpoint URL for Keystone.
223         (default: "")
224     :CLOUD_IGNORE_SSL: Ignore unverified SSL certificates. (default: false)
225     :CLOUD_ZONE: OpenStack region to use. (default: "")
226     :CLOUD_CREDENTIAL_ID: Credential to use for authentication to OpenStack.
227         (default: "os-cloud")
228     :INSTANCE_CAP: Total number of instances the cloud will allow spin up.
229         (default: null)
230     :SANDBOX_CAP: Total number of instances the cloud will allow to
231         spin up. This applies to "sandbox" systems and overrides the
232         INSTANCE_CAP setting. (default: null)
233
234 :Template Parameters:
235
236     .. note::
237
238        In the case of template definitions of a parameter below is not passed
239        the one defined in default clouds will be inherited.
240
241     :IMAGE_NAME: The image name to use for this template.
242         (required)
243     :HARDWARE_ID: OpenStack flavor to use. (required)
244
245     :LABELS: Labels to assign to the vm. (default: FILE_NAME)
246     :NETWORK_ID: OpenStack network to use. (default: "")
247     :USER_DATA_ID: User Data to pass into the instance.
248         (default: jenkins-init-script)
249     :INSTANCE_CAP: Total number of instances of this type that can be launched
250         at one time. When defined in clouds.cfg it defines the total for the
251         entire cloud. (default: null)
252     :SANDBOX_CAP: Total number of instances of this type that can be launched
253         at one time. When defined in clouds.cfg it defines the total for the
254         entire cloud. This applies to "sandbox" systems and overrides the
255         INSTANCE_CAP setting. (default: null)
256     :FLOATING_IP_POOL: Floating ip pool to use. (default: "")
257     :SECURITY_GROUPS: Security group to use. (default: "default")
258     :AVAILABILITY_ZONE: OpenStack availability zone to use. (default: "")
259     :START_TIMEOUT: Number of milliseconds to wait for the agent to be
260         provisioned and connected. (default: 600000)
261     :KEY_PAIR_NAME: SSH Public Key Pair to use for authentication.
262         (default: jenkins)
263     :NUM_EXECUTORS: Number of executors to enable for the instance.
264         (default: 1)
265     :JVM_OPTIONS: JVM Options to pass to Java. (default: "")
266     :FS_ROOT: File system root for the workspace. (default: "/w")
267     :RETENTION_TIME: Number of minutes to wait for an idle slave to be used
268         again before it's removed. If set to -1, the slave will be kept
269         forever. (default: 0)
270     :CONNECTION_TYPE: The connection type for Jenkins to connect to the build
271         minion. Valid options: JNLP, SSH. (default: "SSH")
272
273 For a live example see the OpenDaylight project jenkins-config directory.
274 https://github.com/opendaylight/releng-builder/tree/master/jenkins-config
275
276 Troubleshooting
277 ^^^^^^^^^^^^^^^
278
279 :Cloud Configuration:
280
281     The directory ``groovy-inserts`` contains the groovy script output that is
282     used to push to Jenkins. In the event of a job failure this file can be
283     inspected.
284
285
286 Jenkins Sandbox Cleanup
287 -----------------------
288
289 Cleanup Jenkins Sandbox of jobs and views periodically.
290
291 :Template names:
292
293     - {project-name}-jenkins-sandbox-cleanup
294     - gerrit-jenkins-sandbox-cleanup
295     - github-jenkins-sandbox-cleanup
296
297 :Comment Trigger: NONE
298
299 :Required parameters:
300
301     :build-node: The node to run build on.
302     :jenkins-ssh-credential: Credential to use for SSH. (Generally
303         should be configured in defaults.yaml)
304
305 :Optional parameters:
306
307     :cron: Schedule to run job. (default: '0 8 * * 6')
308
309
310 JJB Deploy Job
311 --------------
312
313 Deploy jobs to jenkins-sandbox system via code review comment
314
315 This job checks out the current code review patch and then runs a
316 `jenkins-jobs update` to push a patch defined by the comment.
317
318 :Template names:
319
320     - {project-name}-jjb-deploy-job
321     - gerrit-jjb-deploy-job
322     - github-jjb-deploy-job
323
324 :Comment Trigger: jjb-deploy JOB_NAME
325
326     .. note::
327
328        JOB_NAME can include the * wildcard character to push multiple jobs
329        matching the pattern. For example `jjb-deploy builder-jjb-*`` will push
330        all builder-jjb-* jobs to the sandbox system.
331
332 :Required parameters:
333
334     :build-node: The node to run build on.
335     :jenkins-ssh-credential: Credential to use for SSH. (Generally
336         should be configured in defaults.yaml)
337
338 :Optional parameters:
339
340     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
341     :gerrit_jjb_deploy_job_triggers: Override Gerrit Triggers.
342
343
344 JJB Merge
345 ---------
346
347 Runs `jenkins-jobs update` to update production job configuration
348
349 :Template Names:
350     - {project-name}-jjb-merge
351     - gerrit-jjb-merge
352     - github-jjb-merge
353
354 :Comment Trigger: remerge
355
356 :Required parameters:
357
358     :build-node: The node to run build on.
359     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
360         be configured in defaults.yaml)
361
362 :Optional parameters:
363
364     :branch: Git branch to fetch for the build. (default: master)
365     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
366     :build-timeout: Timeout in minutes before aborting build. (default: 10)
367     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
368     :jjb-version: JJB version to install. (default: see job-template)
369     :stream: Keyword that can be used to represent a release code-name.
370         Often the same as the branch. (default: master)
371     :submodule-recursive: Whether to checkout submodules recursively.
372         (default: true)
373     :submodule-timeout: Timeout (in minutes) for checkout operation.
374         (default: 10)
375
376     :gerrit_merge_triggers: Override Gerrit Triggers.
377     :gerrit_trigger_file_paths: Override file paths which can be used to
378         filter which file modifications will trigger a build.
379         (default defined by lf_jjb_common)
380
381
382 JJB Verify
383 ----------
384
385 Runs `jenkins-jobs test` to validate JJB syntax
386
387 :Template Names:
388     - {project-name}-jjb-verify
389     - gerrit-jjb-verify
390     - github-jjb-verify
391
392 :Comment Trigger: recheck|reverify
393
394 :Required parameters:
395
396     :build-node: The node to run build on.
397     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
398         be configured in defaults.yaml)
399
400 :Optional parameters:
401
402     :branch: Git branch to fetch for the build. (default: master)
403     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
404     :build-timeout: Timeout in minutes before aborting build. (default: 10)
405     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
406     :jjb-version: JJB version to install. (default: see job-template)
407     :stream: Keyword that can be used to represent a release code-name.
408         Often the same as the branch. (default: master)
409     :submodule-recursive: Whether to checkout submodules recursively.
410         (default: true)
411     :submodule-timeout: Timeout (in minutes) for checkout operation.
412         (default: 10)
413
414     :gerrit_verify_triggers: Override Gerrit Triggers.
415     :gerrit_trigger_file_paths: Override file paths which can be used to
416         filter which file modifications will trigger a build.
417         (default defined by lf_jjb_common)
418
419 .. _jjb-verify-upstream-gjjb:
420
421 JJB Verify Upstream Global JJB
422 ------------------------------
423
424 Runs ``jenkins-jobs test`` to validate JJB syntax for upstream global-jjb
425 patches. This job is useful to notify upstream that they may be breaking
426 project level jobs.
427
428 :Template Names:
429     - {project-name}-jjb-verify-upstream-gjjb
430     - gerrit-jjb-verify-upstream-gjjb
431
432 :Comment Trigger: recheck|reverify
433
434 :Required parameters:
435
436     :build-node: The node to run build on.
437     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
438         be configured in defaults.yaml)
439
440 :Optional parameters:
441
442     :branch: Git branch to fetch for the build. (default: master)
443     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
444     :build-timeout: Timeout in minutes before aborting build. (default: 10)
445     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
446     :jjb-version: JJB version to install. (default: see job-template)
447     :stream: Keyword that can be used to represent a release code-name.
448         Often the same as the branch. (default: master)
449
450 .. _info-yaml-verify:
451
452 Info YAML Verify
453 ----------------
454
455 Info YAML Verify job validates that INFO.yaml file changes are kept isolated from
456 other file changes. Verifies INFO.yaml files follow the schema defined in
457 `global-jjb/info-schema`.
458
459 :Template Names:
460     - {project-name}-info-yaml-verify
461     - gerrit-info-yaml-verify
462     - github-info-yaml-verify
463
464 :Required parameters:
465
466     :build-node: The node to run build on.
467     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
468         be configured in defaults.yaml)
469
470 :Optional parameters:
471
472     :branch: Git branch to fetch for the build. (default: master)
473     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
474     :build-timeout: Timeout in minutes before aborting build. (default: 10)
475     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
476     :stream: Keyword that can be used to represent a release code-name.
477         Often the same as the branch. (default: master)
478     :submodule-recursive: Whether to checkout submodules recursively.
479         (default: true)
480     :submodule-timeout: Timeout (in minutes) for checkout operation.
481         (default: 10)
482
483     :gerrit_verify_triggers: Override Gerrit Triggers.
484
485 .. _license-checker:
486
487 License Checker
488 ---------------
489
490 Job to scan projects for files missing license headers.
491
492 :Template Names:
493     - {project-name}-license-check
494     - gerrit-license-check
495     - github-license-check
496
497 :Optional parameters:
498
499     :build-timeout: Timeout in minutes before aborting build. (default: 15)
500     :file-patterns: Space-separated list of file patterns to scan.
501         (default: \*.go \*.groovy \*.java \*.py \*.sh)
502     :spdx-disable: Disable the SPDX-Identifier checker. (default: false)
503     :lhc-version: Version of LHC to use. (default: 0.2.0)
504     :license-exclude-paths: Comma-separated list of paths to exclude from the
505         license checker. The paths used here will be matched using a contains
506         rule so it is best to be as precise with the path as possible.
507         For example a path of '/src/generated/' will be searched as
508         '**/src/generated/**'.
509         Example: org/opendaylight/yang/gen,protobuff/messages
510         (default: '')
511     :licenses-allowed: Comma-separated list of allowed licenses.
512         (default: Apache-2.0,EPL-1.0,MIT)
513     :project-pattern: The ANT based pattern for Gerrit Trigger to choose which
514         projects to trigger job against. (default: '**')
515
516 .. _gjjb-openstack-cron:
517
518 OpenStack Cron
519 --------------
520
521 Cron job that runs regularly to perform periodic tasks against OpenStack.
522
523 This job requires a Config File Provider file named ``clouds-yaml`` available
524 containing the credentials for the cloud.
525
526 :Template Names:
527     - {project-name}-openstack-cron
528     - gerrit-openstack-cron
529     - github-openstack-cron
530
531 :Required parameters:
532
533     :build-node: The node to run build on.
534     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
535         be configured in defaults.yaml)
536
537 :Optional parameters:
538
539     :branch: Git branch to fetch for the build. (default: master)
540     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
541     :build-timeout: Timeout in minutes before aborting build. (default: 90)
542     :cron: Time when the packer image should be rebuilt (default: @daily)
543     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
544     :openstack-cloud: OS_CLOUD setting to pass to openstack client.
545         (default: vex)
546     :stream: Keyword that can be used to represent a release code-name.
547         Often the same as the branch. (default: master)
548     :submodule-recursive: Whether to checkout submodules recursively.
549         (default: true)
550     :submodule-timeout: Timeout (in minutes) for checkout operation.
551         (default: 10)
552
553 .. _gjjb-packer-merge:
554
555 Packer Merge
556 ------------
557
558 Packer Merge job runs `packer build` to build system images in the cloud.
559
560 :Template Names:
561     - {project-name}-packer-merge-{platforms}-{templates}
562     - gerrit-packer-merge
563     - github-packer-merge
564
565 :Comment Trigger: remerge
566
567 :Required parameters:
568
569     :build-node: The node to run build on.
570     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
571         be configured in defaults.yaml)
572     :mvn-settings: The name of settings file containing credentials for
573         the project.
574     :platforms: Platform or distribution to build. Typically json file
575         found in the packer/vars directory. (Example: centos)
576     :template: System template to build. Typically shell script found in
577         the packer/provision directory. (Example: java-builder)
578
579 :Optional parameters:
580
581     :cron: Time when the packer image should be rebuilt (default: @monthly)
582     :branch: Git branch to fetch for the build. (default: master)
583     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
584     :build-timeout: Timeout in minutes before aborting build. (default: 90)
585     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
586     :openstack: Packer template uses an OpenStack builder (default: true).
587     :openstack-cloud: Sets OS_CLOUD variable to the value of this parameter.
588         (default: vex).
589     :packer-cloud-settings: Name of settings file containing credentials
590         for the cloud that packer will build on. (default: packer-cloud-env)
591     :packer-version: Version of packer to install / use in build. (default: 1.0.2)
592     :stream: Keyword that can be used to represent a release code-name.
593         Often the same as the branch. (default: master)
594     :submodule-recursive: Whether to checkout submodules recursively.
595         (default: true)
596     :submodule-timeout: Timeout (in minutes) for checkout operation.
597         (default: 10)
598
599     :gerrit_verify_triggers: Override Gerrit Triggers.
600
601
602 .. _gjjb-packer-verify:
603
604 Packer Verify
605 -------------
606
607 Packer Verify job runs `packer validate` to verify packer configuration.
608
609 :Template Names:
610     - {project-name}-packer-verify
611     - gerrit-packer-verify
612     - github-packer-verify
613
614 :Comment Trigger: recheck|reverify
615
616 :Required parameters:
617
618     :build-node: The node to run build on.
619     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
620         be configured in defaults.yaml)
621     :mvn-settings: The name of settings file containing credentials for
622         the project.
623
624 :Optional parameters:
625
626     :branch: Git branch to fetch for the build. (default: master)
627     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
628     :build-timeout: Timeout in minutes before aborting build. (default: 10)
629     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
630     :openstack: Packer template uses an OpenStack builder (default: true).
631     :openstack-cloud: Sets OS_CLOUD variable to the value of this parameter.
632         (default: vex).
633     :packer-cloud-settings: Name of settings file containing credentials
634         for the cloud that packer will build on. (default: packer-cloud-env)
635     :packer-version: Version of packer to install / use in build. (default: 1.0.2)
636     :stream: Keyword that can be used to represent a release code-name.
637         Often the same as the branch. (default: master)
638     :submodule-recursive: Whether to checkout submodules recursively.
639         (default: true)
640     :submodule-timeout: Timeout (in minutes) for checkout operation.
641         (default: 10)
642
643     :gerrit_verify_triggers: Override Gerrit Triggers.
644     :gerrit_trigger_file_paths: Override file paths which can be used to
645         filter which file modifications will trigger a build.