Document undocumented ci-jobs macros
[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
235 * 2.31
236 * 2.32
237 * 2.33
238 * 2.34
239
240 Cloud configuration are managed via a directory structure in ci-management as
241 follows:
242
243 - jenkins-config/clouds/openstack/
244 - jenkins-config/clouds/openstack/cattle/cloud.cfg
245 - jenkins-config/clouds/openstack/cattle/centos7-builder-2c-2g.cfg
246 - jenkins-config/clouds/openstack/cattle/centos7-builder-4c-4g.cfg
247 - jenkins-config/clouds/openstack/cattle/centos7-docker-4c-4g.cfg
248
249 The directory name inside of the "openstack" directory is used as the name of
250 the cloud configuration. In this case "cattle" is being used as the cloud name.
251
252 The ``cloud.cfg`` file is a special file used to configure the main cloud
253 configuration in the format ``KEY=value``.
254
255 :Cloud Parameters:
256
257     :CLOUD_URL: API endpoint URL for Keystone.
258         (default: "")
259     :CLOUD_IGNORE_SSL: Ignore unverified SSL certificates. (default: false)
260     :CLOUD_ZONE: OpenStack region to use. (default: "")
261     :CLOUD_CREDENTIAL_ID: Credential to use for authentication to OpenStack.
262         (default: "os-cloud")
263     :INSTANCE_CAP: Total number of instances the cloud will allow spin up.
264         (default: null)
265     :SANDBOX_CAP: Total number of instances the clodu will allow to
266         spin up. This applies to "sandbox" systems and overrides the
267         INSTANCE_CAP setting. (default: null)
268
269 :Template Parameters:
270
271     .. note::
272
273        In the case of template definitions of a parameter below is not passed
274        the one defined in default clouds will be inherited.
275
276     :IMAGE_NAME: The image name to use for this template.
277         (default: "")
278     :LABELS: Labels to assign to the vm. (default: FILE_NAME)
279     :HARDWARE_ID: OpenStack flavor to use. (default: "")
280     :NETWORK_ID: OpenStack network to use. (default: "")
281     :USER_DATA_ID: User Data to pass into the instance.
282         (default: jenkins-init-script)
283     :INSTANCE_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. (default: null)
286     :SANDBOX_CAP: Total number of instances of this type that can be launched
287         at one time. When defined in clouds.cfg it defines the total for the
288         entire cloud. This applies to "sandbox" systems and overrides the
289         INSTANCE_CAP setting. (default: null)
290     :FLOATING_IP_POOL: Floating ip pool to use. (default: "")
291     :SECURITY_GROUPS: Security group to use. (default: "default")
292     :AVAILABILITY_ZONE: OpenStack availability zone to use. (default: "")
293     :START_TIMEOUT: Number of milliseconds to wait for the agent to be
294         provisioned and connected. (default: 600000)
295     :KEY_PAIR_NAME: SSH Public Key Pair to use for authentication.
296         (default: jenkins)
297     :NUM_EXECUTORS: Number of executors to enable for the instance.
298         (default: 1)
299     :JVM_OPTIONS: JVM Options to pass to Java. (default: "")
300     :FS_ROOT: File system root for the workspace. (default: "/w")
301     :RETENTION_TIME: Number of minutes to wait for an idle slave to be used
302         again before it's removed. If set to -1, the slave will be kept
303         forever. (default: 0)
304
305 For a live example see the OpenDaylight project jenkins-config directory.
306 https://github.com/opendaylight/releng-builder/tree/master/jenkins-config
307
308 Troubleshooting
309 ^^^^^^^^^^^^^^^
310
311 :Cloud Configuration:
312
313     The directory ``groovy-inserts`` contains the groovy script output that is
314     used to push to Jenkins. In the event of a job failure this file can be
315     inspected.
316
317
318 JJB Deploy Job
319 --------------
320
321 Deploy jobs to jenkins-sandbox system via code review comment
322
323 This job checks out the current code review patch and then runs a
324 `jenkins-jobs update` to push a patch defined by the comment.
325
326 :Template names:
327
328     - {project-name}-jjb-deploy-job
329     - gerrit-jjb-deploy-job
330     - github-jjb-deploy-job
331
332 :Comment Trigger: jjb-deploy JOB_NAME
333
334     .. note::
335
336        JOB_NAME can include the * wildcard character to push multiple jobs
337        matching the pattern. For example `jjb-deploy builder-jjb-*`` will push
338        all builder-jjb-* jobs to the sandbox system.
339
340 :Required parameters:
341
342     :build-node: The node to run build on.
343     :jenkins-ssh-credential: Credential to use for SSH. (Generally
344         should be configured in defaults.yaml)
345
346 :Optional parameters:
347
348     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
349     :gerrit_jjb_deploy_job_triggers: Override Gerrit Triggers.
350
351
352 JJB Merge
353 ---------
354
355 Runs `jenkins-jobs update` to update production job configuration
356
357 :Template Names:
358     - {project-name}-jjb-merge
359     - gerrit-jjb-merge
360     - github-jjb-merge
361
362 :Required parameters:
363
364     :build-node: The node to run build on.
365     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
366         be configured in defaults.yaml)
367     :mvn-settings: The name of settings file containing credentials for
368         the project.
369
370 :Optional parameters:
371
372     :branch: Git branch to fetch for the build. (default: master)
373     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
374     :build-timeout: Timeout in seconds before aborting build. (default: 10)
375     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
376     :stream: Keyword that can be used to represent a release code-name.
377         Often the same as the branch. (default: master)
378     :submodule-recursive: Whether to checkout submodules recursively.
379         (default: true)
380
381     :gerrit_merge_triggers: Override Gerrit Triggers.
382     :gerrit_trigger_file_paths: Override file paths which can be used to
383         filter which file modifications will trigger a build.
384         (default defined by lf_jjb_common)
385
386
387 JJB Verify
388 ----------
389
390 Runs `jenkins-jobs test` to validate JJB syntax
391
392 :Template Names:
393     - {project-name}-jjb-verify
394     - gerrit-jjb-verify
395     - github-jjb-verify
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     :mvn-settings: The name of settings file containing credentials for
403         the project.
404
405 :Optional parameters:
406
407     :branch: Git branch to fetch for the build. (default: master)
408     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
409     :build-timeout: Timeout in seconds before aborting build. (default: 10)
410     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
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
416     :gerrit_verify_triggers: Override Gerrit Triggers.
417     :gerrit_trigger_file_paths: Override file paths which can be used to
418         filter which file modifications will trigger a build.
419         (default defined by lf_jjb_common)
420
421 .. _info-yaml-verify:
422
423 Info YAML Verify
424 ----------------
425
426 Info YAML Verify job validates that INFO.yaml file changes are kept isolated from
427 other file changes. Verifies INFO.yaml files follow the schema defined in
428 `global-jjb/info-schema`.
429
430 :Template Names:
431     - {project-name}-info-yaml-verify
432     - gerrit-info-yaml-verify
433     - github-info-yaml-verify
434
435 :Required parameters:
436
437     :build-node: The node to run build on.
438     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
439         be configured in defaults.yaml)
440
441 :Optional parameters:
442
443     :branch: Git branch to fetch for the build. (default: master)
444     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
445     :build-timeout: Timeout in seconds before aborting build. (default: 10)
446     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
447     :stream: Keyword that can be used to represent a release code-name.
448         Often the same as the branch. (default: master)
449     :submodule-recursive: Whether to checkout submodules recursively.
450         (default: true)
451     :gerrit_verify_triggers: Override Gerrit Triggers.
452
453 .. _gjjb-packer-merge:
454
455 Packer Merge
456 ------------
457
458 Packer Merge job runs `packer build` to build system images in the cloud.
459
460 :Template Names:
461     - {project-name}-packer-merge-{platforms}-{templates}
462     - gerrit-packer-merge
463     - github-packer-merge
464
465 :Required parameters:
466
467     :build-node: The node to run build on.
468     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
469         be configured in defaults.yaml)
470     :mvn-settings: The name of settings file containing credentials for
471         the project.
472     :platforms: Platform or distribution to build. Typically json file
473         found in the packer/vars directory. (Example: centos)
474     :template: System template to build. Typically shell script found in
475         the packer/provision directory. (Example: java-builder)
476
477 :Optional parameters:
478
479     :cron: Time when the packer image should be rebuilt (default: @monthly)
480     :branch: Git branch to fetch for the build. (default: master)
481     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
482     :build-timeout: Timeout in seconds before aborting build. (default: 10)
483     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
484     :packer-cloud-settings: Name of settings file containing credentials
485         for the cloud that packer will build on. (default: packer-cloud-env)
486     :packer-version: Version of packer to install / use in build. (default: 1.0.2)
487     :stream: Keyword that can be used to represent a release code-name.
488         Often the same as the branch. (default: master)
489     :submodule-recursive: Whether to checkout submodules recursively.
490         (default: true)
491
492     :gerrit_verify_triggers: Override Gerrit Triggers.
493
494
495 .. _gjjb-packer-verify:
496
497 Packer Verify
498 -------------
499
500 Packer Verify job runs `packer validate` to verify packer configuration.
501
502 :Template Names:
503     - {project-name}-packer-verify
504     - gerrit-packer-verify
505     - github-packer-verify
506
507 :Required parameters:
508
509     :build-node: The node to run build on.
510     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
511         be configured in defaults.yaml)
512     :mvn-settings: The name of settings file containing credentials for
513         the project.
514
515 :Optional parameters:
516
517     :branch: Git branch to fetch for the build. (default: master)
518     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
519     :build-timeout: Timeout in seconds before aborting build. (default: 10)
520     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
521     :packer-cloud-settings: Name of settings file containing credentials
522         for the cloud that packer will build on. (default: packer-cloud-env)
523     :packer-version: Version of packer to install / use in build. (default: 1.0.2)
524     :stream: Keyword that can be used to represent a release code-name.
525         Often the same as the branch. (default: master)
526     :submodule-recursive: Whether to checkout submodules recursively.
527         (default: true)
528
529     :gerrit_verify_triggers: Override Gerrit Triggers.
530     :gerrit_trigger_file_paths: Override file paths which can be used to
531         filter which file modifications will trigger a build.