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