Add CMake templates to build/publish DEB/RPM pkgs
[releng/global-jjb.git] / docs / jjb / lf-macros.rst
1 #############
2 Global Macros
3 #############
4
5 Builders
6 ========
7
8 comment-to-gerrit
9 -----------------
10
11 This macro will post a comment to the gerrit patchset if the build
12 creates a file named gerrit_comment.txt
13 To use this macro add it to the list of builders.
14
15
16 lf-fetch-dependent-patches
17 --------------------------
18
19 Fetch all patches provided via comment trigger
20
21 This macro will fetch all patches provided via comment trigger and will
22 create a list of projects from those patches via environment variable
23 called DEPENDENCY_BUILD_ORDER which can be used if necessary to build
24 projects in the specified order. The order is determined by first patch
25 instance for a project in the patch list.
26
27 lf-license-check
28 ----------------
29
30 Checks files for
31
32 :Required parameters:
33
34     :file-patterns: Space-separated list of file patterns to scan.
35         For example: \*.go \*.groovy \*.java \*.py \*.sh
36     :spdx-disable: Disable the SPDX-Identifier checker.
37     :lhc-version: Version of LHC to use.
38     :license-exclude-paths: Comma-separated list of paths to exclude from the
39         license checker. The paths used here will be matched using a contains
40         rule so it is best to be as precise with the path as possible.
41         For example a path of '/src/generated/' will be searched as
42         '**/src/generated/**'.
43         Example: org/opendaylight/yang/gen,protobuff/messages
44     :licenses-allowed: Comma-separated list of allowed licenses.
45         For example: Apache-2.0,EPL-1.0,MIT
46
47 lf-infra-create-netrc
48 ---------------------
49
50 Create a ~/.netrc file from a Maven settings.xml
51
52 :Required parameters:
53
54     :server-id: The id of a server as defined in settings.xml.
55
56 :Optional parameters:
57
58     :ALT_NEXUS_SERVER: URL of custom nexus server.
59         If set this will take precedence.
60         Use this to point at nexus3.$PROJECTDOMAIN
61         for example.
62
63 lf-infra-deploy-maven-file
64 --------------------------
65
66 Deploy files to a repository.
67
68 :Required parameters:
69
70     :global-settings-file: Global settings file to use.
71     :group-id: Group ID of the repository.
72     :maven-repo-url: URL of a Maven repository to upload to.
73     :mvn-version: Version of Maven to use.
74     :repo-id: Repository ID
75     :settings-file: Maven settings file to use.
76     :upload-files-dir: Path to directory containing one or more files
77
78 lf-infra-docker-login
79 ---------------------
80
81 Login into a custom hosted docker registry and / or docker.io
82
83 The Jenkins system should have the following global variables defined
84
85 :Environment variables:
86
87     :DOCKER_REGISTRY: The DNS address of the registry (IP or FQDN)
88         ex: nexus3.example.com (GLOBAL variable)
89
90     :REGISTRY_PORTS: Required if DOCKER_REGISTRY is set. Space separated list
91         of the registry ports to login to. ex: 10001 10002 10003 10004
92         (GLOBAL variable)
93
94     :DOCKERHUB_EMAIL: If this variable is set then an attempt to login to
95         DockerHub (docker.io) will be also made. It should be set to the email
96         address for the credentials that will get looked up. Only _one_
97         credential will ever be found in the maven settings file for DockerHub.
98         (GLOBAL variable)
99
100 lf-infra-gpg-verify-git-signature
101 ---------------------------------
102
103 Verify gpg signature of the latest commit message in $WORKSPACE.
104 This command assumes that $WORKSPACE is a git repo.
105
106 lf-infra-pre-build
107 ------------------
108
109 Macro that runs before all builders to prepare the system for job use.
110
111 lf-infra-package-listing
112 ------------------------
113
114 Lists distro level packages.
115
116 lf-infra-packer-build
117 ---------------------
118
119 Run `packer build` to build system images.
120
121 :Required parameters:
122
123     :openstack: Packer template uses an OpenStack builder (true|false).
124     :openstack-cloud: Sets OS_CLOUD variable to the value of this parameter.
125     :packer-version: Version of packer to use.
126     :platform: Build platform as found in the vars directory.
127     :template: Packer template to build as found in the templates directory.
128
129 :Optional parameters:
130
131     :update-cloud-image: Submit a change request to update new built cloud
132         image to Jenkins.
133
134 lf-infra-packer-validate
135 ------------------------
136
137 Run `packer validate` to verify packer configuration.
138
139 :Required parameters:
140
141     :openstack: Packer template uses an OpenStack builder (true|false).
142     :openstack-cloud: Sets OS_CLOUD variable to the value of this parameter.
143     :packer-cloud-settings: Cloud configuration file. Loaded on the build
144         server as CLOUDENV environment variable.
145     :packer-version: Version of packer to use.
146
147 lf-infra-push-gerrit-patch
148 --------------------------
149
150 Push a change through a Jenkins job to a Gerrit repository in an automated
151 way using git-review.
152
153 :Required parameters:
154
155     :gerrit-commit-message: Commit message to assign.
156     :gerrit-host: Gerrit hostname.
157     :gerrit-topic: Gerrit topic.
158     :gerrit-user: Gerrit user-id used for submitting the change.
159     :reviewers-email: Reviewers email. Space-separated list of
160         email addresses to CC on the patch.
161     :project: Gerrit project name.
162
163 .. _lf-infra-ship-logs:
164
165 lf-infra-ship-logs
166 ------------------
167
168 Gather and deploy logs to a log server.
169
170 lf-infra-sysstat
171 ----------------
172
173 Retrieves system stats.
174
175 lf-infra-update-packer-images
176 -----------------------------
177
178 Find and update the new built cloud image{s} in the ci-management source
179 repository.
180
181
182 lf-jacoco-nojava-workaround
183 ---------------------------
184
185 Workaround for Jenkins not able to find Java in JaCoCo runs.
186
187 .. _lf-maven-central:
188
189 lf-maven-central
190 ----------------
191
192 Publish artifacts to OSSRH (Maven Central) staging.
193
194 Requires that the project's settings.xml contains a ServerId 'ossrh' with the
195 credentials for the project's OSSRH account.
196
197 This macro assumes the directory ``$WORKSPACE/m2repo`` contains a Maven 2
198 repository which is to upload to OSSRH.
199
200 :Required parameters:
201
202     :mvn-central: Whether or not to upload to mvn-central. (true|false)
203     :mvn-global-settings: The name of the Maven global settings to use for
204         Maven configuration. (default: global-settings)
205     :mvn-settings: The name of settings file containing credentials for the
206         project.
207     :ossrh-profile-id: Nexus staging profile ID as provided by OSSRH.
208
209 .. literalinclude:: ../../.jjb-test/lf-macros/lf-maven-central-minimal.yaml
210    :language: yaml
211
212 .. _lf-maven-install:
213
214 lf-maven-install
215 ----------------
216
217 Call maven-target builder with a goal of --version to force Jenkins to
218 install the need provided version of Maven. This is needed for any shell scripts
219 that want to use Maven.
220
221 :Required parameters:
222
223     :mvn-version: Version of Maven to install.
224
225 lf-packagecloud-file-provider
226 -----------------------------
227
228 Provisions files required by the Ruby gem package_cloud, namely
229 ".packagecloud" and "packagecloud_api" in the Jenkins home directory.
230
231 lf-packagecloud-push
232 --------------------
233
234 Pushes DEB/RPM package files to PackageCloud using the Ruby gem package_cloud.
235
236 :Required parameters:
237
238     :build-dir: Directory with deb/rpm files to push
239     :debian-distribution-versions: list of DEB package distro/version strings
240         separated by space; example: ubuntu/bionic debian/stretch
241     :packagecloud-account: PackageCloud account ID; example: oran
242     :packagecloud-repo: PackageCloud repository; example: master, staging
243     :rpm-distribution-versions: list of RPM package distro/version strings
244         separated by space; example: el/4 el/5
245
246 lf-pip-install
247 --------------
248
249 Call pip install to install packages into a virtualenv located in
250 /tmp/v/VENV
251
252 .. note:: The first package listed in PIP_PACKAGES is used as the VENV name.
253
254 .. _lf-provide-maven-settings:
255
256 lf-provide-maven-settings
257 -------------------------
258
259 Push a global settings and user settings maven files to the build node.
260
261 lf-provide-maven-settings-cleanup
262 ---------------------------------
263
264 Cleanup maven settings.xml configuration. This should be called at the end of
265 any macros that calles the
266 :ref:`lf-provide-maven-settings <lf-provide-maven-settings>` macro.
267
268 lf-rtd-trigger-build
269 --------------------
270
271 Script to trigger a build on http://readthedocs.org
272
273 lf-rtd-verify
274 -------------
275
276 ReadTheDocs verify script. Installs and runs tox.
277
278 :Required parameters:
279
280     :doc-dir: Document directory.
281     :python-version: Python version.
282
283 lf-rtdv3-build
284 ---------------
285
286 Read the docs scripts that leverage the new Read the Docs v3 api
287 `RTD v3 API <https://docs.readthedocs.io/en/stable/api/v3.html>`_
288 Runs tox to verify that the docs are good and then runs the RTDv3 shell script.
289 This script handles creating projects as needed, assiging subprojects to the main
290 read the docs project and triggering builds to update the documentation.
291 Jobs will run but skip verify bits until a .readthedocs.yaml is found in the root
292 of their repository.
293
294
295 check-info-votes
296 ----------------
297
298 Calls shell script to validate votes on a change to an INFO.yaml
299
300 lf-release
301 ----------
302
303 releases lftools.ini (required)
304 needed to push to nexus.
305
306 [nexus]
307 username=
308 password=
309
310 Then runs ../shell/release-job.sh
311
312
313 lf-sigul-sign-dir
314 -----------------
315
316 Use Sigul to sign a directory via {sign-dir}.
317
318 Requires ``SIGUL_BRIDGE_IP`` configured as a global envvar.
319
320 :Required Parameters:
321     :sign-artifacts: Whether or not to sign artifacts with Sigul.
322     :sign-dir: Directory to sign.
323     :sign-mode: serial|parallel
324
325 lf-infra-provide-docker-cleanup
326 -------------------------------
327
328 Forcibly removes all of the docker images.
329
330 lf-infra-sonar
331 ---------------
332
333 Runs Jenkins SonarQube plug-in.
334
335 Requires ``SonarQube Scanner for Jenkins``
336
337 .. note:: Sonar properties can be set directly in the job definition by
338    setting the sonar-project-file to ``""`` and adding all properties under
339    ``sonar-properties``.
340
341 :Optional Parameters:
342     :sonar-task: Sonar task to run. (default: "")
343     :sonar-project-file: The filename for the project's properties
344         (default: "sonar-project.properties")
345     :sonar-properties: Sonar configuration properties. (default: "")
346     :sonar-java-opts: JVM options. (default: "")
347     :sonar-additional-args: Additional command line arguments. (default: "")
348
349 lf-infra-sonar-with-prescan
350 ---------------------------
351
352 Runs Jenkins SonarQube plug-in after a pre-scan builder, which is defined by
353 the macro's caller.
354
355 Requires ``SonarQube Scanner for Jenkins``
356
357 .. note:: Sonar properties can be set directly in the job definition by
358    setting the sonar-project-file to ``""`` and adding all properties under
359    ``sonar-properties``.
360
361 :Required Parameters:
362     :lf-sonar-prescan: A builder that will run prior to the Sonar scan.
363
364 :Optional Parameters:
365     :sonar-task: Sonar task to run. (default: "")
366     :sonar-project-file: The filename for the project's properties
367         (default: "sonar-project.properties")
368     :sonar-properties: Sonar configuration properties. (default: "")
369     :sonar-java-opts: JVM options. (default: "")
370     :sonar-additional-args: Additional command line arguments. (default: "")
371
372 Parameters
373 ==========
374
375 lf-clm-parameters
376 -------------------
377
378 Provides the policy evaluation stage to run against Nexus IQ Server.
379 Valid values include: 'build', 'stage-release', 'operate'.
380
381 lf-cmake-parameters
382 -------------------
383
384 Provides parameters needed by CMake. Should be used by any jobs that need to
385 call the ``cmake && make && make install`` pattern.
386
387 lf-infra-maven-parameters
388 -------------------------
389
390 Provides parameters needed by Maven. Should be used by any jobs that need to
391 call the mvn cli.
392
393 lf-infra-openstack-parameters
394 -----------------------------
395
396 Provides parameters needed by OpenStack client CLI. Use in jobs that need to
397 call the openstack cli.
398
399 :Required Parameters:
400
401     :os-cloud: Configures ``OS_CLOUD`` envvar as used by openstack cli.
402
403 lf-infra-parameters
404 -------------------
405
406 Standard parameters used in the LF CI environments. Gerrit variables are
407 not used by GitHub projects, but defining them is not harmful. Should be used
408 in every job template.
409
410 lf-infra-node-parameters
411 ------------------------
412
413 Provides parameters needed by NodeJS and NPM. Should be used by any jobs that
414 need to run NodeJS or NPM.
415
416 lf-infra-tox-parameters
417 -----------------------
418
419 Provides parameters needed by python-tox. Should be used by any jobs that need
420 to run `tox <https://tox.readthedocs.io>`.
421
422
423 lf-build-with-parameters-maven-release
424 --------------------------------------
425
426 Provides parameters needed for maven release jobs 'build with parameters'.
427
428 Properties
429 ==========
430
431 lf-infra-properties
432 -------------------
433
434 Configures the build-discarder plugin for Jenkins with the recommended lf-infra
435 settings. Should be used in all job-templates.
436
437 Publishers
438 ==========
439
440 lf-jacoco-report
441 ----------------
442
443 Provides basic configuration for the JaCoCo plugin.
444
445 lf-infra-publish
446 ----------------
447
448 Provides basic lf-infra recommended publisher configurations which should be
449 used in all job templates. This primary objective of this trigger is to
450 gather build logs and copy them to a log server.
451
452 lf-infra-publish-windows
453 ------------------------
454
455 Windows publisher for use at the end of Windows job templates. Takes care of
456 cleaning out the workspace at the end of a job.
457
458 SCM
459 ===
460
461 lf-infra-gerrit-scm
462 -------------------
463
464 Basic SCM configuration for Gerrit based projects.
465
466 :Required parameters:
467
468     :submodule-timeout: Timeout (in minutes) for checkout operation.
469         (default: 10)
470     :submodule-disable: Disable submodule checkout operation.
471         (default: false)
472
473 lf-infra-github-scm
474 -------------------
475
476 Basic SCM configuration for GitHub based projects.
477
478 On the `branch` variable you can assign `$sha1` or `$ghprbActualCommit`
479 as the value.  This will require that the job be triggered via
480 the GHPRB plugin and not manually.
481
482 :Required parameters:
483
484     :submodule-timeout: Timeout (in minutes) for checkout operation.
485         (default: 10)
486     :submodule-disable: Disable submodule checkout operation.
487         (default: false)
488
489 Wrappers
490 ========
491
492 lf-infra-wrappers-common
493 ------------------------
494
495 Provides lf-infra recommended wrappers which should be used in every
496 job-template. It's meant to be used by more specific wrappers below.
497
498 lf-infra-wrappers
499 -----------------
500
501 Provides lf-infra recommended wrappers which should be used in every
502 job-template that's run on Linux systems.
503
504 This wrapper requires that a managed file called `npmrc` exists in the Jenkins.
505 The main use case here is to point to a npm proxy, on Nexus for example.
506 The type of the file should be "Custom file".  You can set various npmrc
507 settings in it. Documentation on npm configuration can be found at
508 https://docs.npmjs.com/files/npmrc. If you are not using npm then it is fine
509 for the file to be empty.
510
511 Example npmrc:
512
513 .. code-block:: bash
514
515    registry=https://nexus3.onap.org/repository/npm.public/
516
517 lf-infra-wrappers-windows
518 -------------------------
519
520 Provides lf-infra recommended wrappers which should be used in every
521 job-template that's run on Windows systems.