Configurable Timed Trigger for Packer Merge 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}-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-common
85 ----------------
86
87 Common packer configuration.
88
89 lf-packer-file-paths
90 --------------------
91
92 Gerrit file-paths for packer jobs.
93
94 lf-packer-parameters
95 --------------------
96
97 Parameters useful for packer related tasks.
98
99 :Parameters:
100
101     :packer-version: Version of packer to install / use.
102         (shell: PACKER_VERSION)
103
104 lf-packer-verify-file-paths
105 ---------------------------
106
107 Gerrit file-paths for packer verify jobs.
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 .. _jenkins-cfg-envvar:
164
165 Global Environment Variables
166 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
167
168 Global Environment Variables are managed via the
169 ``jenkins-config/global-vars-SILO.sh`` file in ci-management. Replace SILO with
170 the name of the Jenkins silo the variable configuration is for.
171
172 The format for this file is ``KEY=value`` for example::
173
174     GERRIT_URL=https://git.opendaylight.org/gerrit
175     GIT_BASE=git://devvexx.opendaylight.org/mirror/$PROJECT
176     GIT_URL=git://devvexx.opendaylight.org/mirror
177     JENKINS_HOSTNAME=vex-yul-odl-jenkins-2
178     LOGS_SERVER=https://logs.opendaylight.org
179     NEXUS_URL=https://nexus.opendaylight.org
180     ODLNEXUSPROXY=https://nexus.opendaylight.org
181     SILO=sandbox
182     SONAR_URL=https://sonar.opendaylight.org
183
184 Cloud Configuration
185 ^^^^^^^^^^^^^^^^^^^
186
187 This configuration requires the OpenStack Cloud plugin in Jenkins and is
188 currently the only cloud plugin supported.
189
190 OpenStack Cloud plugin version supported:
191
192 * 2.30
193 * 2.31
194 * 2.32
195 * 2.33
196 * 2.34
197
198 Cloud configuration are managed via a directory structure in ci-management as
199 follows:
200
201 - jenkins-config/clouds/openstack/
202 - jenkins-config/clouds/openstack/cattle/cloud.cfg
203 - jenkins-config/clouds/openstack/cattle/centos7-builder-2c-2g.cfg
204 - jenkins-config/clouds/openstack/cattle/centos7-builder-4c-4g.cfg
205 - jenkins-config/clouds/openstack/cattle/centos7-docker-4c-4g.cfg
206
207 The directory name inside of the "openstack" directory is used as the name of
208 the cloud configuration. In this case "cattle" is being used as the cloud name.
209
210 The ``cloud.cfg`` file is a special file used to configure the main cloud
211 configuration in the format ``KEY=value``.
212
213 :Cloud Parameters:
214
215     :CLOUD_URL: API endpoint URL for Keystone.
216         (default: "")
217     :CLOUD_IGNORE_SSL: Ignore unverified SSL certificates. (default: false)
218     :CLOUD_ZONE: OpenStack region to use. (default: "")
219     :CLOUD_CREDENTIAL_ID: Credential to use for authentication to OpenStack.
220         (default: "os-cloud")
221     :INSTANCE_CAP: Total number of instances the cloud will allow spin up.
222         (default: null)
223     :SANDBOX_CAP: Total number of instances the clodu will allow to
224         spin up. This applies to "sandbox" systems and overrides the
225         INSTANCE_CAP setting. (default: null)
226
227 :Template Parameters:
228
229     .. note::
230
231        In the case of template definitions of a parameter below is not passed
232        the one defined in default clouds will be inherited.
233
234     :IMAGE_NAME: The image name to use for this template.
235         (default: "")
236     :LABELS: Labels to assign to the vm. (default: FILE_NAME)
237     :HARDWARE_ID: OpenStack flavor to use. (default: "")
238     :NETWORK_ID: OpenStack network to use. (default: "")
239     :USER_DATA_ID: User Data to pass into the instance.
240         (default: jenkins-init-script)
241     :INSTANCE_CAP: Total number of instances of this type that can be launched
242         at one time. When defined in clouds.cfg it defines the total for the
243         entire cloud. (default: null)
244     :SANDBOX_CAP: Total number of instances of this type that can be launched
245         at one time. When defined in clouds.cfg it defines the total for the
246         entire cloud. This applies to "sandbox" systems and overrides the
247         INSTANCE_CAP setting. (default: null)
248     :FLOATING_IP_POOL: Floating ip pool to use. (default: "")
249     :SECURITY_GROUPS: Security group to use. (default: "default")
250     :AVAILABILITY_ZONE: OpenStack availability zone to use. (default: "")
251     :START_TIMEOUT: Number of milliseconds to wait for the agent to be
252         provisioned and connected. (default: 600000)
253     :KEY_PAIR_NAME: SSH Public Key Pair to use for authentication.
254         (default: jenkins)
255     :NUM_EXECUTORS: Number of executors to enable for the instance.
256         (default: 1)
257     :JVM_OPTIONS: JVM Options to pass to Java. (default: "")
258     :FS_ROOT: File system root for the workspace. (default: "/w")
259     :RETENTION_TIME: Number of minutes to wait for an idle slave to be used
260         again before it's removed. If set to -1, the slave will be kept
261         forever. (default: 0)
262
263 For a live example see the OpenDaylight project jenkins-config directory.
264 https://github.com/opendaylight/releng-builder/tree/master/jenkins-config
265
266 Troubleshooting
267 ^^^^^^^^^^^^^^^
268
269 :Cloud Configuration:
270
271     The directory ``groovy-inserts`` contains the groovy script output that is
272     used to push to Jenkins. In the event of a job failure this file can be
273     inspected.
274
275
276 JJB Deploy Job
277 --------------
278
279 Deploy jobs to jenkins-sandbox system via code review comment
280
281 This job checks out the current code review patch and then runs a
282 `jenkins-jobs update` to push a patch defined by the comment.
283
284 :Template names:
285
286     - {project-name}-jjb-deploy-job
287     - gerrit-jjb-deploy-job
288     - github-jjb-deploy-job
289
290 :Comment Trigger: jjb-deploy JOB_NAME
291
292     .. note::
293
294        JOB_NAME can include the * wildcard character to push multiple jobs
295        matching the pattern. For example `jjb-deploy builder-jjb-*`` will push
296        all builder-jjb-* jobs to the sandbox system.
297
298 :Required parameters:
299
300     :build-node: The node to run build on.
301     :jenkins-ssh-credential: Credential to use for SSH. (Generally
302         should be configured in defaults.yaml)
303
304 :Optional parameters:
305
306     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
307     :gerrit_jjb_deploy_job_triggers: Override Gerrit Triggers.
308
309
310 JJB Merge
311 ---------
312
313 Runs `jenkins-jobs update` to update production job configuration
314
315 :Template Names:
316     - {project-name}-jjb-merge
317     - gerrit-jjb-merge
318     - github-jjb-merge
319
320 :Required parameters:
321
322     :build-node: The node to run build on.
323     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
324         be configured in defaults.yaml)
325     :mvn-settings: The name of settings file containing credentials for
326         the project.
327
328 :Optional parameters:
329
330     :branch: Git branch to fetch for the build. (default: master)
331     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
332     :build-timeout: Timeout in seconds before aborting build. (default: 10)
333     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
334     :stream: Keyword that can be used to represent a release code-name.
335         Often the same as the branch. (default: master)
336     :submodule-recursive: Whether to checkout submodules recursively.
337         (default: true)
338
339     :gerrit_merge_triggers: Override Gerrit Triggers.
340     :gerrit_trigger_file_paths: Override file paths which can be used to
341         filter which file modifications will trigger a build.
342         (default defined by lf_jjb_common)
343
344
345 JJB Verify
346 ----------
347
348 Runs `jenkins-jobs test` to validate JJB syntax
349
350 :Template Names:
351     - {project-name}-jjb-verify
352     - gerrit-jjb-verify
353     - github-jjb-verify
354
355 :Required parameters:
356
357     :build-node: The node to run build on.
358     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
359         be configured in defaults.yaml)
360     :mvn-settings: The name of settings file containing credentials for
361         the project.
362
363 :Optional parameters:
364
365     :branch: Git branch to fetch for the build. (default: master)
366     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
367     :build-timeout: Timeout in seconds before aborting build. (default: 10)
368     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
369     :stream: Keyword that can be used to represent a release code-name.
370         Often the same as the branch. (default: master)
371     :submodule-recursive: Whether to checkout submodules recursively.
372         (default: true)
373
374     :gerrit_verify_triggers: Override Gerrit Triggers.
375     :gerrit_trigger_file_paths: Override file paths which can be used to
376         filter which file modifications will trigger a build.
377         (default defined by lf_jjb_common)
378
379
380 .. _gjjb-packer-merge:
381
382 Packer Merge
383 ------------
384
385 Packer Merge job runs `packer build` to build system images in the cloud.
386
387 :Template Names:
388     - {project-name}-packer-merge-{platforms}-{templates}
389     - gerrit-packer-merge
390     - github-packer-merge
391
392 :Required parameters:
393
394     :build-node: The node to run build on.
395     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
396         be configured in defaults.yaml)
397     :mvn-settings: The name of settings file containing credentials for
398         the project.
399     :platforms: Platform or distribution to build. Typically json file
400         found in the packer/vars directory. (Example: centos)
401     :template: System template to build. Typically shell script found in
402         the packer/provision directory. (Example: java-builder)
403
404 :Optional parameters:
405
406     :cron: Time when the packer image should be rebuilt (default: @monthly)
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     :packer-cloud-settings: Name of settings file containing credentials
412         for the cloud that packer will build on. (default: packer-cloud-env)
413     :packer-version: Version of packer to install / use in build. (default: 1.0.2)
414     :stream: Keyword that can be used to represent a release code-name.
415         Often the same as the branch. (default: master)
416     :submodule-recursive: Whether to checkout submodules recursively.
417         (default: true)
418
419     :gerrit_verify_triggers: Override Gerrit Triggers.
420
421
422 .. _gjjb-packer-verify:
423
424 Packer Verify
425 -------------
426
427 Packer Verify job runs `packer validate` to verify packer configuration.
428
429 :Template Names:
430     - {project-name}-packer-verify
431     - gerrit-packer-verify
432     - github-packer-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     :mvn-settings: The name of settings file containing credentials for
440         the project.
441
442 :Optional parameters:
443
444     :branch: Git branch to fetch for the build. (default: master)
445     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
446     :build-timeout: Timeout in seconds before aborting build. (default: 10)
447     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
448     :packer-cloud-settings: Name of settings file containing credentials
449         for the cloud that packer will build on. (default: packer-cloud-env)
450     :packer-version: Version of packer to install / use in build. (default: 1.0.2)
451     :stream: Keyword that can be used to represent a release code-name.
452         Often the same as the branch. (default: master)
453     :submodule-recursive: Whether to checkout submodules recursively.
454         (default: true)
455
456     :gerrit_verify_triggers: Override Gerrit Triggers.
457     :gerrit_trigger_file_paths: Override file paths which can be used to
458         filter which file modifications will trigger a build.