INFO.yaml check vote for global-jjb
[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-license-check
15     builders:
16       - inject:
17           properties-content: |
18               FILE_PATTERNS={file-patterns}
19               SPDX_DISABLE={spdx-disable}
20               LHC_VERSION={lhc-version}
21               LICENSE_EXCLUDE_PATHS={license-exclude-paths}
22               LICENSES_ALLOWED={licenses-allowed}
23       - shell: !include-raw-escape:
24           - ../shell/license-check.sh
25
26 - builder:
27     name: lf-infra-create-netrc
28     builders:
29       - inject:
30           properties-content: 'SERVER_ID={server-id}'
31       - shell: !include-raw-escape: ../shell/create-netrc.sh
32
33 - builder:
34     name: lf-infra-docker-login
35     builders:
36       - lf-provide-maven-settings:
37           global-settings-file: '{global-settings-file}'
38           settings-file: '{settings-file}'
39       - shell: !include-raw-escape: ../shell/docker-login.sh
40       - lf-provide-maven-settings-cleanup
41
42 - builder:
43     name: lf-infra-gpg-verify-git-signature
44     # TODO: Verify signature after downloading users public key from a locally
45     # created repository instead of the public keymesh. This requires a process
46     # in place to get ODL developers public keys into a local repository without
47     # increasing the job thoughput.
48     builders:
49       - shell: !include-raw: ../shell/gpg-verify-git-signature.sh
50
51 - builder:
52     name: lf-infra-pre-build
53     builders:
54       - shell: !include-raw-escape: ../shell/python-tools-install.sh
55
56 - builder:
57     name: lf-infra-ship-logs
58     builders:
59       # Ensure no pre-existing .netrc files are overriding logs config
60       - lf-provide-maven-settings-cleanup
61       - config-file-provider:
62           files:
63             - file-id: 'jenkins-log-archives-settings'
64               variable: 'SETTINGS_FILE'
65       - lf-infra-create-netrc:
66           server-id: logs
67       - shell: !include-raw:
68           # Ensure python-tools are installed in case job template does not
69           # call the lf-infra-pre-build macro.
70           - ../shell/python-tools-install.sh
71           - ../shell/logs-deploy.sh
72       - shell: !include-raw:
73           - ../shell/logs-clear-credentials.sh
74       - description-setter:
75           regexp: '^Build logs: .*'
76
77 - builder:
78     name: lf-infra-package-listing
79     builders:
80       - shell: !include-raw:
81           - ../shell/package-listing.sh
82
83 - builder:
84     name: lf-infra-packer-build
85     builders:
86       - conditional-step:
87           condition-kind: boolean-expression
88           condition-expression: '{openstack}'
89           steps:
90             - config-file-provider:
91                 files:
92                   - file-id: clouds-yaml
93                     target: '$HOME/.config/openstack/clouds.yaml'
94             - inject:
95                 properties-content: OS_CLOUD={openstack-cloud}
96       - config-file-provider:
97           files:
98             - file-id: '{packer-cloud-settings}'
99               variable: CLOUDENV
100       - inject:
101           properties-content: |
102               PACKER_PLATFORM={platform}
103               PACKER_TEMPLATE={template}
104               PACKER_VERSION={packer-version}
105       - shell: !include-raw-escape:
106           - ../shell/packer-install.sh
107           - ../shell/packer-build.sh
108       - shell: !include-raw:
109           - ../shell/packer-clear-credentials.sh
110
111 - builder:
112     name: lf-infra-packer-validate
113     builders:
114       - conditional-step:
115           condition-kind: boolean-expression
116           condition-expression: '{openstack}'
117           steps:
118             - config-file-provider:
119                 files:
120                   - file-id: clouds-yaml
121                     target: '$HOME/.config/openstack/clouds.yaml'
122             - inject:
123                 properties-content: OS_CLOUD={openstack-cloud}
124       - config-file-provider:
125           files:
126             - file-id: '{packer-cloud-settings}'
127               variable: CLOUDENV
128       - inject:
129           properties-content: |
130               PACKER_VERSION={packer-version}
131       - shell: !include-raw-escape:
132           - ../shell/packer-install.sh
133           - ../shell/packer-validate.sh
134       - shell: !include-raw:
135           - ../shell/packer-clear-credentials.sh
136
137 - builder:
138     name: lf-infra-push-gerrit-patch
139     builders:
140       - inject:
141           properties-content: |
142               PROJECT={project}
143               GERRIT_COMMIT_MESSAGE={gerrit-commit-message}
144               GERRIT_HOST={gerrit-host}
145               GERRIT_TOPIC={gerrit-topic}
146               GERRIT_USER={gerrit-user}
147               REVIEWERS_EMAIL={reviewers-email}
148       - shell: !include-raw-escape: ../shell/gerrit-push-patch.sh
149
150 - builder:
151     name: lf-infra-sysstat
152     builders:
153       - shell: !include-raw:
154           - ../shell/sysstat.sh
155
156 - builder:
157     name: lf-jacoco-nojava-workaround
158     builders:
159       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
160
161 - builder:
162     name: lf-infra-deploy-maven-file
163     builders:
164       - lf-maven-install:
165           mvn-version: '{mvn-version}'
166       - lf-provide-maven-settings:
167           global-settings-file: '{global-settings-file}'
168           settings-file: '{settings-file}'
169       - inject:
170           properties-content: |
171               MAVEN_REPO_URL={maven-repo-url}
172               REPO_ID={repo-id}
173               GROUP_ID={group-id}
174               UPLOAD_FILES_PATH={upload-files-dir}
175       - shell: !include-raw-escape:
176           - ../shell/common-variables.sh
177           - ../shell/deploy-maven-file.sh
178       - lf-provide-maven-settings-cleanup
179
180 - builder:
181     name: lf-maven-central
182     builders:
183       - conditional-step:
184           condition-kind: boolean-expression
185           condition-expression: '{mvn-central}'
186           steps:
187             - lf-provide-maven-settings:
188                 global-settings-file: '{mvn-global-settings}'
189                 settings-file: '{mvn-settings}'
190             - lf-infra-create-netrc:
191                 server-id: 'ossrh'
192             - inject:
193                 properties-content: 'OSSRH_PROFILE_ID={ossrh-profile-id}'
194             - shell: !include-raw-escape: ../shell/maven-central.sh
195             - lf-provide-maven-settings-cleanup
196
197 - builder:
198     name: lf-maven-install
199     builders:
200       # Create a $HOME/.wgetrc to make the Maven download quiet.
201       - shell: 'echo "quiet=on" > "$HOME/.wgetrc"'
202       - maven-target:
203           maven-version: '{mvn-version}'
204           goals: '--version'
205       - shell: 'rm "$HOME/.wgetrc"'
206
207 - builder:
208     name: lf-provide-maven-settings
209     builders:
210       - config-file-provider:
211           files:
212             - file-id: '{global-settings-file}'
213               variable: 'GLOBAL_SETTINGS_FILE'
214             - file-id: '{settings-file}'
215               variable: 'SETTINGS_FILE'
216
217 - builder:
218     name: lf-pip-install
219     builders:
220       - inject:
221           properties-content: PIP_PACKAGES={pip-packages}
222       - shell: !include-raw-escape: ../shell/pip-install.sh
223
224 - builder:
225     name: lf-provide-maven-settings-cleanup
226     builders:
227       - shell: |
228           #!/bin/bash
229           set +e  # DO NOT cause build failure if any of the rm calls fail.
230
231           rm -f "$GLOBAL_SETTINGS_FILE" "$SETTINGS_FILE"
232
233           # In some cases we use the lf-provide-maven-settings macro to produce
234           # a "$HOME/.netrc" file containing credentials. Remove that file here
235           # too if it exists.
236           rm -f "$HOME/.netrc"
237
238           # DO NOT fail build if any of the above lines fail.
239           exit 0
240
241 - builder:
242     name: lf-rtd-trigger-build
243     builders:
244       - inject:
245           properties-content: |
246             RTD_BUILD_URL={rtd-build-url}
247             RTD_TOKEN={rtd-token}
248       - shell: !include-raw-escape: ../shell/rtd-trigger-build.sh
249
250 - builder:
251     name: lf-rtd-verify
252     builders:
253       - inject:
254           properties-content: DOC_DIR={doc-dir}
255       - shell: !include-raw-escape: ../shell/tox-install.sh
256       - shell: !include-raw-escape: ../shell/rtd-verify.sh
257
258 - builder:
259     name: check-info-votes
260     builders:
261       - inject:
262           properties-content: JENKINS_SSH_CREDENTIAL={jenkins-ssh-credential}
263       - shell: !include-raw-escape: ../shell/check-info-votes.sh
264
265 - builder:
266     name: lf-sigul-sign-dir
267     # Requires that Jenkins be configured with SIGUL_BRIDGE_IP as a global
268     # Environment variable
269     builders:
270       - conditional-step:
271           condition-kind: boolean-expression
272           condition-expression: '{sign-artifacts}'
273           steps:
274             - config-file-provider:
275                 files:
276                   - file-id: sigul-config
277                     variable: SIGUL_CONFIG
278                   - file-id: sigul-password
279                     variable: SIGUL_PASSWORD
280                   - file-id: sigul-pki
281                     variable: SIGUL_PKI
282             - shell: !include-raw-escape: ../shell/sigul-configuration.sh
283             - shell: !include-raw-escape: ../shell/sigul-install.sh
284             - inject:
285                 properties-content: |
286                     SIGN_DIR={sign-dir}
287                     SIGN_MODE={sign-mode}
288             - shell: !include-raw-escape:
289                 - ../shell/sigul-sign-dir.sh
290             - shell: !include-raw-escape: ../shell/sigul-configuration-cleanup.sh
291
292 - builder:
293     name: lf-infra-provide-docker-cleanup
294     builders:
295       - shell: |
296           #!/bin/bash
297           set +e  # DO NOT cause build failure if docker rmi fails
298           docker rmi -f $(docker images -a -q)
299           exit 0
300
301
302 ##############
303 # PARAMETERS #
304 ##############
305
306 - parameter:
307     name: lf-clm-parameters
308     parameters:
309       - string:
310           name: NEXUS_IQ_STAGE
311           default: '{nexus-iq-stage}'
312           description: |
313               Stage the policy evaluation will be run against on the Nexus IQ Server.
314
315 - parameter:
316     name: lf-cmake-parameters
317     # Parameters useful in CMake builds.
318     parameters:
319       - string:
320           name: BUILD_DIR
321           default: '{build-dir}'
322           description: 'Directory to build the project in.'
323       - string:
324           name: CMAKE_OPTS
325           default: '{cmake-opts}'
326           description: |
327               Options to pass to CMAKE.
328               Example: -DCMAKE_INSTALL_PREFIX=$WORKSPACE/target/output
329       - string:
330           name: INSTALL_PREFIX
331           default: '{install-prefix}'
332           description: 'Install prefix for C/C++ builds. Example: /usr/local'
333       - string:
334           name: MAKE_OPTS
335           default: '{make-opts}'
336           description: 'Options to pass to make. Example: -j8'
337
338 - parameter:
339     name: lf-infra-maven-parameters
340     parameters:
341       - string:
342           name: M2_HOME
343           # Sets an env var for shell scripts to be able to call the dynamically
344           # installed maven without having to calculate the M2_HOME themselves.
345           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}'
346           description: 'Maven selector to be used by shell scripts'
347       - string:
348           name: MAVEN_OPTS
349           default: '{mvn-opts}'
350           description: |
351               Maven Java opts. Example: -Xmx1024m -XX:MaxPermSize=256m
352       - string:
353           name: MAVEN_PARAMS
354           default: '{mvn-params}'
355           description: |
356               Maven parameters to pass to the mvn command.
357       - string:
358           name: MVN
359           # Sets an env var for shell scripts to be able to call the dynamically
360           # installed maven without having to calculate the path themselves.
361           # yamllint disable-line rule:line-length
362           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn'
363           description: 'Maven selector to be used by shell scripts'
364
365 - parameter:
366     name: lf-infra-openstack-parameters
367     parameters:
368       - string:
369           name: OS_CLOUD
370           default: '{os-cloud}'
371           description: |
372               The name of a cloud configuration in clouds.yaml. OS_CLOUD is a
373               variable name that is significant to openstack client as a
374               environment variable. Please refer to the documentation for
375               further details.
376               https://docs.openstack.org/developer/python-openstackclient/
377
378
379 - parameter:
380     name: lf-infra-parameters
381     # Standard parameters used in the LF CI environments. Gerrit variables are
382     # not used by GitHub projects, but defining them isn't harmful.
383     parameters:
384       - string:
385           name: PROJECT
386           default: '{project}'
387           description: |
388               Parameter to identify a SCM project to build. This is typically
389               the project repo path. For example: ofextensions/circuitsw
390       - string:
391           name: STREAM
392           default: '{stream}'
393           description: |
394               Stream is often set to the same name as 'branch' but can
395               sometimes be used as a name representing a project's release code
396               name.
397       - string:
398           name: GERRIT_PROJECT
399           default: '{project}'
400           description: |
401               Gerrit Trigger provided parameter to identify Gerrit project that
402               triggered the build. This is typically the project repo path as
403               exists in Gerrit. For example: ofextensions/circuitsw
404
405               If using Gerrit, in a manual build this should match the PROJECT
406               parameter above.
407       - string:
408           name: GERRIT_BRANCH
409           default: '{branch}'
410           description: |
411               Gerrit Trigger provided parameter to identify a Gerrit branch.
412
413               If using Gerrit, in a manual build override with the branch to
414               build against.
415       - string:
416           name: GERRIT_REFSPEC
417           default: 'refs/heads/{branch}'
418           description: |
419               Gerrit Trigger provided parameter to identify a refspec to fetch
420               from Gerrit.
421
422               If using Gerrit, in a manual build override with a refspec.
423               https://git-scm.com/book/en/v2/Git-Internals-The-Refspec
424               For example: 'refs/heads/master'
425       - string:
426           name: sha1
427           default: 'origin/{branch}'
428           description: |
429               GitHub PR Trigger provided parameter for specifying the commit
430               to checkout.
431
432               If using GitHub, in a manual build override with a branch path or
433               sha1 hash to a specific commit. For example: 'origin/master'
434
435 - parameter:
436     name: lf-infra-node-parameters
437     parameters:
438       - string:
439           name: NODE_DIR
440           default: '{node-dir}'
441           description: Path to a Node project directory.
442       - string:
443           name: NODE_VERSION
444           default: '{node-version}'
445           description: Version of NodeJS to install.
446
447 - parameter:
448     name: lf-infra-tox-parameters
449     parameters:
450       - string:
451           name: TOX_DIR
452           default: '{tox-dir}'
453           description: |
454               Path to directory containing tox.ini file.
455       - string:
456           name: TOX_ENVS
457           default: '{tox-envs}'
458           description: |
459               Tox environments to run build against.
460               Example: docs,py2,py3
461
462 ##############
463 # PROPERTIES #
464 ##############
465
466 - property:
467     name: lf-infra-properties
468     properties:
469       - build-discarder:
470           # Allow build data to be stored at a length configured by the
471           # downstream project.
472           days-to-keep: '{build-days-to-keep}'
473           # Do not allow artifacts to be stored in Jenkins.
474           artifact-num-to-keep: 0
475
476 ##############
477 # PUBLISHERS #
478 ##############
479
480 - publisher:
481     name: lf-jacoco-report
482     publishers:
483       - jacoco:
484           exec-pattern: "**/**.exec"
485           class-pattern: "**/classes"
486           source-pattern: "**/src/main/java"
487           # yamllint disable-line rule:line-length
488           exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
489           status-update: true
490           targets:
491             - branch:
492                 healthy: 10
493                 unhealthy: 20
494             - method:
495                 healthy: 50
496                 unhealthy: 40
497
498 - publisher:
499     name: lf-infra-publish
500     # lf-infra macro to finish up a build.
501     #
502     # Handles the following:
503     #   - Shipping logs to Nexus logs site repository
504     #   - Cleanup workspace
505     publishers:
506       - postbuildscript:
507           builders:
508             - role: BOTH
509               build-on:
510                 - ABORTED
511                 - FAILURE
512                 - NOT_BUILT
513                 - SUCCESS
514                 - UNSTABLE
515               build-steps:
516                 - lf-infra-sysstat
517                 - lf-infra-package-listing
518                 - lf-infra-ship-logs
519           mark-unstable-if-failed: true
520       - workspace-cleanup:
521           exclude:
522             # Do not clean up *.jenkins-trigger files for jobs that use a
523             # properties file as input for triggering another build.
524             - '**/*.jenkins-trigger'
525           fail-build: false
526
527 - publisher:
528     name: lf-infra-publish-windows
529     # lf-infra macro to finish up a build.
530     #
531     # Handles the following:
532     #   - Shipping logs to Nexus logs site repository
533     #   - Cleanup workspace
534     publishers:
535       # TODO: RELENG-1228 Develop log shipping script for Windows systems
536       # - postbuildscript:
537       #     builders:
538       #       - role: BOTH
539       #         build-on:
540       #           - ABORTED
541       #           - FAILURE
542       #           - NOT_BUILT
543       #           - SUCCESS
544       #           - UNSTABLE
545       #         build-steps:
546       #           - lf-infra-ship-logs-windows
547       #     mark-unstable-if-failed: true
548       - workspace-cleanup:
549           exclude:
550             # Do not clean up *.jenkins-trigger files for jobs that use a
551             # properties file as input for triggering another build.
552             - '**/*.jenkins-trigger'
553           fail-build: false
554
555 #######
556 # SCM #
557 #######
558
559 - scm:
560     name: lf-infra-gerrit-scm
561     scm:
562       - git:
563           credentials-id: '{jenkins-ssh-credential}'
564           url: '{git-url}'
565           refspec: '{refspec}'
566           branches:
567             - 'refs/heads/{branch}'
568           skip-tag: true
569           wipe-workspace: true
570           submodule:
571             recursive: '{submodule-recursive}'
572             timeout: '{submodule-timeout}'
573           choosing-strategy: '{choosing-strategy}'
574
575 - scm:
576     name: lf-infra-github-scm
577     scm:
578       - git:
579           credentials-id: '{jenkins-ssh-credential}'
580           url: '{url}'
581           refspec: '{refspec}'
582           branches:
583             - '{branch}'
584           skip-tag: true
585           wipe-workspace: true
586           submodule:
587             recursive: '{submodule-recursive}'
588             timeout: '{submodule-timeout}'
589           choosing-strategy: '{choosing-strategy}'
590
591 ############
592 # WRAPPERS #
593 ############
594
595 - wrapper:
596     name: lf-infra-wrappers-common
597     wrappers:
598       - mask-passwords
599       - timeout:
600           type: absolute
601           timeout: '{build-timeout}'
602           timeout-var: 'BUILD_TIMEOUT'
603           fail: true
604       - timestamps
605       - openstack:
606           single-use: true
607
608 - wrapper:
609     name: lf-infra-wrappers
610     wrappers:
611       - lf-infra-wrappers-common:
612           build-timeout: '{build-timeout}'
613       - config-file-provider:
614           files:
615             - file-id: npmrc
616               target: '$HOME/.npmrc'
617             - file-id: pipconf
618               target: '$HOME/.config/pip/pip.conf'
619       - ssh-agent-credentials:
620           users:
621             - '{jenkins-ssh-credential}'
622
623 - wrapper:
624     name: lf-infra-wrappers-windows
625     wrappers:
626       - lf-infra-wrappers-common:
627           build-timeout: '{build-timeout}'