Merge "Standardize "release" wording"
[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-release
276     builders:
277       - config-file-provider:
278           files:
279             - file-id: lftoolsini
280               target: '$HOME/.config/lftools/lftools.ini'
281       - shell: !include-raw: ../shell/release-job.sh
282
283 - builder:
284     name: lf-sigul-sign-dir
285     # Requires that Jenkins be configured with SIGUL_BRIDGE_IP as a global
286     # Environment variable
287     builders:
288       - conditional-step:
289           condition-kind: boolean-expression
290           condition-expression: '{sign-artifacts}'
291           steps:
292             - config-file-provider:
293                 files:
294                   - file-id: sigul-config
295                     variable: SIGUL_CONFIG
296                   - file-id: sigul-password
297                     variable: SIGUL_PASSWORD
298                   - file-id: sigul-pki
299                     variable: SIGUL_PKI
300             - shell: !include-raw-escape: ../shell/sigul-configuration.sh
301             - shell: !include-raw-escape: ../shell/sigul-install.sh
302             - inject:
303                 properties-content: |
304                     SIGN_DIR={sign-dir}
305                     SIGN_MODE={sign-mode}
306             - shell: !include-raw-escape:
307                 - ../shell/sigul-sign-dir.sh
308             - shell: !include-raw-escape: ../shell/sigul-configuration-cleanup.sh
309
310 - builder:
311     name: lf-infra-provide-docker-cleanup
312     builders:
313       - shell: |
314           #!/bin/bash
315           set +e  # DO NOT cause build failure if docker rmi fails
316           docker rmi -f $(docker images -a -q)
317           exit 0
318
319
320 ##############
321 # PARAMETERS #
322 ##############
323
324 - parameter:
325     name: lf-clm-parameters
326     parameters:
327       - string:
328           name: NEXUS_IQ_STAGE
329           default: '{nexus-iq-stage}'
330           description: |
331               Stage the policy evaluation will be run against on the Nexus IQ Server.
332
333 - parameter:
334     name: lf-cmake-parameters
335     # Parameters useful in CMake builds.
336     parameters:
337       - string:
338           name: BUILD_DIR
339           default: '{build-dir}'
340           description: 'Directory to build the project in.'
341       - string:
342           name: CMAKE_OPTS
343           default: '{cmake-opts}'
344           description: |
345               Options to pass to CMAKE.
346               Example: -DCMAKE_INSTALL_PREFIX=$WORKSPACE/target/output
347       - string:
348           name: INSTALL_PREFIX
349           default: '{install-prefix}'
350           description: 'Install prefix for C/C++ builds. Example: /usr/local'
351       - string:
352           name: MAKE_OPTS
353           default: '{make-opts}'
354           description: 'Options to pass to make. Example: -j8'
355
356 - parameter:
357     name: lf-infra-maven-parameters
358     parameters:
359       - string:
360           name: M2_HOME
361           # Sets an env var for shell scripts to be able to call the dynamically
362           # installed maven without having to calculate the M2_HOME themselves.
363           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}'
364           description: 'Maven selector to be used by shell scripts'
365       - string:
366           name: MAVEN_OPTS
367           default: '{mvn-opts}'
368           description: |
369               Maven Java opts. Example: -Xmx1024m -XX:MaxPermSize=256m
370       - string:
371           name: MAVEN_PARAMS
372           default: '{mvn-params}'
373           description: |
374               Maven parameters to pass to the mvn command.
375       - string:
376           name: MVN
377           # Sets an env var for shell scripts to be able to call the dynamically
378           # installed maven without having to calculate the path themselves.
379           # yamllint disable-line rule:line-length
380           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn'
381           description: 'Maven selector to be used by shell scripts'
382
383 - parameter:
384     name: lf-infra-openstack-parameters
385     parameters:
386       - string:
387           name: OS_CLOUD
388           default: '{os-cloud}'
389           description: |
390               The name of a cloud configuration in clouds.yaml. OS_CLOUD is a
391               variable name that is significant to openstack client as a
392               environment variable. Please refer to the documentation for
393               further details.
394               https://docs.openstack.org/developer/python-openstackclient/
395
396
397 - parameter:
398     name: lf-infra-parameters
399     # Standard parameters used in the LF CI environments. Gerrit variables are
400     # not used by GitHub projects, but defining them isn't harmful.
401     parameters:
402       - string:
403           name: PROJECT
404           default: '{project}'
405           description: |
406               Parameter to identify a SCM project to build. This is typically
407               the project repo path. For example: ofextensions/circuitsw
408       - string:
409           name: STREAM
410           default: '{stream}'
411           description: |
412               Stream is often set to the same name as 'branch' but can
413               sometimes be used as a name representing a project's release code
414               name.
415       - string:
416           name: GERRIT_PROJECT
417           default: '{project}'
418           description: |
419               Gerrit Trigger provided parameter to identify Gerrit project that
420               triggered the build. This is typically the project repo path as
421               exists in Gerrit. For example: ofextensions/circuitsw
422
423               If using Gerrit, in a manual build this should match the PROJECT
424               parameter above.
425       - string:
426           name: GERRIT_BRANCH
427           default: '{branch}'
428           description: |
429               Gerrit Trigger provided parameter to identify a Gerrit branch.
430
431               If using Gerrit, in a manual build override with the branch to
432               build against.
433       - string:
434           name: GERRIT_REFSPEC
435           default: 'refs/heads/{branch}'
436           description: |
437               Gerrit Trigger provided parameter to identify a refspec to fetch
438               from Gerrit.
439
440               If using Gerrit, in a manual build override with a refspec.
441               https://git-scm.com/book/en/v2/Git-Internals-The-Refspec
442               For example: 'refs/heads/master'
443       - string:
444           name: sha1
445           default: 'origin/{branch}'
446           description: |
447               GitHub PR Trigger provided parameter for specifying the commit
448               to checkout.
449
450               If using GitHub, in a manual build override with a branch path or
451               sha1 hash to a specific commit. For example: 'origin/master'
452
453 - parameter:
454     name: lf-infra-node-parameters
455     parameters:
456       - string:
457           name: NODE_DIR
458           default: '{node-dir}'
459           description: Path to a Node project directory.
460       - string:
461           name: NODE_VERSION
462           default: '{node-version}'
463           description: Version of NodeJS to install.
464
465 - parameter:
466     name: lf-infra-tox-parameters
467     parameters:
468       - string:
469           name: TOX_DIR
470           default: '{tox-dir}'
471           description: |
472               Path to directory containing tox.ini file.
473       - string:
474           name: TOX_ENVS
475           default: '{tox-envs}'
476           description: |
477               Tox environments to run build against.
478               Example: docs,py2,py3
479
480 ##############
481 # PROPERTIES #
482 ##############
483
484 - property:
485     name: lf-infra-properties
486     properties:
487       - build-discarder:
488           # Allow build data to be stored at a length configured by the
489           # downstream project.
490           days-to-keep: '{build-days-to-keep}'
491           # Do not allow artifacts to be stored in Jenkins.
492           artifact-num-to-keep: 0
493
494 ##############
495 # PUBLISHERS #
496 ##############
497
498 - publisher:
499     name: lf-jacoco-report
500     publishers:
501       - jacoco:
502           exec-pattern: "**/**.exec"
503           class-pattern: "**/classes"
504           source-pattern: "**/src/main/java"
505           # yamllint disable-line rule:line-length
506           exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
507           status-update: true
508           targets:
509             - branch:
510                 healthy: 10
511                 unhealthy: 20
512             - method:
513                 healthy: 50
514                 unhealthy: 40
515
516 - publisher:
517     name: lf-infra-publish
518     # lf-infra macro to finish up a build.
519     #
520     # Handles the following:
521     #   - Shipping logs to Nexus logs site repository
522     #   - Cleanup workspace
523     publishers:
524       - postbuildscript:
525           builders:
526             - role: BOTH
527               build-on:
528                 - ABORTED
529                 - FAILURE
530                 - NOT_BUILT
531                 - SUCCESS
532                 - UNSTABLE
533               build-steps:
534                 - lf-infra-sysstat
535                 - lf-infra-package-listing
536                 - lf-infra-ship-logs
537           mark-unstable-if-failed: true
538       - workspace-cleanup:
539           exclude:
540             # Do not clean up *.jenkins-trigger files for jobs that use a
541             # properties file as input for triggering another build.
542             - '**/*.jenkins-trigger'
543           fail-build: false
544
545 - publisher:
546     name: lf-infra-publish-windows
547     # lf-infra macro to finish up a build.
548     #
549     # Handles the following:
550     #   - Shipping logs to Nexus logs site repository
551     #   - Cleanup workspace
552     publishers:
553       # TODO: RELENG-1228 Develop log shipping script for Windows systems
554       # - postbuildscript:
555       #     builders:
556       #       - role: BOTH
557       #         build-on:
558       #           - ABORTED
559       #           - FAILURE
560       #           - NOT_BUILT
561       #           - SUCCESS
562       #           - UNSTABLE
563       #         build-steps:
564       #           - lf-infra-ship-logs-windows
565       #     mark-unstable-if-failed: true
566       - workspace-cleanup:
567           exclude:
568             # Do not clean up *.jenkins-trigger files for jobs that use a
569             # properties file as input for triggering another build.
570             - '**/*.jenkins-trigger'
571           fail-build: false
572
573 #######
574 # SCM #
575 #######
576
577 - scm:
578     name: lf-infra-gerrit-scm
579     scm:
580       - git:
581           credentials-id: '{jenkins-ssh-credential}'
582           url: '{git-url}'
583           refspec: '{refspec}'
584           branches:
585             - 'refs/heads/{branch}'
586           skip-tag: true
587           wipe-workspace: true
588           submodule:
589             disable: '{submodule-disable}'
590             recursive: '{submodule-recursive}'
591             timeout: '{submodule-timeout}'
592           choosing-strategy: '{choosing-strategy}'
593
594 - scm:
595     name: lf-infra-github-scm
596     scm:
597       - git:
598           credentials-id: '{jenkins-ssh-credential}'
599           url: '{url}'
600           refspec: '{refspec}'
601           branches:
602             - '{branch}'
603           skip-tag: true
604           wipe-workspace: true
605           submodule:
606             disable: '{submodule-disable}'
607             recursive: '{submodule-recursive}'
608             timeout: '{submodule-timeout}'
609           choosing-strategy: '{choosing-strategy}'
610
611 ############
612 # WRAPPERS #
613 ############
614
615 - wrapper:
616     name: lf-infra-wrappers-common
617     wrappers:
618       - mask-passwords
619       - timeout:
620           type: absolute
621           timeout: '{build-timeout}'
622           timeout-var: 'BUILD_TIMEOUT'
623           fail: true
624       - timestamps
625       - openstack:
626           single-use: true
627
628 - wrapper:
629     name: lf-infra-wrappers
630     wrappers:
631       - lf-infra-wrappers-common:
632           build-timeout: '{build-timeout}'
633       - config-file-provider:
634           files:
635             - file-id: npmrc
636               target: '$HOME/.npmrc'
637             - file-id: pipconf
638               target: '$HOME/.config/pip/pip.conf'
639       - ssh-agent-credentials:
640           users:
641             - '{jenkins-ssh-credential}'
642
643 - wrapper:
644     name: lf-infra-wrappers-windows
645     wrappers:
646       - lf-infra-wrappers-common:
647           build-timeout: '{build-timeout}'