Add pre-build step to prep vm before build
[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 lf-infra-packer-validate
114 ------------------------
115
116 Run `packer validate` to verify packer configuration.
117
118 :Required parameters:
119
120     :packer-cloud-settings: Cloud configuration file. Loaded on the build
121         server as CLOUDENV environment variable.
122     :packer-version: Version of packer to use.
123
124 lf-infra-push-gerrit-patch
125 --------------------------
126
127 Push a change through a Jenkins job to a Gerrit repository in an automated
128 way using git-review.
129
130 :Required parameters:
131
132     :gerrit-commit-message: Commit message to assign.
133     :gerrit-host: Gerrit hostname.
134     :gerrit-topic: Gerrit topic.
135     :gerrit-user: Gerrit user-id used for submitting the change.
136     :reviewers-email: Reviewers email. Space-separated list of
137         email addresses to CC on the patch.
138     :project: Gerrit project name.
139
140 .. _lf-infra-ship-logs:
141
142 lf-infra-ship-logs
143 ------------------
144
145 Gather and deploy logs to a log server.
146
147 lf-infra-sysstat
148 ----------------
149
150 Retrieves system stats.
151
152 lf-jacoco-nojava-workaround
153 ---------------------------
154
155 Workaround for Jenkins not able to find Java in JaCoCo runs.
156
157 lf-maven-install
158 ----------------
159
160 Call maven-target builder with a goal of --version to force Jenkins to
161 install the need provided version of Maven. This is needed for any shell scripts
162 that want to use Maven.
163
164 :Required parameters:
165
166     :mvn-version: Version of Maven to install.
167
168 lf-pip-install
169 --------------
170
171 Call pip install to install packages into a virtualenv located in
172 /tmp/v/VENV
173
174 .. note:: The first package listed in PIP_PACKAGES is used as the VENV name.
175
176 .. _lf-provide-maven-settings:
177
178 lf-provide-maven-settings
179 -------------------------
180
181 Push a global settings and user settings maven files to the build node.
182
183 lf-provide-maven-settings-cleanup
184 ---------------------------------
185
186 Cleanup maven settings.xml configuration. This should be called at the end of
187 any macros that calles the
188 :ref:`lf-provide-maven-settings <lf-provide-maven-settings>` macro.
189
190 .. _provide-sigul-config:
191
192 lf-provide-sigul-configuration
193 ------------------------------
194
195 Provides sigual configuration to the Jenkins build node.
196
197 Requires the following Config File Provider managed files in Jenkins
198 preconfigured.
199
200 * sigul-config
201 * sigul-password
202 * sigul-pki
203
204 .. _provide-sigul-config-cleanup:
205
206 lf-provide-sigul-configuration-cleanup
207 --------------------------------------
208
209 Cleanup configuration provided by `provide-sigul-config`.
210
211 lf-rtd-trigger-build
212 --------------------
213
214 Script to trigger a build on http://readthedocs.org
215
216 lf-rtd-verify
217 -------------
218
219 ReadTheDocs verify script.
220
221 lf-sigul-install
222 ----------------
223
224 Install Sigul.
225
226 Requires ``SIGUL_BRIDGE_IP`` configured as a global envvar.
227
228 lf-infra-provide-docker-cleanup
229 -------------------------------
230
231 Forcibly removes all of the docker images.
232
233 Parameters
234 ==========
235
236 lf-clm-parameters
237 -------------------
238
239 Provides the policy evaluation stage to run against Nexus IQ Server.
240 Valid values include: 'build', 'stage-release', 'operate'.
241
242 lf-cmake-parameters
243 -------------------
244
245 Provides parameters needed by CMake. Should be used by any jobs that need to
246 call the ``cmake && make && make install`` pattern.
247
248 lf-infra-maven-parameters
249 -------------------------
250
251 Provides parameters needed by Maven. Should be used by any jobs that need to
252 call the mvn cli.
253
254 lf-infra-openstack-parameters
255 -----------------------------
256
257 Provides parameters needed by OpenStack client CLI. Use in jobs that need to
258 call the openstack cli.
259
260 :Required Parameters:
261
262     :os-cloud: Configures ``OS_CLOUD`` envvar as used by openstack cli.
263
264 lf-infra-parameters
265 -------------------
266
267 Standard parameters used in the LF CI environments. Gerrit variables are
268 not used by GitHub projects, but defining them is not harmful. Should be used
269 in every job template.
270
271 lf-infra-node-parameters
272 ------------------------
273
274 Provides parameters needed by NodeJS and NPM. Should be used by any jobs that
275 need to run NodeJS or NPM.
276
277 lf-infra-tox-parameters
278 -----------------------
279
280 Provides parameters needed by python-tox. Should be used by any jobs that need
281 to run `tox <https://tox.readthedocs.io>`.
282
283 Properties
284 ==========
285
286 lf-infra-properties
287 -------------------
288
289 Configures the build-discarder plugin for Jenkins with the recommended lf-infra
290 settings. Should be used in all job-templates.
291
292 Publishers
293 ==========
294
295 lf-jacoco-report
296 ----------------
297
298 Provides basic configuration for the JaCoCo plugin.
299
300 lf-infra-publish
301 ----------------
302
303 Provides basic lf-infra recommended publisher configurations which should be
304 used in all job templates. This primary objective of this trigger is to
305 gather build logs and copy them to a log server.
306
307 SCM
308 ===
309
310 lf-infra-gerrit-scm
311 -------------------
312
313 Basic SCM configuration for Gerrit based projects.
314
315 lf-infra-github-scm
316 -------------------
317
318 Basic SCM configuration for GitHub based projects.
319
320 On the `branch` variable you can assign `$sha1` or `$ghprbActualCommit`
321 as the value.  This will require that the job be triggered via
322 the GHPRB plugin and not manually.
323
324 Wrappers
325 ========
326
327 lf-infra-wrappers
328 -----------------
329
330 Provides lf-infra recommended wrappers which should be used in every
331 job-template.
332
333 This wrapper requires that a managed file called `npmrc` exists in the Jenkins.  The main use
334 case here is to point to a npm proxy, on Nexus for example.
335 The type of the file should be "Custom file".  You can set various npmrc settings in it.
336 Documentation on npm configuration can be found at https://docs.npmjs.com/files/npmrc.
337 If you are not using npm then it is fine for the file to be empty.
338
339 Example npmrc:
340
341 .. code-block:: bash
342
343    registry=https://nexus3.onap.org/repository/npm.public/