Add comment-to-gerrit macro
[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 lf-infra-packer-validate
130 ------------------------
131
132 Run `packer validate` to verify packer configuration.
133
134 :Required parameters:
135
136     :openstack: Packer template uses an OpenStack builder (true|false).
137     :openstack-cloud: Sets OS_CLOUD variable to the value of this parameter.
138     :packer-cloud-settings: Cloud configuration file. Loaded on the build
139         server as CLOUDENV environment variable.
140     :packer-version: Version of packer to use.
141
142 lf-infra-push-gerrit-patch
143 --------------------------
144
145 Push a change through a Jenkins job to a Gerrit repository in an automated
146 way using git-review.
147
148 :Required parameters:
149
150     :gerrit-commit-message: Commit message to assign.
151     :gerrit-host: Gerrit hostname.
152     :gerrit-topic: Gerrit topic.
153     :gerrit-user: Gerrit user-id used for submitting the change.
154     :reviewers-email: Reviewers email. Space-separated list of
155         email addresses to CC on the patch.
156     :project: Gerrit project name.
157
158 .. _lf-infra-ship-logs:
159
160 lf-infra-ship-logs
161 ------------------
162
163 Gather and deploy logs to a log server.
164
165 lf-infra-sysstat
166 ----------------
167
168 Retrieves system stats.
169
170 lf-jacoco-nojava-workaround
171 ---------------------------
172
173 Workaround for Jenkins not able to find Java in JaCoCo runs.
174
175 .. _lf-maven-central:
176
177 lf-maven-central
178 ----------------
179
180 Publish artifacts to OSSRH (Maven Central) staging.
181
182 Requires that the project's settings.xml contains a ServerId 'ossrh' with the
183 credentials for the project's OSSRH account.
184
185 This macro assumes the directory ``$WORKSPACE/m2repo`` contains a Maven 2
186 repository which is to upload to OSSRH.
187
188 :Required parameters:
189
190     :mvn-central: Whether or not to upload to mvn-central. (true|false)
191     :mvn-global-settings: The name of the Maven global settings to use for
192         Maven configuration. (default: global-settings)
193     :mvn-settings: The name of settings file containing credentials for the
194         project.
195     :ossrh-profile-id: Nexus staging profile ID as provided by OSSRH.
196
197 .. literalinclude:: ../../.jjb-test/lf-macros/lf-maven-central-minimal.yaml
198    :language: yaml
199
200 .. _lf-maven-install:
201
202 lf-maven-install
203 ----------------
204
205 Call maven-target builder with a goal of --version to force Jenkins to
206 install the need provided version of Maven. This is needed for any shell scripts
207 that want to use Maven.
208
209 :Required parameters:
210
211     :mvn-version: Version of Maven to install.
212
213 lf-pip-install
214 --------------
215
216 Call pip install to install packages into a virtualenv located in
217 /tmp/v/VENV
218
219 .. note:: The first package listed in PIP_PACKAGES is used as the VENV name.
220
221 .. _lf-provide-maven-settings:
222
223 lf-provide-maven-settings
224 -------------------------
225
226 Push a global settings and user settings maven files to the build node.
227
228 lf-provide-maven-settings-cleanup
229 ---------------------------------
230
231 Cleanup maven settings.xml configuration. This should be called at the end of
232 any macros that calles the
233 :ref:`lf-provide-maven-settings <lf-provide-maven-settings>` macro.
234
235 lf-rtd-trigger-build
236 --------------------
237
238 Script to trigger a build on http://readthedocs.org
239
240 lf-rtd-verify
241 -------------
242
243 ReadTheDocs verify script.
244
245 lf-sigul-sign-dir
246 -----------------
247
248 Use Sigul to sign a directory via {sign-dir}.
249
250 Requires ``SIGUL_BRIDGE_IP`` configured as a global envvar.
251
252 :Required Parameters:
253     :sign-artifacts: Whether or not to sign artifacts with Sigul.
254     :sign-dir: Directory to sign.
255     :sign-mode: serial|parallel
256
257 lf-infra-provide-docker-cleanup
258 -------------------------------
259
260 Forcibly removes all of the docker images.
261
262 Parameters
263 ==========
264
265 lf-clm-parameters
266 -------------------
267
268 Provides the policy evaluation stage to run against Nexus IQ Server.
269 Valid values include: 'build', 'stage-release', 'operate'.
270
271 lf-cmake-parameters
272 -------------------
273
274 Provides parameters needed by CMake. Should be used by any jobs that need to
275 call the ``cmake && make && make install`` pattern.
276
277 lf-infra-maven-parameters
278 -------------------------
279
280 Provides parameters needed by Maven. Should be used by any jobs that need to
281 call the mvn cli.
282
283 lf-infra-openstack-parameters
284 -----------------------------
285
286 Provides parameters needed by OpenStack client CLI. Use in jobs that need to
287 call the openstack cli.
288
289 :Required Parameters:
290
291     :os-cloud: Configures ``OS_CLOUD`` envvar as used by openstack cli.
292
293 lf-infra-parameters
294 -------------------
295
296 Standard parameters used in the LF CI environments. Gerrit variables are
297 not used by GitHub projects, but defining them is not harmful. Should be used
298 in every job template.
299
300 lf-infra-node-parameters
301 ------------------------
302
303 Provides parameters needed by NodeJS and NPM. Should be used by any jobs that
304 need to run NodeJS or NPM.
305
306 lf-infra-tox-parameters
307 -----------------------
308
309 Provides parameters needed by python-tox. Should be used by any jobs that need
310 to run `tox <https://tox.readthedocs.io>`.
311
312 Properties
313 ==========
314
315 lf-infra-properties
316 -------------------
317
318 Configures the build-discarder plugin for Jenkins with the recommended lf-infra
319 settings. Should be used in all job-templates.
320
321 Publishers
322 ==========
323
324 lf-jacoco-report
325 ----------------
326
327 Provides basic configuration for the JaCoCo plugin.
328
329 lf-infra-publish
330 ----------------
331
332 Provides basic lf-infra recommended publisher configurations which should be
333 used in all job templates. This primary objective of this trigger is to
334 gather build logs and copy them to a log server.
335
336 lf-infra-publish-windows
337 ------------------------
338
339 Windows publisher for use at the end of Windows job templates. Takes care of
340 cleaning out the workspace at the end of a job.
341
342 SCM
343 ===
344
345 lf-infra-gerrit-scm
346 -------------------
347
348 Basic SCM configuration for Gerrit based projects.
349
350 :Required parameters:
351
352     :submodule-timeout: Timeout (in minutes) for checkout operation.
353         (default: 10)
354
355 lf-infra-github-scm
356 -------------------
357
358 Basic SCM configuration for GitHub based projects.
359
360 On the `branch` variable you can assign `$sha1` or `$ghprbActualCommit`
361 as the value.  This will require that the job be triggered via
362 the GHPRB plugin and not manually.
363
364 :Required parameters:
365
366     :submodule-timeout: Timeout (in minutes) for checkout operation.
367         (default: 10)
368
369 Wrappers
370 ========
371
372 lf-infra-wrappers-common
373 ------------------------
374
375 Provides lf-infra recommended wrappers which should be used in every
376 job-template. It's meant to be used by more specific wrappers below.
377
378 lf-infra-wrappers
379 -----------------
380
381 Provides lf-infra recommended wrappers which should be used in every
382 job-template that's run on Linux systems.
383
384 This wrapper requires that a managed file called `npmrc` exists in the Jenkins.
385 The main use case here is to point to a npm proxy, on Nexus for example.
386 The type of the file should be "Custom file".  You can set various npmrc
387 settings in it. Documentation on npm configuration can be found at
388 https://docs.npmjs.com/files/npmrc. If you are not using npm then it is fine
389 for the file to be empty.
390
391 Example npmrc:
392
393 .. code-block:: bash
394
395    registry=https://nexus3.onap.org/repository/npm.public/
396
397 lf-infra-wrappers-windows
398 -------------------------
399
400 Provides lf-infra recommended wrappers which should be used in every
401 job-template that's run on Windows systems.