Migrate Global JJB docs to RST
[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-pip-install
142     builders:
143       - inject:
144           properties-content: PIP_PACKAGES={pip-packages}
145       - shell: !include-raw-escape: ../shell/pip-install.sh
146
147 - builder:
148     name: lf-provide-maven-settings-cleanup
149     builders:
150       - shell: |
151           #!/bin/bash
152           set +e  # DO NOT cause build failure if any of the rm calls fail.
153
154           rm "$GLOBAL_SETTINGS_FILE" "$SETTINGS_FILE"
155
156           # In some cases we use the lf-provide-maven-settings macro to produce
157           # a "$HOME/.netrc" file containing credentials. Remove that file here
158           # too if it exists.
159           rm "$HOME/.netrc"
160
161           # DO NOT fail build if any of the above lines fail.
162           exit 0
163
164 - builder:
165     name: lf-rtd-trigger-build
166     builders:
167       - inject:
168           properties-content: RTD_PROJECT={rtd-project}
169       - shell: !include-raw-escape: ../shell/rtd-trigger-build.sh
170
171 - builder:
172     name: lf-rtd-verify
173     builders:
174       - inject:
175           properties-content: DOC_DIR={doc-dir}
176       - shell: !include-raw-escape:
177           - ../shell/tox-install.sh
178           - ../shell/rtd-verify.sh
179
180 ##############
181 # PARAMETERS #
182 ##############
183
184 - parameter:
185     name: lf-infra-maven-parameters
186     parameters:
187       - string:
188           name: MAVEN_OPTS
189           default: '{mvn-opts}'
190           description: |
191               Maven Java opts. Example: -Xmx1024m -XX:MaxPermSize=256m
192       - string:
193           name: MAVEN_PARAMS
194           default: '{mvn-params}'
195           description: |
196               Maven parameters to pass to the mvn command.
197       - string:
198           name: MVN
199           # Sets an env var for shell scripts to be able to call the dynamically
200           # installed maven without having to calculate the path themselves.
201           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn'
202           description: 'Maven selector to be used by shell scripts'
203       - string:
204           name: STAGING_PROFILE_ID
205           default: '{staging-profile-id}'
206           description: |
207               Nexus staging profile ID.
208
209
210 - parameter:
211     name: lf-infra-openstack-parameters
212     parameters:
213       - string:
214           name: OS_CLOUD
215           default: '{os-cloud}'
216           description: |
217               The name of a cloud configuration in clouds.yaml. OS_CLOUD is a
218               variable name that is significant to openstack client as a
219               environment variable. Please refer to the documentation for
220               further details.
221               https://docs.openstack.org/developer/python-openstackclient/
222
223
224 - parameter:
225     name: lf-infra-parameters
226     # Standard parameters used in the LF CI environments. Gerrit variables are
227     # not used by GitHub projects, but defining them isn't harmful.
228     parameters:
229       - string:
230           name: PROJECT
231           default: '{project}'
232           description: |
233               Parameter to identify a Gerrit project. This is typically the
234               project repo path as exists in Gerrit.
235               For example: ofextensions/circuitsw
236       - string:
237           name: STREAM
238           default: '{stream}'
239           description: |
240               Stream is often set to the same name as 'branch' but can
241               sometimes be used as a name representing a project's release code
242               name.
243       - string:
244           name: GERRIT_PROJECT
245           default: '{project}'
246           description: |
247               Parameter to identify Gerrit project. This is typically the
248               project repo path as exists in Gerrit.
249               For example: ofextensions/circuitsw
250
251               Note that Gerrit will override this parameter automatically if a
252               job is triggered by Gerrit.
253       - string:
254           name: GERRIT_BRANCH
255           default: '{branch}'
256           description: |
257               Parameter to identify a Gerrit branch.
258
259               Note that Gerrit will override this parameter automatically if a
260               job is triggered by Gerrit.
261       - string:
262           name: GERRIT_REFSPEC
263           default: 'refs/heads/{branch}'
264           description: |
265               Parameter to identify a refspec when pulling from Gerrit.
266
267               Note that Gerrit will override this parameter automatically if a
268               job is triggered by Gerrit.
269       - string:
270           name: LFTOOLS_VERSION
271           default: '{lftools-version}'
272           description: |
273               Version of lftools to install. Can be a specific version like
274               '0.6.0' or a PEP-440 definition.
275               https://www.python.org/dev/peps/pep-0440/
276               For example '<1.0.0' or '>=1.0.0,<2.0.0'.
277
278 - parameter:
279     name: lf-infra-node-parameters
280     parameters:
281       - string:
282           name: NODE_DIR
283           default: '{node-dir}'
284           description: Path to a Node project directory.
285       - string:
286           name: NODE_VERSION
287           default: '{node-version}'
288           description: Version of NodeJS to install.
289
290 - parameter:
291     name: lf-infra-tox-parameters
292     parameters:
293       - string:
294           name: TOX_DIR
295           default: '{tox-dir}'
296           description: |
297               Path to directory containing tox.ini file.
298       - string:
299           name: TOX_ENVS
300           default: '{tox-envs}'
301           description: |
302               Tox environments to run build against.
303               Example: docs,py2,py3
304
305 ##############
306 # PROPERTIES #
307 ##############
308
309 - property:
310     name: lf-infra-properties
311     properties:
312       - build-discarder:
313           # Allow build data to be stored at a length configured by the
314           # downstream project.
315           days-to-keep: '{build-days-to-keep}'
316           # Do not allow artifacts to be stored in Jenkins.
317           artifact-num-to-keep: 0
318
319 ##############
320 # PUBLISHERS #
321 ##############
322
323 - publisher:
324     name: lf-jacoco-report
325     publishers:
326       - jacoco:
327           exec-pattern: "**/**.exec"
328           class-pattern: "**/classes"
329           source-pattern: "**/src/main/java"
330           exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
331           status-update: true
332           targets:
333             - branch:
334                 healthy: 10
335                 unhealthy: 20
336             - method:
337                 healthy: 50
338                 unhealthy: 40
339
340 - publisher:
341     name: lf-infra-publish
342     # lf-infra macro to finish up a build.
343     #
344     # Handles the following:
345     #   - Shipping logs to Nexus logs site repository
346     #   - Cleanup workspace
347     publishers:
348       - postbuildscript:
349           builders:
350             - lf-infra-sysstat
351             - lf-infra-ship-logs
352           script-only-if-succeeded: false
353           script-only-if-failed: false
354           mark-unstable-if-failed: false
355       - workspace-cleanup:
356           exclude:
357             # Do not clean up *.jenkins-trigger files for jobs that use a
358             # properties file as input for triggering another build.
359             - '**/*.jenkins-trigger'
360           fail-build: false
361
362 #######
363 # SCM #
364 #######
365
366 - scm:
367     name: lf-infra-gerrit-scm
368     scm:
369       - git:
370           credentials-id: '{jenkins-ssh-credential}'
371           url: '{git-url}'
372           refspec: '{refspec}'
373           branches:
374             - 'refs/heads/{branch}'
375           skip-tag: true
376           wipe-workspace: true
377           submodule:
378             recursive: '{submodule-recursive}'
379           choosing-strategy: '{choosing-strategy}'
380
381 - scm:
382     name: lf-infra-github-scm
383     scm:
384       - git:
385           credentials-id: '{jenkins-ssh-credential}'
386           url: '{url}'
387           refspec: '{refspec}'
388           skip-tag: true
389           wipe-workspace: true
390           submodule:
391             recursive: '{submodule-recursive}'
392           choosing-strategy: '{choosing-strategy}'
393
394 ############
395 # TRIGGERS #
396 ############
397
398 - trigger:
399     name: lf-infra-github-pr-trigger
400     triggers:
401       - github-pull-request:
402           trigger-phrase: '{trigger-phrase}'
403           only-trigger-phrase: '{only-trigger-phrase}'
404           status-context: '{status-context}'
405           permit-all: '{permit-all}'
406           github-hooks: '{github-hooks}'
407           auto-close-on-fail: false
408           org-list:
409             - '{github-org}'
410           white-list: '{obj:github_pr_whitelist}'
411           admin-list: '{obj:github_pr_admin_list}'
412
413 ############
414 # WRAPPERS #
415 ############
416
417 - wrapper:
418     name: lf-infra-wrappers
419     wrappers:
420       - mask-passwords
421       - timeout:
422           type: absolute
423           timeout: '{build-timeout}'
424           timeout-var: 'BUILD_TIMEOUT'
425           fail: true
426       - timestamps
427       - ssh-agent-credentials:
428           users:
429             - '{jenkins-ssh-credential}'
430       - openstack:
431           single-use: true