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