Fix github-maven-merge scm config
[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       - config-file-provider:
113           files:
114             - file-id: '{packer-cloud-settings}'
115               variable: 'CLOUDENV'
116       - inject:
117           properties-content: |
118               PACKER_VERSION={packer-version}
119       - shell: !include-raw-escape:
120           - ../shell/packer-install.sh
121           - ../shell/packer-validate.sh
122       - shell: !include-raw:
123           - ../shell/packer-clear-credentials.sh
124
125 - builder:
126     name: lf-infra-push-gerrit-patch
127     builders:
128       - inject:
129           properties-content: |
130               PROJECT={project}
131               GERRIT_COMMIT_MESSAGE={gerrit-commit-message}
132               GERRIT_HOST={gerrit-host}
133               GERRIT_TOPIC={gerrit-topic}
134               GERRIT_USER={gerrit-user}
135               REVIEWERS_EMAIL={reviewers-email}
136       - shell: !include-raw-escape: ../shell/gerrit-push-patch.sh
137
138 - builder:
139     name: lf-infra-sysstat
140     builders:
141       - shell: !include-raw:
142           - ../shell/sysstat.sh
143
144 - builder:
145     name: lf-jacoco-nojava-workaround
146     builders:
147       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
148
149 - builder:
150     name: lf-infra-deploy-maven-file
151     builders:
152       - lf-maven-install:
153           mvn-version: '{mvn-version}'
154       - lf-provide-maven-settings:
155           global-settings-file: '{global-settings-file}'
156           settings-file: '{settings-file}'
157       - inject:
158           properties-content: |
159               MAVEN_REPO_URL={maven-repo-url}
160               REPO_ID={repo-id}
161               GROUP_ID={group-id}
162               UPLOAD_FILES_PATH={upload-files-dir}
163       - shell: !include-raw-escape:
164           - ../shell/lftools-install.sh
165           - ../shell/common-variables.sh
166           - ../shell/deploy-maven-file.sh
167       - lf-provide-maven-settings-cleanup
168
169 - builder:
170     name: lf-maven-install
171     builders:
172       # Create a $HOME/.wgetrc to make the Maven download quiet.
173       - shell: 'echo "quiet=on" > "$HOME/.wgetrc"'
174       - maven-target:
175           maven-version: '{mvn-version}'
176           goals: '--version'
177       - shell: 'rm "$HOME/.wgetrc"'
178
179 - builder:
180     name: lf-provide-maven-settings
181     builders:
182       - config-file-provider:
183           files:
184             - file-id: '{global-settings-file}'
185               variable: 'GLOBAL_SETTINGS_FILE'
186             - file-id: '{settings-file}'
187               variable: 'SETTINGS_FILE'
188
189 - builder:
190     name: lf-pip-install
191     builders:
192       - inject:
193           properties-content: PIP_PACKAGES={pip-packages}
194       - shell: !include-raw-escape: ../shell/pip-install.sh
195
196 - builder:
197     name: lf-provide-maven-settings-cleanup
198     builders:
199       - shell: |
200           #!/bin/bash
201           set +e  # DO NOT cause build failure if any of the rm calls fail.
202
203           rm -f "$GLOBAL_SETTINGS_FILE" "$SETTINGS_FILE"
204
205           # In some cases we use the lf-provide-maven-settings macro to produce
206           # a "$HOME/.netrc" file containing credentials. Remove that file here
207           # too if it exists.
208           rm -f "$HOME/.netrc"
209
210           # DO NOT fail build if any of the above lines fail.
211           exit 0
212
213 - builder:
214     name: lf-rtd-trigger-build
215     builders:
216       - inject:
217           properties-content: |
218             RTD_BUILD_URL={rtd-build-url}
219             RTD_TOKEN={rtd-token}
220       - shell: !include-raw-escape: ../shell/rtd-trigger-build.sh
221
222 - builder:
223     name: lf-rtd-verify
224     builders:
225       - inject:
226           properties-content: DOC_DIR={doc-dir}
227       - shell: !include-raw-escape: ../shell/tox-install.sh
228       - shell: !include-raw-escape: ../shell/rtd-verify.sh
229
230 - builder:
231     name: lf-sigul-sign-dir
232     # Requires that Jenkins be configured with SIGUL_BRIDGE_IP as a global
233     # Environment variable
234     builders:
235       - conditional-step:
236           condition-kind: boolean-expression
237           condition-expression: '{sign-artifacts}'
238           steps:
239             - config-file-provider:
240                 files:
241                   - file-id: sigul-config
242                     variable: SIGUL_CONFIG
243                   - file-id: sigul-password
244                     variable: SIGUL_PASSWORD
245                   - file-id: sigul-pki
246                     variable: SIGUL_PKI
247             - shell: !include-raw-escape: ../shell/sigul-configuration.sh
248             - shell: !include-raw-escape: ../shell/sigul-install.sh
249             - inject:
250                 properties-content: SIGN_DIR={sign-dir}
251             - shell: !include-raw-escape:
252                 - ../shell/common-variables.sh
253                 - ../shell/sigul-sign-dir.sh
254             - shell: !include-raw-escape: ../shell/sigul-configuration-cleanup.sh
255
256 - builder:
257     name: lf-infra-provide-docker-cleanup
258     builders:
259       - shell: |
260           #!/bin/bash
261           set +e  # DO NOT cause build failure if docker rmi fails
262           docker rmi -f $(docker images -a -q)
263           exit 0
264
265
266 ##############
267 # PARAMETERS #
268 ##############
269
270 - parameter:
271     name: lf-clm-parameters
272     parameters:
273       - string:
274           name: NEXUS_IQ_STAGE
275           default: '{nexus-iq-stage}'
276           description: |
277               Stage the policy evaluation will be run against on the Nexus IQ Server.
278
279 - parameter:
280     name: lf-cmake-parameters
281     # Parameters useful in CMake builds.
282     parameters:
283       - string:
284           name: BUILD_DIR
285           default: '{build-dir}'
286           description: 'Directory to build the project in.'
287       - string:
288           name: CMAKE_OPTS
289           default: '{cmake-opts}'
290           description: |
291               Options to pass to CMAKE.
292               Example: -DCMAKE_INSTALL_PREFIX=$WORKSPACE/target/output
293       - string:
294           name: INSTALL_PREFIX
295           default: '{install-prefix}'
296           description: 'Install prefix for C/C++ builds. Example: /usr/local'
297       - string:
298           name: MAKE_OPTS
299           default: '{make-opts}'
300           description: 'Options to pass to make. Example: -j8'
301
302 - parameter:
303     name: lf-infra-maven-parameters
304     parameters:
305       - string:
306           name: M2_HOME
307           # Sets an env var for shell scripts to be able to call the dynamically
308           # installed maven without having to calculate the M2_HOME themselves.
309           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}'
310           description: 'Maven selector to be used by shell scripts'
311       - string:
312           name: MAVEN_OPTS
313           default: '{mvn-opts}'
314           description: |
315               Maven Java opts. Example: -Xmx1024m -XX:MaxPermSize=256m
316       - string:
317           name: MAVEN_PARAMS
318           default: '{mvn-params}'
319           description: |
320               Maven parameters to pass to the mvn command.
321       - string:
322           name: MVN
323           # Sets an env var for shell scripts to be able to call the dynamically
324           # installed maven without having to calculate the path themselves.
325           # yamllint disable-line rule:line-length
326           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn'
327           description: 'Maven selector to be used by shell scripts'
328
329 - parameter:
330     name: lf-infra-openstack-parameters
331     parameters:
332       - string:
333           name: OS_CLOUD
334           default: '{os-cloud}'
335           description: |
336               The name of a cloud configuration in clouds.yaml. OS_CLOUD is a
337               variable name that is significant to openstack client as a
338               environment variable. Please refer to the documentation for
339               further details.
340               https://docs.openstack.org/developer/python-openstackclient/
341
342
343 - parameter:
344     name: lf-infra-parameters
345     # Standard parameters used in the LF CI environments. Gerrit variables are
346     # not used by GitHub projects, but defining them isn't harmful.
347     parameters:
348       - string:
349           name: PROJECT
350           default: '{project}'
351           description: |
352               Parameter to identify a SCM project to build. This is typically
353               the project repo path. For example: ofextensions/circuitsw
354       - string:
355           name: STREAM
356           default: '{stream}'
357           description: |
358               Stream is often set to the same name as 'branch' but can
359               sometimes be used as a name representing a project's release code
360               name.
361       - string:
362           name: GERRIT_PROJECT
363           default: '{project}'
364           description: |
365               Gerrit Trigger provided parameter to identify Gerrit project that
366               triggered the build. This is typically the project repo path as
367               exists in Gerrit. For example: ofextensions/circuitsw
368
369               If using Gerrit, in a manual build this should match the PROJECT
370               parameter above.
371       - string:
372           name: GERRIT_BRANCH
373           default: '{branch}'
374           description: |
375               Gerrit Trigger provided parameter to identify a Gerrit branch.
376
377               If using Gerrit, in a manual build override with the branch to
378               build against.
379       - string:
380           name: GERRIT_REFSPEC
381           default: 'refs/heads/{branch}'
382           description: |
383               Gerrit Trigger provided parameter to identify a refspec to fetch
384               from Gerrit.
385
386               If using Gerrit, in a manual build override with a refspec.
387               https://git-scm.com/book/en/v2/Git-Internals-The-Refspec
388               For example: 'refs/heads/master'
389       - string:
390           name: sha1
391           default: 'origin/{branch}'
392           description: |
393               GitHub PR Trigger provided parameter for specifying the commit
394               to checkout.
395
396               If using GitHub, in a manual build override with a branch path or
397               sha1 hash to a specific commit. For example: 'origin/master'
398       # Tools
399       - string:
400           name: LFTOOLS_VERSION
401           default: '{lftools-version}'
402           description: |
403               Version of lftools to install. Can be a specific version like
404               '0.6.0' or a PEP-440 definition.
405               https://www.python.org/dev/peps/pep-0440/
406               For example '<1.0.0' or '>=1.0.0,<2.0.0'.
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-stack-delete
502     publishers:
503       - postbuildscript:
504           builders:
505             - role: BOTH
506               build-on:
507                 - ABORTED
508                 - FAILURE
509                 - SUCCESS
510                 - UNSTABLE
511               build-steps:
512                 - shell: |
513                     #!/bin/bash -l
514                     echo "Deleting $STACK_NAME"
515                     lftools openstack stack delete "$STACK_NAME"
516           mark-unstable-if-failed: false
517
518 #######
519 # SCM #
520 #######
521
522 - scm:
523     name: lf-infra-gerrit-scm
524     scm:
525       - git:
526           credentials-id: '{jenkins-ssh-credential}'
527           url: '{git-url}'
528           refspec: '{refspec}'
529           branches:
530             - 'refs/heads/{branch}'
531           skip-tag: true
532           wipe-workspace: true
533           submodule:
534             recursive: '{submodule-recursive}'
535           choosing-strategy: '{choosing-strategy}'
536
537 - scm:
538     name: lf-infra-github-scm
539     scm:
540       - git:
541           credentials-id: '{jenkins-ssh-credential}'
542           url: '{url}'
543           refspec: '{refspec}'
544           branches:
545             - '{branch}'
546           skip-tag: true
547           wipe-workspace: true
548           submodule:
549             recursive: '{submodule-recursive}'
550           choosing-strategy: '{choosing-strategy}'
551
552 ############
553 # WRAPPERS #
554 ############
555
556 - wrapper:
557     name: lf-infra-wrappers-common
558     wrappers:
559       - mask-passwords
560       - timeout:
561           type: absolute
562           timeout: '{build-timeout}'
563           timeout-var: 'BUILD_TIMEOUT'
564           fail: true
565       - timestamps
566       - openstack:
567           single-use: true
568
569 - wrapper:
570     name: lf-infra-wrappers
571     wrappers:
572       - lf-infra-wrappers-common:
573           build-timeout: '{build-timeout}'
574       - config-file-provider:
575           files:
576             - file-id: npmrc
577               target: '$HOME/.npmrc'
578             - file-id: pipconf
579               target: '$HOME/.config/pip/pip.conf'
580       - ssh-agent-credentials:
581           users:
582             - '{jenkins-ssh-credential}'
583
584 - wrapper:
585     name: lf-infra-wrappers-windows
586     wrappers:
587       - lf-infra-wrappers-common:
588           build-timeout: '{build-timeout}'