Document undocumented ci-jobs macros
[releng/global-jjb.git] / jjb / lf-macros.yaml
1 ---
2 ############
3 # BUILDERS #
4 ############
5
6 - builder:
7     name: lf-fetch-dependent-patches
8     builders:
9       - shell: !include-raw: ../shell/gerrit-fetch-dependencies.sh
10       - inject:
11           properties-file: $WORKSPACE/.dependency.properties
12
13 - builder:
14     name: lf-infra-create-netrc
15     builders:
16       - inject:
17           properties-content: 'SERVER_ID={server-id}'
18       - shell: !include-raw-escape: ../shell/create-netrc.sh
19
20 - builder:
21     name: lf-infra-docker-login
22     builders:
23       - lf-provide-maven-settings:
24           global-settings-file: '{global-settings-file}'
25           settings-file: '{settings-file}'
26       - shell: !include-raw-escape: ../shell/docker-login.sh
27       - lf-provide-maven-settings-cleanup
28
29 - builder:
30     name: lf-infra-gpg-verify-git-signature
31     # TODO: Verify signature after downloading users public key from a locally
32     # created repository instead of the public keymesh. This requires a process
33     # in place to get ODL developers public keys into a local repository without
34     # increasing the job thoughput.
35     builders:
36       - shell: !include-raw: ../shell/gpg-verify-git-signature.sh
37
38 - builder:
39     name: lf-infra-ship-logs
40     builders:
41       - config-file-provider:
42           files:
43             - file-id: 'jenkins-log-archives-settings'
44               variable: 'SETTINGS_FILE'
45       - lf-infra-create-netrc:
46           server-id: logs
47       - shell: !include-raw:
48           - ../shell/lftools-install.sh
49           - ../shell/logs-deploy.sh
50       - shell: !include-raw:
51           - ../shell/logs-clear-credentials.sh
52       - description-setter:
53           regexp: '^Build logs: .*'
54
55 - builder:
56     name: lf-infra-package-listing
57     builders:
58       - shell: !include-raw:
59           - ../shell/package-listing.sh
60
61 - builder:
62     name: lf-infra-packer-build
63     builders:
64       - config-file-provider:
65           files:
66             - file-id: '{packer-cloud-settings}'
67               variable: CLOUDENV
68       - inject:
69           properties-content: |
70               PACKER_PLATFORM={platform}
71               PACKER_TEMPLATE={template}
72               PACKER_VERSION={packer-version}
73       - shell: !include-raw-escape:
74           - ../shell/packer-install.sh
75           - ../shell/packer-build.sh
76       - shell: !include-raw:
77           - ../shell/packer-clear-credentials.sh
78
79 - builder:
80     name: lf-infra-packer-validate
81     builders:
82       - config-file-provider:
83           files:
84             - file-id: '{packer-cloud-settings}'
85               variable: 'CLOUDENV'
86       - inject:
87           properties-content: |
88               PACKER_VERSION={packer-version}
89       - shell: !include-raw-escape:
90           - ../shell/packer-install.sh
91           - ../shell/packer-validate.sh
92       - shell: !include-raw:
93           - ../shell/packer-clear-credentials.sh
94
95 - builder:
96     name: lf-infra-push-gerrit-patch
97     builders:
98       - inject:
99           properties-content: |
100               PROJECT='{project}'
101               GERRIT_COMMIT_MESSAGE='{gerrit-commit-message}'
102               GERRIT_HOST='{gerrit-host}'
103               GERRIT_TOPIC='{gerrit-topic}'
104               GERRIT_USER='{gerrit-user}'
105               REVIEWERS_EMAIL='{reviewers-email}'
106       - shell: !include-raw-escape: ../shell/gerrit-push-patch.sh
107
108 - builder:
109     name: lf-infra-sysstat
110     builders:
111       - shell: !include-raw:
112           - ../shell/sysstat.sh
113
114 - builder:
115     name: lf-jacoco-nojava-workaround
116     builders:
117       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
118
119 - builder:
120     name: lf-infra-deploy-maven-file
121     builders:
122       - lf-maven-install:
123           mvn-version: '{mvn-version}'
124       - lf-provide-maven-settings:
125           global-settings-file: '{global-settings-file}'
126           settings-file: '{settings-file}'
127       - inject:
128           properties-content: |
129               MAVEN_REPO_URL={maven-repo-url}
130               REPO_ID={repo-id}
131               GROUP_ID={group-id}
132               UPLOAD_FILES_PATH={upload-files-dir}
133       - shell: !include-raw-escape:
134           - ../shell/lftools-install.sh
135           - ../shell/common-variables.sh
136           - ../shell/deploy-maven-file.sh
137       - lf-provide-maven-settings-cleanup
138
139 - builder:
140     name: lf-maven-install
141     builders:
142       # Create a $HOME/.wgetrc to make the Maven download quiet.
143       - shell: 'echo "quiet=on" > "$HOME/.wgetrc"'
144       - maven-target:
145           maven-version: '{mvn-version}'
146           goals: '--version'
147       - shell: 'rm "$HOME/.wgetrc"'
148
149 - builder:
150     name: lf-provide-maven-settings
151     builders:
152       - config-file-provider:
153           files:
154             - file-id: '{global-settings-file}'
155               variable: 'GLOBAL_SETTINGS_FILE'
156             - file-id: '{settings-file}'
157               variable: 'SETTINGS_FILE'
158
159 - builder:
160     name: lf-provide-sigul-configuration
161     # Push configuration files to interact with sigul
162     builders:
163       - config-file-provider:
164           files:
165             - file-id: sigul-config
166               variable: SIGUL_CONFIG
167             - file-id: sigul-password
168               variable: SIGUL_PASSWORD
169             - file-id: sigul-pki
170               variable: SIGUL_PKI
171       - shell: !include-raw-escape: ../shell/sigul-configuration.sh
172
173 - builder:
174     name: lf-pip-install
175     builders:
176       - inject:
177           properties-content: PIP_PACKAGES={pip-packages}
178       - shell: !include-raw-escape: ../shell/pip-install.sh
179
180 - builder:
181     name: lf-provide-maven-settings-cleanup
182     builders:
183       - shell: |
184           #!/bin/bash
185           set +e  # DO NOT cause build failure if any of the rm calls fail.
186
187           rm -f "$GLOBAL_SETTINGS_FILE" "$SETTINGS_FILE"
188
189           # In some cases we use the lf-provide-maven-settings macro to produce
190           # a "$HOME/.netrc" file containing credentials. Remove that file here
191           # too if it exists.
192           rm -f "$HOME/.netrc"
193
194           # DO NOT fail build if any of the above lines fail.
195           exit 0
196
197 - builder:
198     name: lf-provide-sigul-configuration-cleanup
199     # Clear sigul configuration files after we're done using them
200     builders:
201       - shell: !include-raw-escape: ../shell/sigul-configuration-cleanup.sh
202
203 - builder:
204     name: lf-rtd-trigger-build
205     builders:
206       - inject:
207           properties-content: |
208             RTD_BUILD_URL={rtd-build-url}
209             RTD_TOKEN={rtd-token}
210       - shell: !include-raw-escape: ../shell/rtd-trigger-build.sh
211
212 - builder:
213     name: lf-rtd-verify
214     builders:
215       - inject:
216           properties-content: DOC_DIR={doc-dir}
217       - shell: !include-raw-escape:
218           - ../shell/tox-install.sh
219           - ../shell/rtd-verify.sh
220
221 - builder:
222     name: lf-sigul-install
223     # Requires that Jenkins be configured with SIGUL_BRIDGE_IP as a global
224     # Environment variable
225     builder:
226       - shell: !include-raw-escape: ../shell/sigul-install.sh
227
228 - builder:
229     name: lf-infra-provide-docker-cleanup
230     builders:
231       - shell: |
232           #!/bin/bash
233           set +e  # DO NOT cause build failure if docker rmi fails
234           docker rmi -f $(docker images -a -q)
235           exit 0
236
237
238 ##############
239 # PARAMETERS #
240 ##############
241
242 - parameter:
243     name: lf-infra-maven-parameters
244     parameters:
245       - string:
246           name: M2_HOME
247           # Sets an env var for shell scripts to be able to call the dynamically
248           # installed maven without having to calculate the M2_HOME themselves.
249           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}'
250           description: 'Maven selector to be used by shell scripts'
251       - string:
252           name: MAVEN_OPTS
253           default: '{mvn-opts}'
254           description: |
255               Maven Java opts. Example: -Xmx1024m -XX:MaxPermSize=256m
256       - string:
257           name: MAVEN_PARAMS
258           default: '{mvn-params}'
259           description: |
260               Maven parameters to pass to the mvn command.
261       - string:
262           name: MVN
263           # Sets an env var for shell scripts to be able to call the dynamically
264           # installed maven without having to calculate the path themselves.
265           # yamllint disable-line rule:line-length
266           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn'
267           description: 'Maven selector to be used by shell scripts'
268       - string:
269           name: STAGING_PROFILE_ID
270           default: '{staging-profile-id}'
271           description: |
272               Nexus staging profile ID.
273
274
275 - parameter:
276     name: lf-infra-openstack-parameters
277     parameters:
278       - string:
279           name: OS_CLOUD
280           default: '{os-cloud}'
281           description: |
282               The name of a cloud configuration in clouds.yaml. OS_CLOUD is a
283               variable name that is significant to openstack client as a
284               environment variable. Please refer to the documentation for
285               further details.
286               https://docs.openstack.org/developer/python-openstackclient/
287
288
289 - parameter:
290     name: lf-infra-parameters
291     # Standard parameters used in the LF CI environments. Gerrit variables are
292     # not used by GitHub projects, but defining them isn't harmful.
293     parameters:
294       - string:
295           name: PROJECT
296           default: '{project}'
297           description: |
298               Parameter to identify a SCM project to build. This is typically
299               the project repo path. For example: ofextensions/circuitsw
300       - string:
301           name: STREAM
302           default: '{stream}'
303           description: |
304               Stream is often set to the same name as 'branch' but can
305               sometimes be used as a name representing a project's release code
306               name.
307       - string:
308           name: GERRIT_PROJECT
309           default: '{project}'
310           description: |
311               Gerrit Trigger provided parameter to identify Gerrit project that
312               triggered the build. This is typically the project repo path as
313               exists in Gerrit. For example: ofextensions/circuitsw
314
315               If using Gerrit, in a manual build this should match the PROJECT
316               parameter above.
317       - string:
318           name: GERRIT_BRANCH
319           default: '{branch}'
320           description: |
321               Gerrit Trigger provided parameter to identify a Gerrit branch.
322
323               If using Gerrit, in a manual build override with the branch to
324               build against.
325       - string:
326           name: GERRIT_REFSPEC
327           default: 'refs/heads/{branch}'
328           description: |
329               Gerrit Trigger provided parameter to identify a refspec to fetch
330               from Gerrit.
331
332               If using Gerrit, in a manual build override with a refspec.
333               https://git-scm.com/book/en/v2/Git-Internals-The-Refspec
334               For example: 'refs/heads/master'
335       - string:
336           name: sha1
337           default: 'origin/{branch}'
338           description: |
339               GitHub PR Trigger provided parameter for specifying the commit
340               to checkout.
341
342               If using GitHub, in a manual build override with a branch path or
343               sha1 hash to a specific commit. For example: 'origin/master'
344       # Tools
345       - string:
346           name: LFTOOLS_VERSION
347           default: '{lftools-version}'
348           description: |
349               Version of lftools to install. Can be a specific version like
350               '0.6.0' or a PEP-440 definition.
351               https://www.python.org/dev/peps/pep-0440/
352               For example '<1.0.0' or '>=1.0.0,<2.0.0'.
353
354 - parameter:
355     name: lf-infra-node-parameters
356     parameters:
357       - string:
358           name: NODE_DIR
359           default: '{node-dir}'
360           description: Path to a Node project directory.
361       - string:
362           name: NODE_VERSION
363           default: '{node-version}'
364           description: Version of NodeJS to install.
365
366 - parameter:
367     name: lf-infra-tox-parameters
368     parameters:
369       - string:
370           name: TOX_DIR
371           default: '{tox-dir}'
372           description: |
373               Path to directory containing tox.ini file.
374       - string:
375           name: TOX_ENVS
376           default: '{tox-envs}'
377           description: |
378               Tox environments to run build against.
379               Example: docs,py2,py3
380
381 ##############
382 # PROPERTIES #
383 ##############
384
385 - property:
386     name: lf-infra-properties
387     properties:
388       - build-discarder:
389           # Allow build data to be stored at a length configured by the
390           # downstream project.
391           days-to-keep: '{build-days-to-keep}'
392           # Do not allow artifacts to be stored in Jenkins.
393           artifact-num-to-keep: 0
394
395 ##############
396 # PUBLISHERS #
397 ##############
398
399 - publisher:
400     name: lf-jacoco-report
401     publishers:
402       - jacoco:
403           exec-pattern: "**/**.exec"
404           class-pattern: "**/classes"
405           source-pattern: "**/src/main/java"
406           # yamllint disable-line rule:line-length
407           exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
408           status-update: true
409           targets:
410             - branch:
411                 healthy: 10
412                 unhealthy: 20
413             - method:
414                 healthy: 50
415                 unhealthy: 40
416
417 - publisher:
418     name: lf-infra-publish
419     # lf-infra macro to finish up a build.
420     #
421     # Handles the following:
422     #   - Shipping logs to Nexus logs site repository
423     #   - Cleanup workspace
424     publishers:
425       - postbuildscript:
426           builders:
427             - role: BOTH
428               build-on:
429                 - ABORTED
430                 - FAILURE
431                 - NOT_BUILT
432                 - SUCCESS
433                 - UNSTABLE
434               build-steps:
435                 - lf-infra-sysstat
436                 - lf-infra-package-listing
437                 - lf-infra-ship-logs
438           mark-unstable-if-failed: true
439       - workspace-cleanup:
440           exclude:
441             # Do not clean up *.jenkins-trigger files for jobs that use a
442             # properties file as input for triggering another build.
443             - '**/*.jenkins-trigger'
444           fail-build: false
445
446 #######
447 # SCM #
448 #######
449
450 - scm:
451     name: lf-infra-gerrit-scm
452     scm:
453       - git:
454           credentials-id: '{jenkins-ssh-credential}'
455           url: '{git-url}'
456           refspec: '{refspec}'
457           branches:
458             - 'refs/heads/{branch}'
459           skip-tag: true
460           wipe-workspace: true
461           submodule:
462             recursive: '{submodule-recursive}'
463           choosing-strategy: '{choosing-strategy}'
464
465 - scm:
466     name: lf-infra-github-scm
467     scm:
468       - git:
469           credentials-id: '{jenkins-ssh-credential}'
470           url: '{url}'
471           refspec: '{refspec}'
472           branches:
473             - '{branch}'
474           skip-tag: true
475           wipe-workspace: true
476           submodule:
477             recursive: '{submodule-recursive}'
478           choosing-strategy: '{choosing-strategy}'
479
480 ############
481 # WRAPPERS #
482 ############
483
484 - wrapper:
485     name: lf-infra-wrappers
486     wrappers:
487       - mask-passwords
488       - timeout:
489           type: absolute
490           timeout: '{build-timeout}'
491           timeout-var: 'BUILD_TIMEOUT'
492           fail: true
493       - timestamps
494       - ssh-agent-credentials:
495           users:
496             - '{jenkins-ssh-credential}'
497       - openstack:
498           single-use: true
499       - config-file-provider:
500           files:
501             - file-id: npmrc
502               target: '$HOME/.npmrc'
503             - file-id: pipconf
504               target: '$HOME/.config/pip/pip.conf'