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