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