Add maven metadata validator tool
[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-packer-build
57     builders:
58       - config-file-provider:
59           files:
60             - file-id: '{packer-cloud-settings}'
61               variable: CLOUDENV
62       - inject:
63           properties-content: |
64               PACKER_PLATFORM={platform}
65               PACKER_TEMPLATE={template}
66               PACKER_VERSION={packer-version}
67       - shell: !include-raw-escape:
68           - ../shell/packer-install.sh
69           - ../shell/packer-build.sh
70       - shell: !include-raw:
71           - ../shell/packer-clear-credentials.sh
72
73 - builder:
74     name: lf-infra-packer-validate
75     builders:
76       - config-file-provider:
77           files:
78             - file-id: '{packer-cloud-settings}'
79               variable: 'CLOUDENV'
80       - inject:
81           properties-content: |
82               PACKER_VERSION={packer-version}
83       - shell: !include-raw-escape:
84           - ../shell/packer-install.sh
85           - ../shell/packer-validate.sh
86       - shell: !include-raw:
87           - ../shell/packer-clear-credentials.sh
88
89 - builder:
90     name: lf-infra-sysstat
91     builders:
92       - shell: !include-raw:
93           - ../shell/sysstat.sh
94
95 - builder:
96     name: lf-jacoco-nojava-workaround
97     builders:
98       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
99
100 - builder:
101     name: lf-infra-deploy-maven-file
102     builders:
103       - lf-maven-install:
104           mvn-version: '{mvn-version}'
105       - lf-provide-maven-settings:
106           global-settings-file: '{global-settings-file}'
107           settings-file: '{settings-file}'
108       - inject:
109           properties-content: |
110               MAVEN_REPO_URL={maven-repo-url}
111               REPO_ID={repo-id}
112               GROUP_ID={group-id}
113               UPLOAD_FILES_PATH={upload-files-dir}
114       - shell: !include-raw-escape:
115           - ../shell/lftools-install.sh
116           - ../shell/common-variables.sh
117           - ../shell/deploy-maven-file.sh
118       - lf-provide-maven-settings-cleanup
119
120 - builder:
121     name: lf-maven-install
122     builders:
123       # Create a $HOME/.wgetrc to make the Maven download quiet.
124       - shell: 'echo "quiet=on" > "$HOME/.wgetrc"'
125       - maven-target:
126           maven-version: '{mvn-version}'
127           goals: '--version'
128       - shell: 'rm "$HOME/.wgetrc"'
129
130 - builder:
131     name: lf-provide-maven-settings
132     builders:
133       - config-file-provider:
134           files:
135             - file-id: '{global-settings-file}'
136               variable: 'GLOBAL_SETTINGS_FILE'
137             - file-id: '{settings-file}'
138               variable: 'SETTINGS_FILE'
139
140 - builder:
141     name: lf-provide-sigul-configuration
142     # Push configuration files to interact with sigul
143     builders:
144       - config-file-provider:
145           files:
146             - file-id: sigul-config
147               variable: SIGUL_CONFIG
148             - file-id: sigul-password
149               variable: SIGUL_PASSWORD
150             - file-id: sigul-pki
151               variable: SIGUL_PKI
152       - shell: !include-raw-escape: ../shell/sigul-configuration.sh
153
154 - builder:
155     name: lf-pip-install
156     builders:
157       - inject:
158           properties-content: PIP_PACKAGES={pip-packages}
159       - shell: !include-raw-escape: ../shell/pip-install.sh
160
161 - builder:
162     name: lf-provide-maven-settings-cleanup
163     builders:
164       - shell: |
165           #!/bin/bash
166           set +e  # DO NOT cause build failure if any of the rm calls fail.
167
168           rm "$GLOBAL_SETTINGS_FILE" "$SETTINGS_FILE"
169
170           # In some cases we use the lf-provide-maven-settings macro to produce
171           # a "$HOME/.netrc" file containing credentials. Remove that file here
172           # too if it exists.
173           rm "$HOME/.netrc"
174
175           # DO NOT fail build if any of the above lines fail.
176           exit 0
177
178 - builder:
179     name: lf-provide-sigul-configuration-cleanup
180     # Clear sigul configuration files after we're done using them
181     builders:
182       - shell: !include-raw-escape: ../shell/sigul-configuration-cleanup.sh
183
184 - builder:
185     name: lf-rtd-trigger-build
186     builders:
187       - inject:
188           properties-content: RTD_PROJECT={rtd-project}
189       - shell: !include-raw-escape: ../shell/rtd-trigger-build.sh
190
191 - builder:
192     name: lf-rtd-verify
193     builders:
194       - inject:
195           properties-content: DOC_DIR={doc-dir}
196       - shell: !include-raw-escape:
197           - ../shell/tox-install.sh
198           - ../shell/rtd-verify.sh
199
200 - builder:
201     name: lf-sigul-install
202     # Requires that Jenkins be configured with SIGUL_BRIDGE_IP as a global
203     # Environment variable
204     builder:
205       - shell: !include-raw-escape: ../shell/sigul-install.sh
206
207 ##############
208 # PARAMETERS #
209 ##############
210
211 - parameter:
212     name: lf-infra-maven-parameters
213     parameters:
214       - string:
215           name: M2_HOME
216           # Sets an env var for shell scripts to be able to call the dynamically
217           # installed maven without having to calculate the M2_HOME themselves.
218           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}'
219           description: 'Maven selector to be used by shell scripts'
220       - string:
221           name: MAVEN_OPTS
222           default: '{mvn-opts}'
223           description: |
224               Maven Java opts. Example: -Xmx1024m -XX:MaxPermSize=256m
225       - string:
226           name: MAVEN_PARAMS
227           default: '{mvn-params}'
228           description: |
229               Maven parameters to pass to the mvn command.
230       - string:
231           name: MVN
232           # Sets an env var for shell scripts to be able to call the dynamically
233           # installed maven without having to calculate the path themselves.
234           # yamllint disable-line rule:line-length
235           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn'
236           description: 'Maven selector to be used by shell scripts'
237       - string:
238           name: STAGING_PROFILE_ID
239           default: '{staging-profile-id}'
240           description: |
241               Nexus staging profile ID.
242
243
244 - parameter:
245     name: lf-infra-openstack-parameters
246     parameters:
247       - string:
248           name: OS_CLOUD
249           default: '{os-cloud}'
250           description: |
251               The name of a cloud configuration in clouds.yaml. OS_CLOUD is a
252               variable name that is significant to openstack client as a
253               environment variable. Please refer to the documentation for
254               further details.
255               https://docs.openstack.org/developer/python-openstackclient/
256
257
258 - parameter:
259     name: lf-infra-parameters
260     # Standard parameters used in the LF CI environments. Gerrit variables are
261     # not used by GitHub projects, but defining them isn't harmful.
262     parameters:
263       - string:
264           name: PROJECT
265           default: '{project}'
266           description: |
267               Parameter to identify a Gerrit project. This is typically the
268               project repo path as exists in Gerrit.
269               For example: ofextensions/circuitsw
270       - string:
271           name: STREAM
272           default: '{stream}'
273           description: |
274               Stream is often set to the same name as 'branch' but can
275               sometimes be used as a name representing a project's release code
276               name.
277       - string:
278           name: GERRIT_PROJECT
279           default: '{project}'
280           description: |
281               Parameter to identify Gerrit project. This is typically the
282               project repo path as exists in Gerrit.
283               For example: ofextensions/circuitsw
284
285               Note that Gerrit will override this parameter automatically if a
286               job is triggered by Gerrit.
287       - string:
288           name: GERRIT_BRANCH
289           default: '{branch}'
290           description: |
291               Parameter to identify a Gerrit branch.
292
293               Note that Gerrit will override this parameter automatically if a
294               job is triggered by Gerrit.
295       - string:
296           name: GERRIT_REFSPEC
297           default: 'refs/heads/{branch}'
298           description: |
299               Parameter to identify a refspec when pulling from Gerrit.
300
301               Note that Gerrit will override this parameter automatically if a
302               job is triggered by Gerrit.
303       - string:
304           name: LFTOOLS_VERSION
305           default: '{lftools-version}'
306           description: |
307               Version of lftools to install. Can be a specific version like
308               '0.6.0' or a PEP-440 definition.
309               https://www.python.org/dev/peps/pep-0440/
310               For example '<1.0.0' or '>=1.0.0,<2.0.0'.
311
312 - parameter:
313     name: lf-infra-node-parameters
314     parameters:
315       - string:
316           name: NODE_DIR
317           default: '{node-dir}'
318           description: Path to a Node project directory.
319       - string:
320           name: NODE_VERSION
321           default: '{node-version}'
322           description: Version of NodeJS to install.
323
324 - parameter:
325     name: lf-infra-tox-parameters
326     parameters:
327       - string:
328           name: TOX_DIR
329           default: '{tox-dir}'
330           description: |
331               Path to directory containing tox.ini file.
332       - string:
333           name: TOX_ENVS
334           default: '{tox-envs}'
335           description: |
336               Tox environments to run build against.
337               Example: docs,py2,py3
338
339 ##############
340 # PROPERTIES #
341 ##############
342
343 - property:
344     name: lf-infra-properties
345     properties:
346       - build-discarder:
347           # Allow build data to be stored at a length configured by the
348           # downstream project.
349           days-to-keep: '{build-days-to-keep}'
350           # Do not allow artifacts to be stored in Jenkins.
351           artifact-num-to-keep: 0
352
353 ##############
354 # PUBLISHERS #
355 ##############
356
357 - publisher:
358     name: lf-jacoco-report
359     publishers:
360       - jacoco:
361           exec-pattern: "**/**.exec"
362           class-pattern: "**/classes"
363           source-pattern: "**/src/main/java"
364           # yamllint disable-line rule:line-length
365           exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
366           status-update: true
367           targets:
368             - branch:
369                 healthy: 10
370                 unhealthy: 20
371             - method:
372                 healthy: 50
373                 unhealthy: 40
374
375 - publisher:
376     name: lf-infra-publish
377     # lf-infra macro to finish up a build.
378     #
379     # Handles the following:
380     #   - Shipping logs to Nexus logs site repository
381     #   - Cleanup workspace
382     publishers:
383       - postbuildscript:
384           builders:
385             - lf-infra-sysstat
386             - lf-infra-ship-logs
387           script-only-if-succeeded: false
388           script-only-if-failed: false
389           mark-unstable-if-failed: false
390       - workspace-cleanup:
391           exclude:
392             # Do not clean up *.jenkins-trigger files for jobs that use a
393             # properties file as input for triggering another build.
394             - '**/*.jenkins-trigger'
395           fail-build: false
396
397 #######
398 # SCM #
399 #######
400
401 - scm:
402     name: lf-infra-gerrit-scm
403     scm:
404       - git:
405           credentials-id: '{jenkins-ssh-credential}'
406           url: '{git-url}'
407           refspec: '{refspec}'
408           branches:
409             - 'refs/heads/{branch}'
410           skip-tag: true
411           wipe-workspace: true
412           submodule:
413             recursive: '{submodule-recursive}'
414           choosing-strategy: '{choosing-strategy}'
415
416 - scm:
417     name: lf-infra-github-scm
418     scm:
419       - git:
420           credentials-id: '{jenkins-ssh-credential}'
421           url: '{url}'
422           refspec: '{refspec}'
423           branches:
424             - '{branch}'
425           skip-tag: true
426           wipe-workspace: true
427           submodule:
428             recursive: '{submodule-recursive}'
429           choosing-strategy: '{choosing-strategy}'
430
431 ############
432 # TRIGGERS #
433 ############
434
435 - trigger:
436     name: lf-infra-github-pr-trigger
437     triggers:
438       - github-pull-request:
439           trigger-phrase: '{trigger-phrase}'
440           only-trigger-phrase: '{only-trigger-phrase}'
441           status-context: '{status-context}'
442           permit-all: '{permit-all}'
443           github-hooks: '{github-hooks}'
444           auto-close-on-fail: false
445           org-list:
446             - '{github-org}'
447           white-list: '{obj:github_pr_whitelist}'
448           admin-list: '{obj:github_pr_admin_list}'
449
450 ############
451 # WRAPPERS #
452 ############
453
454 - wrapper:
455     name: lf-infra-wrappers
456     wrappers:
457       - mask-passwords
458       - timeout:
459           type: absolute
460           timeout: '{build-timeout}'
461           timeout-var: 'BUILD_TIMEOUT'
462           fail: true
463       - timestamps
464       - ssh-agent-credentials:
465           users:
466             - '{jenkins-ssh-credential}'
467       - openstack:
468           single-use: true
469       - config-file-provider:
470           files:
471             - file-id: npmrc
472               target: '$HOME/.npmrc'