Release global-jjb v0.19.1
[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-infra-create-netrc
15     builders:
16       - inject:
17           properties-content: 'SERVER_ID={server-id}'
18       - shell: !include-raw-escape: ../shell/create-netrc.sh
19
20 - builder:
21     name: lf-infra-docker-login
22     builders:
23       - lf-provide-maven-settings:
24           global-settings-file: '{global-settings-file}'
25           settings-file: '{settings-file}'
26       - shell: !include-raw-escape: ../shell/docker-login.sh
27       - lf-provide-maven-settings-cleanup
28
29 - builder:
30     name: lf-infra-gpg-verify-git-signature
31     # TODO: Verify signature after downloading users public key from a locally
32     # created repository instead of the public keymesh. This requires a process
33     # in place to get ODL developers public keys into a local repository without
34     # increasing the job thoughput.
35     builders:
36       - shell: !include-raw: ../shell/gpg-verify-git-signature.sh
37
38 - builder:
39     name: lf-infra-ship-logs
40     builders:
41       - config-file-provider:
42           files:
43             - file-id: 'jenkins-log-archives-settings'
44               variable: 'SETTINGS_FILE'
45       - lf-infra-create-netrc:
46           server-id: logs
47       - shell: !include-raw:
48           - ../shell/lftools-install.sh
49           - ../shell/logs-deploy.sh
50       - shell: !include-raw:
51           - ../shell/logs-clear-credentials.sh
52       - description-setter:
53           regexp: '^Build logs: .*'
54
55 - builder:
56     name: lf-infra-packer-build
57     builders:
58       - config-file-provider:
59           files:
60             - file-id: '{packer-cloud-settings}'
61               variable: CLOUDENV
62       - inject:
63           properties-content: |
64               PACKER_PLATFORM={platform}
65               PACKER_TEMPLATE={template}
66               PACKER_VERSION={packer-version}
67       - shell: !include-raw-escape:
68           - ../shell/packer-install.sh
69           - ../shell/packer-build.sh
70       - shell: !include-raw:
71           - ../shell/packer-clear-credentials.sh
72
73 - builder:
74     name: lf-infra-packer-validate
75     builders:
76       - config-file-provider:
77           files:
78             - file-id: '{packer-cloud-settings}'
79               variable: 'CLOUDENV'
80       - inject:
81           properties-content: |
82               PACKER_VERSION={packer-version}
83       - shell: !include-raw-escape:
84           - ../shell/packer-install.sh
85           - ../shell/packer-validate.sh
86       - shell: !include-raw:
87           - ../shell/packer-clear-credentials.sh
88
89 - builder:
90     name: lf-infra-push-gerrit-patch
91     builders:
92       - inject:
93           properties-content: |
94               PROJECT='{project}'
95               GERRIT_COMMIT_MESSAGE='{gerrit-commit-message}'
96               GERRIT_HOST='{gerrit-host}'
97               GERRIT_TOPIC='{gerrit-topic}'
98               GERRIT_USER='{gerrit-user}'
99               REVIEWERS_EMAIL='{reviewers-email}'
100       - shell: !include-raw-escape: ../shell/gerrit-push-patch.sh
101
102 - builder:
103     name: lf-infra-sysstat
104     builders:
105       - shell: !include-raw:
106           - ../shell/sysstat.sh
107
108 - builder:
109     name: lf-jacoco-nojava-workaround
110     builders:
111       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
112
113 - builder:
114     name: lf-infra-deploy-maven-file
115     builders:
116       - lf-maven-install:
117           mvn-version: '{mvn-version}'
118       - lf-provide-maven-settings:
119           global-settings-file: '{global-settings-file}'
120           settings-file: '{settings-file}'
121       - inject:
122           properties-content: |
123               MAVEN_REPO_URL={maven-repo-url}
124               REPO_ID={repo-id}
125               GROUP_ID={group-id}
126               UPLOAD_FILES_PATH={upload-files-dir}
127       - shell: !include-raw-escape:
128           - ../shell/lftools-install.sh
129           - ../shell/common-variables.sh
130           - ../shell/deploy-maven-file.sh
131       - lf-provide-maven-settings-cleanup
132
133 - builder:
134     name: lf-maven-install
135     builders:
136       # Create a $HOME/.wgetrc to make the Maven download quiet.
137       - shell: 'echo "quiet=on" > "$HOME/.wgetrc"'
138       - maven-target:
139           maven-version: '{mvn-version}'
140           goals: '--version'
141       - shell: 'rm "$HOME/.wgetrc"'
142
143 - builder:
144     name: lf-provide-maven-settings
145     builders:
146       - config-file-provider:
147           files:
148             - file-id: '{global-settings-file}'
149               variable: 'GLOBAL_SETTINGS_FILE'
150             - file-id: '{settings-file}'
151               variable: 'SETTINGS_FILE'
152
153 - builder:
154     name: lf-provide-sigul-configuration
155     # Push configuration files to interact with sigul
156     builders:
157       - config-file-provider:
158           files:
159             - file-id: sigul-config
160               variable: SIGUL_CONFIG
161             - file-id: sigul-password
162               variable: SIGUL_PASSWORD
163             - file-id: sigul-pki
164               variable: SIGUL_PKI
165       - shell: !include-raw-escape: ../shell/sigul-configuration.sh
166
167 - builder:
168     name: lf-pip-install
169     builders:
170       - inject:
171           properties-content: PIP_PACKAGES={pip-packages}
172       - shell: !include-raw-escape: ../shell/pip-install.sh
173
174 - builder:
175     name: lf-provide-maven-settings-cleanup
176     builders:
177       - shell: |
178           #!/bin/bash
179           set +e  # DO NOT cause build failure if any of the rm calls fail.
180
181           rm -f "$GLOBAL_SETTINGS_FILE" "$SETTINGS_FILE"
182
183           # In some cases we use the lf-provide-maven-settings macro to produce
184           # a "$HOME/.netrc" file containing credentials. Remove that file here
185           # too if it exists.
186           rm -f "$HOME/.netrc"
187
188           # DO NOT fail build if any of the above lines fail.
189           exit 0
190
191 - builder:
192     name: lf-provide-sigul-configuration-cleanup
193     # Clear sigul configuration files after we're done using them
194     builders:
195       - shell: !include-raw-escape: ../shell/sigul-configuration-cleanup.sh
196
197 - builder:
198     name: lf-rtd-trigger-build
199     builders:
200       - inject:
201           properties-content: |
202             RTD_BUILD_URL={rtd-build-url}
203             RTD_TOKEN={rtd-token}
204       - shell: !include-raw-escape: ../shell/rtd-trigger-build.sh
205
206 - builder:
207     name: lf-rtd-verify
208     builders:
209       - inject:
210           properties-content: DOC_DIR={doc-dir}
211       - shell: !include-raw-escape:
212           - ../shell/tox-install.sh
213           - ../shell/rtd-verify.sh
214
215 - builder:
216     name: lf-sigul-install
217     # Requires that Jenkins be configured with SIGUL_BRIDGE_IP as a global
218     # Environment variable
219     builder:
220       - shell: !include-raw-escape: ../shell/sigul-install.sh
221
222 ##############
223 # PARAMETERS #
224 ##############
225
226 - parameter:
227     name: lf-infra-maven-parameters
228     parameters:
229       - string:
230           name: M2_HOME
231           # Sets an env var for shell scripts to be able to call the dynamically
232           # installed maven without having to calculate the M2_HOME themselves.
233           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}'
234           description: 'Maven selector to be used by shell scripts'
235       - string:
236           name: MAVEN_OPTS
237           default: '{mvn-opts}'
238           description: |
239               Maven Java opts. Example: -Xmx1024m -XX:MaxPermSize=256m
240       - string:
241           name: MAVEN_PARAMS
242           default: '{mvn-params}'
243           description: |
244               Maven parameters to pass to the mvn command.
245       - string:
246           name: MVN
247           # Sets an env var for shell scripts to be able to call the dynamically
248           # installed maven without having to calculate the path themselves.
249           # yamllint disable-line rule:line-length
250           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn'
251           description: 'Maven selector to be used by shell scripts'
252       - string:
253           name: STAGING_PROFILE_ID
254           default: '{staging-profile-id}'
255           description: |
256               Nexus staging profile ID.
257
258
259 - parameter:
260     name: lf-infra-openstack-parameters
261     parameters:
262       - string:
263           name: OS_CLOUD
264           default: '{os-cloud}'
265           description: |
266               The name of a cloud configuration in clouds.yaml. OS_CLOUD is a
267               variable name that is significant to openstack client as a
268               environment variable. Please refer to the documentation for
269               further details.
270               https://docs.openstack.org/developer/python-openstackclient/
271
272
273 - parameter:
274     name: lf-infra-parameters
275     # Standard parameters used in the LF CI environments. Gerrit variables are
276     # not used by GitHub projects, but defining them isn't harmful.
277     parameters:
278       - string:
279           name: PROJECT
280           default: '{project}'
281           description: |
282               Parameter to identify a Gerrit project. This is typically the
283               project repo path as exists in Gerrit.
284               For example: ofextensions/circuitsw
285       - string:
286           name: STREAM
287           default: '{stream}'
288           description: |
289               Stream is often set to the same name as 'branch' but can
290               sometimes be used as a name representing a project's release code
291               name.
292       - string:
293           name: GERRIT_PROJECT
294           default: '{project}'
295           description: |
296               Parameter to identify Gerrit project. This is typically the
297               project repo path as exists in Gerrit.
298               For example: ofextensions/circuitsw
299
300               Note that Gerrit will override this parameter automatically if a
301               job is triggered by Gerrit.
302       - string:
303           name: GERRIT_BRANCH
304           default: '{branch}'
305           description: |
306               Parameter to identify a Gerrit branch.
307
308               Note that Gerrit will override this parameter automatically if a
309               job is triggered by Gerrit.
310       - string:
311           name: GERRIT_REFSPEC
312           default: 'refs/heads/{branch}'
313           description: |
314               Parameter to identify a refspec when pulling from Gerrit.
315
316               Note that Gerrit will override this parameter automatically if a
317               job is triggered by Gerrit.
318       - string:
319           name: LFTOOLS_VERSION
320           default: '{lftools-version}'
321           description: |
322               Version of lftools to install. Can be a specific version like
323               '0.6.0' or a PEP-440 definition.
324               https://www.python.org/dev/peps/pep-0440/
325               For example '<1.0.0' or '>=1.0.0,<2.0.0'.
326
327 - parameter:
328     name: lf-infra-node-parameters
329     parameters:
330       - string:
331           name: NODE_DIR
332           default: '{node-dir}'
333           description: Path to a Node project directory.
334       - string:
335           name: NODE_VERSION
336           default: '{node-version}'
337           description: Version of NodeJS to install.
338
339 - parameter:
340     name: lf-infra-tox-parameters
341     parameters:
342       - string:
343           name: TOX_DIR
344           default: '{tox-dir}'
345           description: |
346               Path to directory containing tox.ini file.
347       - string:
348           name: TOX_ENVS
349           default: '{tox-envs}'
350           description: |
351               Tox environments to run build against.
352               Example: docs,py2,py3
353
354 ##############
355 # PROPERTIES #
356 ##############
357
358 - property:
359     name: lf-infra-properties
360     properties:
361       - build-discarder:
362           # Allow build data to be stored at a length configured by the
363           # downstream project.
364           days-to-keep: '{build-days-to-keep}'
365           # Do not allow artifacts to be stored in Jenkins.
366           artifact-num-to-keep: 0
367
368 ##############
369 # PUBLISHERS #
370 ##############
371
372 - publisher:
373     name: lf-jacoco-report
374     publishers:
375       - jacoco:
376           exec-pattern: "**/**.exec"
377           class-pattern: "**/classes"
378           source-pattern: "**/src/main/java"
379           # yamllint disable-line rule:line-length
380           exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
381           status-update: true
382           targets:
383             - branch:
384                 healthy: 10
385                 unhealthy: 20
386             - method:
387                 healthy: 50
388                 unhealthy: 40
389
390 - publisher:
391     name: lf-infra-publish
392     # lf-infra macro to finish up a build.
393     #
394     # Handles the following:
395     #   - Shipping logs to Nexus logs site repository
396     #   - Cleanup workspace
397     publishers:
398       - postbuildscript:
399           builders:
400             - role: BOTH
401               build-on:
402                 - ABORTED
403                 - FAILURE
404                 - NOT_BUILT
405                 - SUCCESS
406                 - UNSTABLE
407               build-steps:
408                 - lf-infra-sysstat
409                 - lf-infra-ship-logs
410           mark-unstable-if-failed: true
411       - workspace-cleanup:
412           exclude:
413             # Do not clean up *.jenkins-trigger files for jobs that use a
414             # properties file as input for triggering another build.
415             - '**/*.jenkins-trigger'
416           fail-build: false
417
418 #######
419 # SCM #
420 #######
421
422 - scm:
423     name: lf-infra-gerrit-scm
424     scm:
425       - git:
426           credentials-id: '{jenkins-ssh-credential}'
427           url: '{git-url}'
428           refspec: '{refspec}'
429           branches:
430             - 'refs/heads/{branch}'
431           skip-tag: true
432           wipe-workspace: true
433           submodule:
434             recursive: '{submodule-recursive}'
435           choosing-strategy: '{choosing-strategy}'
436
437 - scm:
438     name: lf-infra-github-scm
439     scm:
440       - git:
441           credentials-id: '{jenkins-ssh-credential}'
442           url: '{url}'
443           refspec: '{refspec}'
444           branches:
445             - '{branch}'
446           skip-tag: true
447           wipe-workspace: true
448           submodule:
449             recursive: '{submodule-recursive}'
450           choosing-strategy: '{choosing-strategy}'
451
452 ############
453 # TRIGGERS #
454 ############
455
456 - trigger:
457     name: lf-infra-github-pr-trigger
458     triggers:
459       - github-pull-request:
460           trigger-phrase: '{trigger-phrase}'
461           only-trigger-phrase: '{only-trigger-phrase}'
462           status-context: '{status-context}'
463           permit-all: '{permit-all}'
464           github-hooks: '{github-hooks}'
465           auto-close-on-fail: false
466           org-list:
467             - '{github-org}'
468           white-list: '{obj:github_pr_whitelist}'
469           admin-list: '{obj:github_pr_admin_list}'
470
471 ############
472 # WRAPPERS #
473 ############
474
475 - wrapper:
476     name: lf-infra-wrappers
477     wrappers:
478       - mask-passwords
479       - timeout:
480           type: absolute
481           timeout: '{build-timeout}'
482           timeout-var: 'BUILD_TIMEOUT'
483           fail: true
484       - timestamps
485       - ssh-agent-credentials:
486           users:
487             - '{jenkins-ssh-credential}'
488       - openstack:
489           single-use: true
490       - config-file-provider:
491           files:
492             - file-id: npmrc
493               target: '$HOME/.npmrc'
494             - file-id: pipconf
495               target: '$HOME/.config/pip/pip.conf'