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