Merge "Document required params in lf-maven-stage macro"
[releng/global-jjb.git] / docs / jjb / lf-macros.rst
1 #############
2 Global Macros
3 #############
4
5 Builders
6 ========
7
8 lf-fetch-dependent-patches
9 --------------------------
10
11 Fetch all patches provided via comment trigger
12
13 This macro will fetch all patches provided via comment trigger and will
14 create a list of projects from those patches via environment variable
15 called DEPENDENCY_BUILD_ORDER which can be used if necessary to build
16 projects in the specified order. The order is determined by first patch
17 instance for a project in the patch list.
18
19 lf-license-check
20 ----------------
21
22 Checks files for
23
24 :Required parameters:
25
26     :file-patterns: Space-separated list of file patterns to scan.
27         For example: \*.go \*.groovy \*.java \*.py \*.sh
28     :spdx-disable: Disable the SPDX-Identifier checker.
29     :lhc-version: Version of LHC to use.
30     :license-exclude-paths: Comma-separated list of paths to exclude from the
31         license checker. The paths used here will be matched using a contains
32         rule so it is best to be as precise with the path as possible.
33         For example a path of '/src/generated/' will be searched as
34         '**/src/generated/**'.
35         Example: org/opendaylight/yang/gen,protobuff/messages
36     :licenses-allowed: Comma-separated list of allowed licenses.
37         For example: Apache-2.0,EPL-1.0,MIT
38
39 lf-infra-create-netrc
40 ---------------------
41
42 Create a ~/.netrc file from a Maven settings.xml
43
44 :Required parameters:
45
46     :server-id: The id of a server as defined in settings.xml.
47
48 :Optional parameters:
49
50     :ALT_NEXUS_SERVER: URL of custom nexus server.
51         If set this will take precedence.
52         Use this to point at nexus3.$PROJECTDOMAIN
53         for example.
54
55 lf-infra-deploy-maven-file
56 --------------------------
57
58 Deploy files to a repository.
59
60 :Required parameters:
61
62     :global-settings-file: Global settings file to use.
63     :group-id: Group ID of the repository.
64     :maven-repo-url: URL of a Maven repository to upload to.
65     :mvn-version: Version of Maven to use.
66     :repo-id: Repository ID
67     :settings-file: Maven settings file to use.
68     :upload-files-dir: Path to directory containing one or more files
69
70 lf-infra-docker-login
71 ---------------------
72
73 Login into a custom hosted docker registry and / or docker.io
74
75 The Jenkins system should have the following global variables defined
76
77 :Environment variables:
78
79     :DOCKER_REGISTRY: The DNS address of the registry (IP or FQDN)
80         ex: nexus3.example.com (GLOBAL variable)
81
82     :REGISTRY_PORTS: Required if DOCKER_REGISTRY is set. Space separated list
83         of the registry ports to login to. ex: 10001 10002 10003 10004
84         (GLOBAL variable)
85
86     :DOCKERHUB_EMAIL: If this variable is set then an attempt to login to
87         DockerHub (docker.io) will be also made. It should be set to the email
88         address for the credentials that will get looked up. Only _one_
89         credential will ever be found in the maven settings file for DockerHub.
90         (GLOBAL variable)
91
92 lf-infra-gpg-verify-git-signature
93 ---------------------------------
94
95 Verify gpg signature of the latest commit message in $WORKSPACE.
96 This command assumes that $WORKSPACE is a git repo.
97
98 lf-infra-pre-build
99 ------------------
100
101 Macro that runs before all builders to prepare the system for job use.
102
103 lf-infra-package-listing
104 ------------------------
105
106 Lists distro level packages.
107
108 lf-infra-packer-build
109 ---------------------
110
111 Run `packer build` to build system images.
112
113 :Required parameters:
114
115     :openstack: Packer template uses an OpenStack builder (true|false).
116     :openstack-cloud: Sets OS_CLOUD variable to the value of this parameter.
117     :packer-version: Version of packer to use.
118     :platform: Build platform as found in the vars directory.
119     :template: Packer template to build as found in the templates directory.
120
121 lf-infra-packer-validate
122 ------------------------
123
124 Run `packer validate` to verify packer configuration.
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-cloud-settings: Cloud configuration file. Loaded on the build
131         server as CLOUDENV environment variable.
132     :packer-version: Version of packer to use.
133
134 lf-infra-push-gerrit-patch
135 --------------------------
136
137 Push a change through a Jenkins job to a Gerrit repository in an automated
138 way using git-review.
139
140 :Required parameters:
141
142     :gerrit-commit-message: Commit message to assign.
143     :gerrit-host: Gerrit hostname.
144     :gerrit-topic: Gerrit topic.
145     :gerrit-user: Gerrit user-id used for submitting the change.
146     :reviewers-email: Reviewers email. Space-separated list of
147         email addresses to CC on the patch.
148     :project: Gerrit project name.
149
150 .. _lf-infra-ship-logs:
151
152 lf-infra-ship-logs
153 ------------------
154
155 Gather and deploy logs to a log server.
156
157 lf-infra-sysstat
158 ----------------
159
160 Retrieves system stats.
161
162 lf-jacoco-nojava-workaround
163 ---------------------------
164
165 Workaround for Jenkins not able to find Java in JaCoCo runs.
166
167 .. _lf-maven-central:
168
169 lf-maven-central
170 ----------------
171
172 Publish artifacts to OSSRH (Maven Central) staging.
173
174 Requires that the project's settings.xml contains a ServerId 'ossrh' with the
175 credentials for the project's OSSRH account.
176
177 This macro assumes the directory ``$WORKSPACE/m2repo`` contains a Maven 2
178 repository which is to upload to OSSRH.
179
180 :Required parameters:
181
182     :mvn-central: Whether or not to upload to mvn-central. (true|false)
183     :mvn-global-settings: The name of the Maven global settings to use for
184         Maven configuration. (default: global-settings)
185     :mvn-settings: The name of settings file containing credentials for the
186         project.
187     :ossrh-profile-id: Nexus staging profile ID as provided by OSSRH.
188
189 .. literalinclude:: ../../.jjb-test/lf-macros/lf-maven-central-minimal.yaml
190    :language: yaml
191
192 .. _lf-maven-install:
193
194 lf-maven-install
195 ----------------
196
197 Call maven-target builder with a goal of --version to force Jenkins to
198 install the need provided version of Maven. This is needed for any shell scripts
199 that want to use Maven.
200
201 :Required parameters:
202
203     :mvn-version: Version of Maven to install.
204
205 lf-pip-install
206 --------------
207
208 Call pip install to install packages into a virtualenv located in
209 /tmp/v/VENV
210
211 .. note:: The first package listed in PIP_PACKAGES is used as the VENV name.
212
213 .. _lf-provide-maven-settings:
214
215 lf-provide-maven-settings
216 -------------------------
217
218 Push a global settings and user settings maven files to the build node.
219
220 lf-provide-maven-settings-cleanup
221 ---------------------------------
222
223 Cleanup maven settings.xml configuration. This should be called at the end of
224 any macros that calles the
225 :ref:`lf-provide-maven-settings <lf-provide-maven-settings>` macro.
226
227 lf-rtd-trigger-build
228 --------------------
229
230 Script to trigger a build on http://readthedocs.org
231
232 lf-rtd-verify
233 -------------
234
235 ReadTheDocs verify script.
236
237 lf-sigul-sign-dir
238 -----------------
239
240 Use Sigul to sign a directory via {sign-dir}.
241
242 Requires ``SIGUL_BRIDGE_IP`` configured as a global envvar.
243
244 :Required Parameters:
245     :sign-artifacts: Whether or not to sign artifacts with Sigul.
246     :sign-dir: Directory to sign.
247     :sign-mode: serial|parallel
248
249 lf-infra-provide-docker-cleanup
250 -------------------------------
251
252 Forcibly removes all of the docker images.
253
254 Parameters
255 ==========
256
257 lf-clm-parameters
258 -------------------
259
260 Provides the policy evaluation stage to run against Nexus IQ Server.
261 Valid values include: 'build', 'stage-release', 'operate'.
262
263 lf-cmake-parameters
264 -------------------
265
266 Provides parameters needed by CMake. Should be used by any jobs that need to
267 call the ``cmake && make && make install`` pattern.
268
269 lf-infra-maven-parameters
270 -------------------------
271
272 Provides parameters needed by Maven. Should be used by any jobs that need to
273 call the mvn cli.
274
275 lf-infra-openstack-parameters
276 -----------------------------
277
278 Provides parameters needed by OpenStack client CLI. Use in jobs that need to
279 call the openstack cli.
280
281 :Required Parameters:
282
283     :os-cloud: Configures ``OS_CLOUD`` envvar as used by openstack cli.
284
285 lf-infra-parameters
286 -------------------
287
288 Standard parameters used in the LF CI environments. Gerrit variables are
289 not used by GitHub projects, but defining them is not harmful. Should be used
290 in every job template.
291
292 lf-infra-node-parameters
293 ------------------------
294
295 Provides parameters needed by NodeJS and NPM. Should be used by any jobs that
296 need to run NodeJS or NPM.
297
298 lf-infra-tox-parameters
299 -----------------------
300
301 Provides parameters needed by python-tox. Should be used by any jobs that need
302 to run `tox <https://tox.readthedocs.io>`.
303
304 Properties
305 ==========
306
307 lf-infra-properties
308 -------------------
309
310 Configures the build-discarder plugin for Jenkins with the recommended lf-infra
311 settings. Should be used in all job-templates.
312
313 Publishers
314 ==========
315
316 lf-jacoco-report
317 ----------------
318
319 Provides basic configuration for the JaCoCo plugin.
320
321 lf-infra-publish
322 ----------------
323
324 Provides basic lf-infra recommended publisher configurations which should be
325 used in all job templates. This primary objective of this trigger is to
326 gather build logs and copy them to a log server.
327
328 lf-infra-publish-windows
329 ------------------------
330
331 Windows publisher for use at the end of Windows job templates. Takes care of
332 cleaning out the workspace at the end of a job.
333
334 SCM
335 ===
336
337 lf-infra-gerrit-scm
338 -------------------
339
340 Basic SCM configuration for Gerrit based projects.
341
342 :Required parameters:
343
344     :submodule-timeout: Timeout (in minutes) for checkout operation.
345         (default: 10)
346
347 lf-infra-github-scm
348 -------------------
349
350 Basic SCM configuration for GitHub based projects.
351
352 On the `branch` variable you can assign `$sha1` or `$ghprbActualCommit`
353 as the value.  This will require that the job be triggered via
354 the GHPRB plugin and not manually.
355
356 :Required parameters:
357
358     :submodule-timeout: Timeout (in minutes) for checkout operation.
359         (default: 10)
360
361 Wrappers
362 ========
363
364 lf-infra-wrappers-common
365 ------------------------
366
367 Provides lf-infra recommended wrappers which should be used in every
368 job-template. It's meant to be used by more specific wrappers below.
369
370 lf-infra-wrappers
371 -----------------
372
373 Provides lf-infra recommended wrappers which should be used in every
374 job-template that's run on Linux systems.
375
376 This wrapper requires that a managed file called `npmrc` exists in the Jenkins.
377 The main use case here is to point to a npm proxy, on Nexus for example.
378 The type of the file should be "Custom file".  You can set various npmrc
379 settings in it. Documentation on npm configuration can be found at
380 https://docs.npmjs.com/files/npmrc. If you are not using npm then it is fine
381 for the file to be empty.
382
383 Example npmrc:
384
385 .. code-block:: bash
386
387    registry=https://nexus3.onap.org/repository/npm.public/
388
389 lf-infra-wrappers-windows
390 -------------------------
391
392 Provides lf-infra recommended wrappers which should be used in every
393 job-template that's run on Windows systems.