Add doc for jjb-verify build-node label check
[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-packer-common
68 ----------------
69
70 Common packer configuration.
71
72 lf-packer-file-paths
73 --------------------
74
75 Gerrit file-paths for packer jobs.
76
77 lf-packer-parameters
78 --------------------
79
80 Parameters useful for packer related tasks.
81
82 :Parameters:
83
84     :packer-version: Version of packer to install / use.
85         (shell: PACKER_VERSION)
86
87 lf-packer-verify-file-paths
88 ---------------------------
89
90 Gerrit file-paths for packer verify jobs.
91
92 lf-puppet-parameters
93 --------------------
94
95 Parameters useful for Puppet related tasks.
96
97 :Parameters:
98
99     :puppet-lint-version: Version of puppet-lint to install / use.
100         (shell: PUPPET_LINT_VERSION)
101
102 Job Templates
103 =============
104
105 .. _gerrit-branch-lock:
106
107 Gerrit Branch Lock
108 ------------------
109
110 Job submits a patch to lock or unlock a project's branch. This should only be
111 loaded once, as "ci-management-gerrit-branch-lock" (or "ci-management"
112 equivalent). That job will process lock/unlock requests for all projects and
113 all branches.
114
115 :Template Names:
116     - {project-name}-gerrit-branch-lock
117     - gerrit-branch-lock
118
119 :Comment Trigger:
120
121     * lock branch
122     * unlock branch
123
124 :Required parameters:
125
126     :build-node: The node to run build on.
127     :jenkins-ssh-credential: Credential to use for SSH. (Generally
128         should be configured in defaults.yaml)
129
130 :Optional parameters:
131
132     :git-url: URL to clone project from. (default: $GIT_URL/$GERRIT_PROJECT)
133     :submodule-timeout: Timeout (in minutes) for checkout operation.
134         (default: 10)
135     :gerrit_merge_triggers: Override Gerrit Triggers.
136
137 .. _lf-global-jjb-jenkins-cfg-merge:
138
139 Jenkins Configuration Merge
140 ---------------------------
141
142 Jenkins job to manage Global Jenkins configuration.
143
144 .. note::
145
146    Requires the jjbini file in Jenkins CFP to contain JJB 2.0 style
147    config definitions for "production" and "sandbox" systems.
148
149 :Template names:
150
151     - {project-name}-jenkins-cfg-merge
152     - gerrit-jenkins-cfg-merge
153     - github-jenkins-cfg-merge
154
155 :Optional parameters:
156
157     :branch: Git branch to build against. (default: master)
158     :cron: How often to run the job on a cron schedule. (default: @daily)
159     :git-url: URL to clone project from. (default: $GIT_URL/$GERRIT_PROJECT)
160     :jenkins-silos: Space separated list of Jenkins silos to update
161         configuration for as defined in ~/.config/jenkins_jobs/jenkins_jobs.ini
162         (default: production sandbox)
163
164 Typically this template is automatically pulled in by the
165 "{project-name}-ci-jobs" job-group and does not need to be explicitly called if
166 the job group is being used.
167
168 Minimal Example:
169
170 .. literalinclude:: ../../.jjb-test/lf-ci-jobs/jenkins-cfg-merge-minimal.yaml
171    :language: yaml
172
173 Full Example:
174
175 .. literalinclude:: ../../.jjb-test/lf-ci-jobs/jenkins-cfg-merge-full.yaml
176    :language: yaml
177
178 .. _jenkins-cfg-envvar:
179
180 Global Environment Variables
181 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
182
183 Global Environment Variables are managed via the
184 ``jenkins-config/global-vars-SILO.sh`` file in ci-management. Replace SILO with
185 the name of the Jenkins silo the variable configuration is for.
186
187 The format for this file is ``KEY=value`` for example::
188
189     GERRIT_URL=https://git.opendaylight.org/gerrit
190     GIT_BASE=git://devvexx.opendaylight.org/mirror/$PROJECT
191     GIT_URL=git://devvexx.opendaylight.org/mirror
192     JENKINS_HOSTNAME=vex-yul-odl-jenkins-2
193     LOGS_SERVER=https://logs.opendaylight.org
194     NEXUS_URL=https://nexus.opendaylight.org
195     ODLNEXUSPROXY=https://nexus.opendaylight.org
196     SILO=sandbox
197     SONAR_URL=https://sonar.opendaylight.org
198
199 Cloud Configuration
200 ^^^^^^^^^^^^^^^^^^^
201
202 This configuration requires the OpenStack Cloud plugin in Jenkins and is
203 currently the only cloud plugin supported.
204
205 OpenStack Cloud plugin version supported:
206
207 * 2.30 - 2.34
208 * 2.35 - 2.37
209
210 Cloud configuration are managed via a directory structure in ci-management as
211 follows:
212
213 - jenkins-config/clouds/openstack/
214 - jenkins-config/clouds/openstack/cattle/cloud.cfg
215 - jenkins-config/clouds/openstack/cattle/centos7-builder-2c-2g.cfg
216 - jenkins-config/clouds/openstack/cattle/centos7-builder-4c-4g.cfg
217 - jenkins-config/clouds/openstack/cattle/centos7-docker-4c-4g.cfg
218
219 The directory name inside of the "openstack" directory is used as the name of
220 the cloud configuration. In this case "cattle" is being used as the cloud name.
221
222 The ``cloud.cfg`` file is a special file used to configure the main cloud
223 configuration in the format ``KEY=value``.
224
225 :Cloud Parameters:
226
227     :CLOUD_URL: API endpoint URL for Keystone.
228         (default: "")
229     :CLOUD_IGNORE_SSL: Ignore unverified SSL certificates. (default: false)
230     :CLOUD_ZONE: OpenStack region to use. (default: "")
231     :CLOUD_CREDENTIAL_ID: Credential to use for authentication to OpenStack.
232         (default: "os-cloud")
233     :INSTANCE_CAP: Total number of instances the cloud will allow spin up.
234         (default: null)
235     :SANDBOX_CAP: Total number of instances the cloud will allow to
236         spin up. This applies to "sandbox" systems and overrides the
237         INSTANCE_CAP setting. (default: null)
238
239 :Template Parameters:
240
241     .. note::
242
243        In the case of template definitions of a parameter below is not passed
244        the one defined in default clouds will be inherited.
245
246     :IMAGE_NAME: The image name to use for this template. (required)
247     :HARDWARE_ID: OpenStack flavor to use. (required)
248
249     :LABELS: Labels to assign to the vm. (default: FILE_NAME)
250     :VOLUME_SIZE: Volume size to assign to vm. (default: "")
251     :HARDWARE_ID: Hardware Id to assign to vm. (default: "")
252     :NETWORK_ID: OpenStack network to use. (default: "")
253     :USER_DATA_ID: User Data to pass into the instance.
254         (default: jenkins-init-script)
255     :INSTANCE_CAP: Total number of instances of this type that can be launched
256         at one time. When defined in clouds.cfg it defines the total for the
257         entire cloud. (default: null)
258     :SANDBOX_CAP: Total number of instances of this type that can be launched
259         at one time. When defined in clouds.cfg it defines the total for the
260         entire cloud. This applies to "sandbox" systems and overrides the
261         INSTANCE_CAP setting. (default: null)
262     :FLOATING_IP_POOL: Floating ip pool to use. (default: "")
263     :SECURITY_GROUPS: Security group to use. (default: "default")
264     :AVAILABILITY_ZONE: OpenStack availability zone to use. (default: "")
265     :START_TIMEOUT: Number of milliseconds to wait for the agent to be
266         provisioned and connected. (default: 600000)
267     :KEY_PAIR_NAME: SSH Public Key Pair to use for authentication.
268         (default: jenkins-ssh)
269     :NUM_EXECUTORS: Number of executors to enable for the instance.
270         (default: 1)
271     :JVM_OPTIONS: JVM Options to pass to Java. (default: null)
272     :FS_ROOT: File system root for the workspace. (default: "/w")
273     :NODE_PROPERTIES: Node properties. (default: null)
274     :RETENTION_TIME: Number of minutes to wait for an idle slave to be used
275         again before it's removed. If set to -1, the slave will be kept
276         forever. (default: 0)
277     :CONNECTION_TYPE: The connection type for Jenkins to connect to the build
278         minion. Valid options: JNLP, SSH. (default: "SSH")
279     :CONFIG_TYPE: Configuration drive. (default: null)
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  .. _lf-global-jjb-jenkins-cfg-verify:
294
295 Jenkins Configuration Verify
296 ----------------------------
297
298 Jenkins job to verify the Global Jenkins configuration.
299
300 Requires the ``clouds-yaml`` file to be setup on the Jenkins host.
301
302 :Template names:
303
304     - {project-name}-jenkins-cfg-verify
305     - gerrit-jenkins-cfg-verify
306     - github-jenkins-cfg-verify
307
308 :Optional parameters:
309
310     :branch: Git branch to build against. (default: master)
311     :git-url: URL to clone project from. (default: $GIT_URL/$GERRIT_PROJECT)
312
313 This job is not part of the "{project-name}-ci-jobs" group. It must be called
314 explicitly.
315
316 Example:
317
318 .. literalinclude:: ../../.jjb-test/lf-ci-jobs/jenkins-cfg-verify.yaml
319    :language: yaml
320
321
322 .. _jenkins-sandbox-cleanup:
323
324 Jenkins Sandbox Cleanup
325 -----------------------
326
327 Cleanup Jenkins Sandbox of jobs and views periodically.
328
329 :Template names:
330
331     - {project-name}-jenkins-sandbox-cleanup
332     - gerrit-jenkins-sandbox-cleanup
333     - github-jenkins-sandbox-cleanup
334
335 :Comment Trigger: NONE
336
337 :Required parameters:
338
339     :build-node: The node to run build on.
340     :jenkins-ssh-credential: Credential to use for SSH. (Generally
341         should be configured in defaults.yaml)
342
343 :Optional parameters:
344
345     :cron: Schedule to run job. (default: '0 8 * * 6')
346
347
348 .. _jjb-deploy:
349
350 JJB Deploy Job
351 --------------
352
353 Deploy jobs to jenkins-sandbox system via code review comment.
354
355 This job checks out the current code review patch and then runs a
356 ``jenkins-jobs update`` to push a patch defined by the comment.
357
358 :Template names:
359
360     - {project-name}-jjb-deploy-job
361     - gerrit-jjb-deploy-job
362     - github-jjb-deploy-job
363
364 :Comment Trigger: jjb-deploy JOB_NAME
365
366     .. note::
367
368        The JJB Deploy Job is configured to trigger only if the Gerrit comment
369        starts with the `jjb-deploy` keyword.
370
371        Example of a valid command in Gerrit comment that triggers the job:
372
373        ``jjb-deploy builder-jjb-*``
374
375        Example of a invalid command in Gerrit comment that would _not_ trigger
376        the job:
377
378        ``Update the job. jjb-deploy builder-jjb-*``
379
380        JOB_NAME can include the * wildcard character to push multiple jobs
381        matching the pattern. For example ``jjb-deploy builder-jjb-*`` will push
382        all builder-jjb-* jobs to the sandbox system.
383
384 :Required parameters:
385
386     :build-node: The node to run build on.
387     :jenkins-ssh-credential: Credential to use for SSH. (Generally
388         should be configured in defaults.yaml)
389
390 :Optional parameters:
391
392     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
393     :gerrit_jjb_deploy_job_triggers: Override Gerrit Triggers.
394
395
396 .. _jjb-merge:
397
398 JJB Merge
399 ---------
400
401 Runs `jenkins-jobs update` to update production job configuration
402
403 :Template Names:
404     - {project-name}-jjb-merge
405     - gerrit-jjb-merge
406     - github-jjb-merge
407
408 :Comment Trigger: remerge
409
410 :Required parameters:
411
412     :build-node: The node to run build on.
413     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
414         be configured in defaults.yaml)
415
416 :Optional parameters:
417
418     :branch: Git branch to fetch for the build. (default: master)
419     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
420     :build-timeout: Timeout in minutes before aborting build. (default: 10)
421     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
422     :jjb-cache: JJB cache location. (default: $HOME/.cache/jenkins_jobs)
423     :jjb-workers: Number of threads to run **update** with. Set to 0 by default
424         which is equivalent to the number of available CPU cores. (default: 0)
425     :jjb-version: JJB version to install. (default: see job-template)
426     :stream: Keyword that can be used to represent a release code-name.
427         Often the same as the branch. (default: master)
428     :submodule-recursive: Whether to checkout submodules recursively.
429         (default: true)
430     :submodule-timeout: Timeout (in minutes) for checkout operation.
431         (default: 10)
432     :submodule-disable: Disable submodule checkout operation.
433         (default: false)
434
435     :gerrit_merge_triggers: Override Gerrit Triggers.
436     :gerrit_trigger_file_paths: Override file paths which can be used to
437         filter which file modifications will trigger a build.
438         (default defined by lf_jjb_common)
439
440
441 .. _jjb-verify:
442
443 JJB Verify
444 ----------
445
446 Runs `jenkins-jobs test` to validate JJB syntax. Optionally validates
447 build-node labels used in templates and job definitions.
448
449 :Template Names:
450     - {project-name}-jjb-verify
451     - gerrit-jjb-verify
452     - github-jjb-verify
453
454 :Comment Trigger: recheck|reverify
455
456 :Required parameters:
457
458     :build-node: The node to run build on.
459     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
460         be configured in defaults.yaml)
461
462 :Optional parameters:
463
464     :branch: Git branch to fetch for the build. (default: master)
465     :build-concurrent: Whether or not to allow this job to run multiple jobs
466         simultaneously. (default: true)
467     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
468     :build-node-label-check: Whether to check build-node labels in jobs
469         against node names in cloud config files (default: false)
470     :build-node-label-list: Space-separated list of external build-node
471         labels not present in cloud config files (default: "")
472     :build-timeout: Timeout in minutes before aborting build. (default: 10)
473     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
474     :jjb-cache: JJB cache location. (default: $HOME/.cache/jenkins_jobs)
475     :jjb-version: JJB version to install. (default: see job-template)
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     :submodule-disable: Disable submodule checkout operation.
483         (default: false)
484     :throttle_categories: List of categories to throttle by.
485     :throttle-enabled: Whether or not to enable throttling on the job.
486         (default: true)
487     :throttle-max-per-node: Max jobs to run on the same node. (default: 1)
488     :throttle-max-total: Max jobs to run across the entire project. - 0
489         means 'unlimited' (default: 0)
490     :throttle-option: Throttle by the project or by list of categories
491         defined in the throttle plugin configuration. (options: 'project',
492         'category'; default: project)
493
494     :gerrit_verify_triggers: Override Gerrit Triggers.
495     :gerrit_trigger_file_paths: Override file paths which can be used to
496         filter which file modifications will trigger a build.
497         (default defined by lf_jjb_common)
498
499 .. _jjb-verify-upstream-gjjb:
500
501 JJB Verify Upstream Global JJB
502 ------------------------------
503
504 Runs ``jenkins-jobs test`` to validate JJB syntax for upstream global-jjb
505 patches. This job is useful to notify upstream that they may be breaking
506 project level jobs.
507
508 :Template Names:
509     - {project-name}-jjb-verify-upstream-gjjb
510     - gerrit-jjb-verify-upstream-gjjb
511
512 :Comment Trigger: recheck|reverify
513
514 :Required parameters:
515
516     :build-node: The node to run build on.
517     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
518         be configured in defaults.yaml)
519
520 :Optional parameters:
521
522     :branch: Git branch to fetch for the build. (default: master)
523     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
524     :build-timeout: Timeout in minutes before aborting build. (default: 10)
525     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
526     :jjb-cache: JJB cache location. (default: $HOME/.cache/jenkins_jobs)
527     :jjb-version: JJB version to install. (default: see job-template)
528     :stream: Keyword that can be used to represent a release code-name.
529         Often the same as the branch. (default: master)
530
531 .. _info-yaml-verify:
532
533 Info YAML Verify
534 ----------------
535
536 Info YAML Verify job validates that INFO.yaml file changes are kept isolated from
537 other file changes. Verifies INFO.yaml files follow the schema defined in
538 `lfit/releng-global-jjb/schema/info-schema.yaml`.
539
540 :Template Names:
541     - {project-name}-info-yaml-verify
542     - gerrit-info-yaml-verify
543     - github-info-yaml-verify
544
545 :Required parameters:
546
547     :build-node: The node to run build on.
548     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
549         be configured in defaults.yaml)
550
551 :Optional parameters:
552
553     :branch: Git branch to fetch for the build. (default: master)
554     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
555     :build-timeout: Timeout in minutes before aborting build. (default: 10)
556     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
557     :stream: Keyword that can be used to represent a release code-name.
558         Often the same as the branch. (default: master)
559     :submodule-recursive: Whether to checkout submodules recursively.
560         (default: true)
561     :submodule-timeout: Timeout (in minutes) for checkout operation.
562         (default: 10)
563     :submodule-disable: Disable submodule checkout operation.
564         (default: false)
565
566     :gerrit_verify_triggers: Override Gerrit Triggers.
567
568 .. _license-checker:
569
570 License Checker
571 ---------------
572
573 Job to scan projects for files missing license headers.
574
575 :Template Names:
576     - {project-name}-license-check
577     - gerrit-license-check
578     - github-license-check
579
580 :Optional parameters:
581
582     :build-timeout: Timeout in minutes before aborting build. (default: 15)
583     :file-patterns: Space-separated list of file patterns to scan.
584         (default: \*.go \*.groovy \*.java \*.py \*.sh)
585     :spdx-disable: Disable the SPDX-Identifier checker. (default: false)
586     :lhc-version: Version of LHC to use. (default: 0.2.0)
587     :license-exclude-paths: Comma-separated list of paths to exclude from the
588         license checker. The paths used here will be matched using a contains
589         rule so it is best to be as precise with the path as possible.
590         For example a path of '/src/generated/' will be searched as
591         '**/src/generated/**'.
592         Example: org/opendaylight/yang/gen,protobuff/messages
593         (default: '')
594     :licenses-allowed: Comma-separated list of allowed licenses.
595         (default: Apache-2.0,EPL-1.0,MIT)
596     :project-pattern: The ANT based pattern for Gerrit Trigger to choose which
597         projects to trigger job against. (default: '**')
598
599 .. _gjjb-openstack-cron:
600
601 OpenStack Cron
602 --------------
603
604 Cron job that runs regularly to perform periodic tasks against OpenStack.
605
606 This job requires a Config File Provider file named ``clouds-yaml`` available
607 containing the credentials for the cloud.
608
609 :Template Names:
610     - {project-name}-openstack-cron
611     - gerrit-openstack-cron
612     - github-openstack-cron
613
614 :Required parameters:
615
616     :build-node: The node to run build on.
617     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
618         be configured in defaults.yaml)
619     :jenkins-urls: URLs to Jenkins systems to check for active builds.
620
621 :Optional parameters:
622
623     :branch: Git branch to fetch for the build. (default: master)
624     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
625     :build-timeout: Timeout in minutes before aborting build. (default: 90)
626     :cron: Time when the packer image should be rebuilt (default: @hourly)
627     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
628     :openstack-cloud: OS_CLOUD setting to pass to openstack client.
629         (default: vex)
630     :openstack-image-cleanup: Whether or not to run the image cleanup script.
631         (default: true)
632     :openstack-image-cleanup-age: Age in days of image before marking it for
633         removal. (default: 30)
634     :openstack-image-protect: Whether or not to run the image protect script.
635         (default: true)
636     :openstack-server-cleanup: Whether or not to run the server cleanup script.
637         (default: true)
638     :openstack-stack-cleanup: Whether or not to run the stack cleanup script.
639         (default: true)
640     :openstack-volume-cleanup: Whether or not to run the volume cleanup script.
641         (default: true)
642     :stream: Keyword that can be used to represent a release code-name.
643         Often the same as the branch. (default: master)
644     :submodule-recursive: Whether to checkout submodules recursively.
645         (default: true)
646     :submodule-timeout: Timeout (in minutes) for checkout operation.
647         (default: 10)
648     :submodule-disable: Disable submodule checkout operation.
649         (default: false)
650
651 Minimal Example:
652
653 .. literalinclude:: ../../.jjb-test/lf-ci-jobs/openstack-cron-minimal.yaml
654
655 Full Example:
656
657 .. literalinclude:: ../../.jjb-test/lf-ci-jobs/openstack-cron-full.yaml
658
659 .. _gjjb-openstack-update-cloud-image:
660
661 OpenStack Update Cloud Image
662 ----------------------------
663
664 This job finds and updates OpenStack cloud images on the ci-management source
665 repository.
666
667 The job is triggered in two ways:
668
669 1. When packer merge job completes, the new image name created is passed
670    down to the job.
671 2. When the job is triggered manually to update all new images.
672
673 When the job is triggered through an upstream packer merge job, this only
674 generates a change request for the new image built.
675
676 When the job is triggered manually, this job finds the latest images on
677 OpenStack cloud and compares them with the images currently used in the source
678 ci-management source repository. If the compared images have newer
679 time stamps are **all** updated through a change request.
680
681 This job requires a Jenkins configuration merge and verify job setup and
682 working on Jenkins.
683
684 :Template Names:
685     - {project-name}-openstack-update-cloud-image
686     - gerrit-openstack-update-cloud-image
687     - github-openstack-update-cloud-image
688
689 :Required parameters:
690
691     :build-node: The node to run build on.
692     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
693         be configured in defaults.yaml)
694     :new-image-name: Name of new image name passed from packer merge job or
695         set to 'all' to update all images. (default: all)
696
697 :Optional parameters:
698
699     :branch: Git branch to fetch for the build. (default: master)
700     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
701     :build-timeout: Timeout in minutes before aborting build. (default: 90)
702     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
703     :openstack-cloud: OS_CLOUD setting to pass to openstack client.
704         (default: vex)
705     :stream: Keyword that can be used to represent a release code-name.
706         Often the same as the branch. (default: master)
707     :submodule-recursive: Whether to checkout submodules recursively.
708         (default: true)
709     :submodule-timeout: Timeout (in minutes) for checkout operation.
710         (default: 10)
711     :submodule-disable: Disable submodule checkout operation.
712         (default: false)
713     :update-cloud-image: Submit a change request to update new built cloud
714         image to Jenkins. (default: false)
715
716 Minimal Example:
717
718 .. literalinclude:: ../../.jjb-test/lf-ci-jobs/openstack-update-cloud-image-minimal.yaml
719
720 Full Example:
721
722 .. literalinclude:: ../../.jjb-test/lf-ci-jobs/openstack-update-cloud-image-full.yaml
723
724
725 .. _gjjb-packer-merge:
726
727 Packer Merge
728 ------------
729
730 Packer Merge job runs `packer build` to build system images in the cloud.
731
732 :Template Names:
733     - {project-name}-packer-merge-{platforms}-{templates}
734     - gerrit-packer-merge
735     - github-packer-merge
736
737 :Comment Trigger: remerge
738
739 :Required parameters:
740
741     :build-node: The node to run build on.
742     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
743         be configured in defaults.yaml)
744     :mvn-settings: The name of settings file containing credentials for
745         the project.
746     :platforms: Platform or distribution to build. Typically json file
747         found in the packer/vars directory. (Example: centos)
748     :template: System template to build. Typically shell script found in
749         the packer/provision directory. (Example: java-builder)
750
751 :Optional parameters:
752
753     :cron: Time when the packer image should be rebuilt (default: @monthly)
754     :branch: Git branch to fetch for the build. (default: master)
755     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
756     :build-timeout: Timeout in minutes before aborting build. (default: 90)
757     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
758     :openstack: Packer template uses an OpenStack builder (default: true).
759     :openstack-cloud: Sets OS_CLOUD variable to the value of this parameter.
760         (default: vex).
761     :packer-cloud-settings: Name of settings file containing credentials
762         for the cloud that packer will build on. (default: packer-cloud-env)
763     :packer-version: Version of packer to install / use in build. (default: 1.0.2)
764     :stream: Keyword that can be used to represent a release code-name.
765         Often the same as the branch. (default: master)
766     :submodule-recursive: Whether to checkout submodules recursively.
767         (default: true)
768     :submodule-timeout: Timeout (in minutes) for checkout operation.
769         (default: 10)
770     :submodule-disable: Disable submodule checkout operation.
771         (default: false)
772
773     :gerrit_verify_triggers: Override Gerrit Triggers.
774     :update-cloud-image: Submit a change request to update new built cloud
775         image to Jenkins. (default: false)
776
777
778 Test an in-progress patch
779 ^^^^^^^^^^^^^^^^^^^^^^^^^
780
781 To test an in-progress patch from a GitHub Pull Request. Upload this
782 job to the :doc:`Jenkins Sandbox <lfdocs:jenkins-sandbox>`. Then when manually
783 building the job replace the GERRIT_REFSPEC parameter with the GitHub Pull
784 Request number of the patch you would like to test.
785
786 Example GitHub:
787
788 .. code-block:: none
789
790    GERRIT_REFSPEC: origin/pr/49/merge
791
792 .. _gjjb-packer-verify:
793
794 Packer Verify
795 -------------
796
797 Packer Verify job runs `packer validate` to verify packer configuration.
798
799 :Template Names:
800     - {project-name}-packer-verify
801     - gerrit-packer-verify
802     - github-packer-verify
803
804 :Comment Trigger: recheck|reverify
805
806 :Required parameters:
807
808     :build-node: The node to run build on.
809     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
810         be configured in defaults.yaml)
811     :mvn-settings: The name of settings file containing credentials for
812         the project.
813
814 :Optional parameters:
815
816     :branch: Git branch to fetch for the build. (default: master)
817     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
818     :build-timeout: Timeout in minutes before aborting build. (default: 10)
819     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
820     :openstack: Packer template uses an OpenStack builder (default: true).
821     :openstack-cloud: Sets OS_CLOUD variable to the value of this parameter.
822         (default: vex).
823     :packer-cloud-settings: Name of settings file containing credentials
824         for the cloud that packer will build on. (default: packer-cloud-env)
825     :packer-version: Version of packer to install / use in build. (default: 1.0.2)
826     :stream: Keyword that can be used to represent a release code-name.
827         Often the same as the branch. (default: master)
828     :submodule-recursive: Whether to checkout submodules recursively.
829         (default: true)
830     :submodule-timeout: Timeout (in minutes) for checkout operation.
831         (default: 10)
832     :submodule-disable: Disable submodule checkout operation.
833         (default: false)
834
835     :gerrit_verify_triggers: Override Gerrit Triggers.
836     :gerrit_trigger_file_paths: Override file paths which can be used to
837         filter which file modifications will trigger a build.
838
839
840 Puppet Verify
841 -------------
842
843 Runs puppet-lint in the ``puppet-dir`` directory. puppet-lint runs recursively,
844 the base directory is usually the best place to run from.
845
846 :Template Names:
847
848     - {project-name}-puppet-verify
849     - gerrit-puppet-verify
850     - github-puppet-verify
851
852 :Comment Trigger: recheck|reverify
853
854 :Required Parameters:
855
856     :build-node: The node to run build on.
857     :jenkins-ssh-credential: Credential to use for SSH. (Generally set
858         in defaults.yaml)
859
860 :Optional Parameters:
861
862     :branch: The branch to build against. (default: master)
863     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
864     :build-timeout: Timeout in minutes before aborting build. (default: 15)
865     :gerrit_trigger_file_paths: Override file paths which used to filter which
866         file modifications will trigger a build. Refer to JJB documentation for
867         "file-path" details.
868         https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit
869     :git-url: URL clone project from. (default: $GIT_URL/$GERRIT_PROJECT)
870     :puppet-dir: Directory containing the project's puppet module(s) relative
871         to the workspace.
872         (default: '')
873     :puppet-lint-version: Version of puppet-lint to use for testing.
874         (default: 2.3.6)
875     :stream: Keyword representing a release code-name.
876         Often the same as the branch. (default: master)
877     :submodule-recursive: Whether to checkout submodules recursively.
878         (default: true)
879     :submodule-timeout: Timeout (in minutes) for checkout operation.
880         (default: 10)
881     :submodule-disable: Disable submodule checkout operation.
882         (default: false)
883
884
885 Sonar
886 -----
887
888 Runs the Jenkins SonarQube Scanner plug-in to analyze code for bugs,
889 code smells and security vulnerabilities, and to upload the result
890 (possibly including code-coverage statistics) to a SonarQube server
891 or to SonarCloud.io.
892
893 Requires ``SonarQube Scanner for Jenkins``
894
895 One of the optional parameters sonar-project-file and sonar-properties
896 must be supplied; they cannot both be empty.
897
898 Plug-in configurations
899     Manage Jenkins --> Configure System --> SonarQube servers
900         - Name: Sonar (fixed)
901         - Server URL: https://sonar.server.org/ or https://sonarcloud.io
902         - Server authentication token: none for local, API token (saved as a
903           "secret text" credential) for Sonarcloud
904
905     Manage Jenkins --> Global Tool Configuration --> SonarQube Scanner
906         - Name: SonarQube Scanner (fixed)
907         - Install automatically
908         - Select latest version
909
910 .. note:: Sonar properties can be set directly in the job definition by
911    setting the sonar-project-file to ``""`` and adding all properties under
912    ``sonar-properties``.
913
914 :Template Names:
915
916     - {project-name}-sonar
917     - gerrit-sonar
918     - github-sonar
919
920 :Optional Parameters:
921     :sonar-task: Sonar task to run. (default: "")
922     :sonar-project-file: The filename for the project's properties
923         (default: "sonar-project.properties")
924     :sonar-properties: Sonar configuration properties. (default: "")
925     :sonar-java-opts: JVM options. (default: "")
926     :sonar-additional-args: Additional command line arguments. (default: "")
927
928
929 Sonar with Prescan
930 ------------------
931
932 The same as the Sonar job above, except the caller also defines a builder
933 called ``lf-sonar-prescan``, in which they can put any builders that they want
934 to run prior to the Sonar scan.
935
936 .. code-block:: yaml
937
938    - builder:
939        name: lf-sonar-prescan
940        builders:
941          - shell: "# Pre-scan shell script"
942
943 :Template Names:
944
945     - {project-name}-sonar-prescan
946     - gerrit-sonar-prescan
947     - github-sonar-prescan
948
949 :Required Parameters:
950     :lf-sonar-prescan: A builder that will run prior to the Sonar scan.
951
952 :Optional Parameters:
953     :sonar-task: Sonar task to run. (default: "")
954     :sonar-project-file: The filename for the project's properties
955         (default: "sonar-project.properties")
956     :sonar-properties: Sonar configuration properties. (default: "")
957     :sonar-java-opts: JVM options. (default: "")
958     :sonar-additional-args: Additional command line arguments. (default: "")
959
960
961 Sonar with Prescan Script
962 -------------------------
963
964 The same as the Sonar job above, except the caller must supply a shell script
965 to run prior to the Sonar scan. This is commonly used to install prerequisites,
966 build the project, execute unit tests and generate a code-coverage report.
967
968 :Template Names:
969
970     - {project-name}-sonar-prescan-script
971     - gerrit-sonar-prescan-script
972     - github-sonar-prescan-script
973
974 :Required Parameters:
975     :sonar-prescan-script: A shell script that will run prior to the Sonar scan.
976
977 :Optional Parameters:
978     :sonar-task: Sonar task to run. (default: "")
979     :sonar-project-file: The filename for the project's properties.
980         (default: "sonar-project.properties")
981     :sonar-properties: Sonar configuration properties. (default: "")
982     :sonar-java-opts: JVM options. (default: "")
983     :sonar-additional-args: Additional command line arguments. (default: "")