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