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