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