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