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