Merge "Document undocumented Python macros"
[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-packer-build
99 ---------------------
100
101 Run `packer build` to build system images.
102
103 lf-infra-packer-validate
104 ------------------------
105
106 Run `packer validate` to verify packer configuration.
107
108 :Required parameters:
109
110     :packer-cloud-settings: Cloud configuration file. Loaded on the build
111         server as CLOUDENV environment variable.
112     :packer-version: Version of packer to use.
113
114 lf-infra-push-gerrit-patch
115 --------------------------
116
117 Push a change through a Jenkins job to a Gerrit repository in an automated
118 way using git-review.
119
120 :Required parameters:
121
122     :gerrit-commit-message: Commit message to assign.
123     :gerrit-host: Gerrit hostname.
124     :gerrit-topic: Gerrit topic.
125     :gerrit-user: Gerrit user-id used for submitting the change.
126     :reviewers-email: Reviewers email. Space-separated list of
127         email addresses to CC on the patch.
128     :project: Gerrit project name.
129
130 .. _lf-infra-ship-logs:
131
132 lf-infra-ship-logs
133 ------------------
134
135 Gather and deploy logs to a log server.
136
137 lf-infra-sysstat
138 ----------------
139
140 Retrieves system stats.
141
142 lf-jacoco-nojava-workaround
143 ---------------------------
144
145 Workaround for Jenkins not able to find Java in JaCoCo runs.
146
147 lf-maven-install
148 ----------------
149
150 Call maven-target builder with a goal of --version to force Jenkins to
151 install the need provided version of Maven. This is needed for any shell scripts
152 that want to use Maven.
153
154 :Required parameters:
155
156     :mvn-version: Version of Maven to install.
157
158 lf-pip-install
159 --------------
160
161 Call pip install to install packages into a virtualenv located in
162 /tmp/v/VENV
163
164 .. note:: The first package listed in PIP_PACKAGES is used as the VENV name.
165
166 .. _lf-provide-maven-settings:
167
168 lf-provide-maven-settings
169 -------------------------
170
171 Push a global settings and user settings maven files to the build node.
172
173 lf-provide-maven-settings-cleanup
174 ---------------------------------
175
176 Cleanup maven settings.xml configuration. This should be called at the end of
177 any macros that calles the
178 :ref:`lf-provide-maven-settings <lf-provide-maven-settings>` macro.
179
180 lf-rtd-trigger-build
181 --------------------
182
183 Script to trigger a build on http://readthedocs.org
184
185 lf-rtd-verify
186 -------------
187
188 ReadTheDocs verify script.
189
190 lf-infra-provide-docker-cleanup
191 -------------------------------
192
193 Forcibly removes all of the docker images.
194
195 Parameters
196 ==========
197
198 lf-infra-maven-parameters
199 -------------------------
200
201 Provides parameters needed by Maven. Should be used by any jobs that need to
202 call the mvn cli.
203
204 lf-infra-parameters
205 -------------------
206
207 Standard parameters used in the LF CI environments. Gerrit variables are
208 not used by GitHub projects, but defining them is not harmful. Should be used
209 in every job template.
210
211 lf-infra-node-parameters
212 ------------------------
213
214 Provides parameters needed by NodeJS and NPM. Should be used by any jobs that
215 need to run NodeJS or NPM.
216
217 lf-infra-tox-parameters
218 -----------------------
219
220 Provides parameters needed by python-tox. Should be used by any jobs that need
221 to run `tox <https://tox.readthedocs.io>`.
222
223 Properties
224 ==========
225
226 lf-infra-properties
227 -------------------
228
229 Configures the build-discarder plugin for Jenkins with the recommended lf-infra
230 settings. Should be used in all job-templates.
231
232 Publishers
233 ==========
234
235 lf-jacoco-report
236 ----------------
237
238 Provides basic configuration for the JaCoCo plugin.
239
240 lf-infra-publish
241 ----------------
242
243 Provides basic lf-infra recommended publisher configurations which should be
244 used in all job templates. This primary objective of this trigger is to
245 gather build logs and copy them to a log server.
246
247 SCM
248 ===
249
250 lf-infra-gerrit-scm
251 -------------------
252
253 Basic SCM configuration for Gerrit based projects.
254
255 lf-infra-github-scm
256 -------------------
257
258 Basic SCM configuration for GitHub based projects.
259
260 On the `branch` variable you can assign `$sha1` or `$ghprbActualCommit`
261 as the value.  This will require that the job be triggered via
262 the GHPRB plugin and not manually.
263
264 Wrappers
265 ========
266
267 lf-infra-wrappers
268 -----------------
269
270 Provides lf-infra recommended wrappers which should be used in every
271 job-template.
272
273 This wrapper requires that a managed file called `npmrc` exists in the Jenkins.  The main use
274 case here is to point to a npm proxy, on Nexus for example.
275 The type of the file should be "Custom file".  You can set various npmrc settings in it.
276 Documentation on npm configuration can be found at https://docs.npmjs.com/files/npmrc.
277 If you are not using npm then it is fine for the file to be empty.
278
279 Example npmrc:
280
281 .. code-block:: bash
282
283    registry=https://nexus3.onap.org/repository/npm.public/