Merge "Enable sar report collection for global-jjb"
[releng/global-jjb.git] / jjb / lf-macros.yaml
1 ---
2 # BUILDERS
3 - builder:
4     name: lf-infra-create-netrc
5     # Macro to create a ~/.netrc file from a Maven settings.xml
6     # Parameters:
7     #     {server-id} The id of a server as defined in settings.xml
8     builders:
9       - inject:
10           properties-content: 'SERVER_ID={server-id}'
11       - shell: !include-raw-escape: ../shell/create-netrc.sh
12
13 - builder:
14     name: lf-infra-gpg-verify-git-signature
15     # Verify gpg signature of the latest commit message in $WORKSPACE
16     #
17     # This command assumes that $WORKSPACE is a git repo.
18     #
19     # TODO: Verify signature after downloading users public key from a locally
20     # created repository instead of the public keymesh. This requires a process
21     # in place to get ODL developers public keys into a local repository without
22     # increasing the job thoughput.
23     builders:
24       - shell: !include-raw: ../shell/gpg-verify-git-signature.sh
25
26 - builder:
27     name: lf-infra-ship-logs
28     builders:
29       - config-file-provider:
30           files:
31             - file-id: 'jenkins-log-archives-settings'
32               variable: 'SETTINGS_FILE'
33       - lf-infra-create-netrc:
34           server-id: logs
35       - shell: !include-raw:
36           - ../shell/lftools-install.sh
37           - ../shell/logs-deploy.sh
38       - shell: !include-raw:
39           - ../shell/logs-clear-credentials.sh
40       - description-setter:
41           regexp: '^Build logs: .*'
42
43 - builder:
44     name: lf-infra-sysstat
45     builders:
46       - shell: !include-raw:
47           - ../shell/sysstat.sh
48
49 - builder:
50     name: lf-jacoco-nojava-workaround
51     builders:
52       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
53
54 # call maven-target builder with a goal of --version to force Jenkins to
55 # install the needed maven version
56 - builder:
57     name: lf-maven-install
58     builders:
59       - maven-target:
60           maven-version: '{maven-version}'
61           goals: '--version'
62
63 # Push a global settings and user settings maven files
64 - builder:
65     name: lf-provide-maven-settings
66     builders:
67       - config-file-provider:
68           files:
69             - file-id: '{global-settings-file}'
70               variable: 'GLOBAL_SETTINGS_FILE'
71             - file-id: '{settings-file}'
72               variable: 'SETTINGS_FILE'
73
74
75 # PARAMETERS
76 # Standard parameters used in the LF CI environments. Gerrit variables are not
77 # used by GitHub projects, but defining them isn't harmful
78 - parameter:
79     name: lf-infra-parameters
80     parameters:
81       - string:
82           name: PROJECT
83           default: '{project}'
84           description: |
85               Parameter to identify a Gerrit project. This is typically the
86               project repo path as exists in Gerrit.
87               For example: ofextensions/circuitsw
88
89               (Deprecated) Please use GERRIT_PROJECT instead. A future version
90               of global-jjb will remove this variable.
91       - string:
92           name: GERRIT_PROJECT
93           default: '{project}'
94           description: |
95               Parameter to identify Gerrit project. This is typically the
96               project repo path as exists in Gerrit.
97               For example: ofextensions/circuitsw
98
99               Note that Gerrit will override this parameter automatically if a
100               job is triggered by Gerrit.
101       - string:
102           name: GERRIT_BRANCH
103           default: '{branch}'
104           description: |
105               Parameter to identify a Gerrit branch.
106
107               Note that Gerrit will override this parameter automatically if a
108               job is triggered by Gerrit.
109       - string:
110           name: GERRIT_REFSPEC
111           default: ''
112           description: |
113               Parameter to identify a refspec when pulling from Gerrit.
114
115               Note that Gerrit will override this parameter automatically if a
116               job is triggered by Gerrit.
117
118 # Useful parameters when working with TOX
119 # https://tox.readthedocs.io/
120 - parameter:
121     name: lf-infra-tox-parameters
122     parameters:
123       - string:
124           name: TOX_DIR
125           default: '{tox-dir}'
126           description: |
127               Path to directory containing tox.ini file.
128       - string:
129           name: TOX_ENVS
130           default: '{tox-envs}'
131           description: |
132               Tox environments to run build against.
133               Example: docs,py2,py3
134
135 # Set an env var for shell scripts to be able to call the dynamically installed
136 # maven without having to calculate the path themselves
137 - parameter:
138     name: lf-maven-exec
139     parameters:
140       - string:
141           name: MVN
142           # yamllint disable-line rule:line-length
143           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
144           description: 'Maven selector to be used by shell scripts'
145
146
147 # PROPERTIES
148 - property:
149     name: lf-infra-properties
150     properties:
151       - build-discarder:
152           # Allow build data to be stored at a length configured by the
153           # downstream project.
154           days-to-keep: '{build-days-to-keep}'
155           # Do not allow artifacts to be stored in Jenkins.
156           artifact-num-to-keep: 0
157
158 # PUBLISHERS
159 - publisher:
160     name: lf-infra-publish
161     # lf-infra macro to finish up a build.
162     #
163     # Handles the following:
164     #   - Shipping logs to Nexus logs site repository
165     #   - Cleanup workspace
166     publishers:
167       - postbuildscript:
168           builders:
169             - lf-infra-sysstat
170             - lf-infra-ship-logs
171           script-only-if-succeeded: false
172           script-only-if-failed: false
173           mark-unstable-if-failed: false
174       - workspace-cleanup:
175           exclude:
176             # Do not clean up *.jenkins-trigger files for jobs that use a
177             # properties file as input for triggering another build.
178             - '**/*.jenkins-trigger'
179           fail-build: false
180
181 # SCM
182 - scm:
183     name: lf-infra-gerrit-scm
184     scm:
185       - git:
186           credentials-id: '{jenkins-ssh-credential}'
187           url: '{git-url}'
188           refspec: '{refspec}'
189           branches:
190             - 'refs/heads/{branch}'
191           skip-tag: true
192           wipe-workspace: true
193           submodule:
194             recursive: '{submodule-recursive}'
195           choosing-strategy: '{choosing-strategy}'
196
197 - scm:
198     name: lf-infra-github-scm
199     scm:
200       - git:
201           credentials-id: '{jenkins-ssh-credential}'
202           url: '{url}'
203           refspec: '{refspec}'
204           skip-tag: true
205           wipe-workspace: true
206           submodule:
207             recursive: '{submodule-recursive}'
208           choosing-strategy: '{choosing-strategy}'
209
210 # WRAPPERS
211 - wrapper:
212     name: lf-infra-wrappers
213     wrappers:
214       - mask-passwords
215       - timeout:
216           type: absolute
217           timeout: '{build-timeout}'
218           timeout-var: 'BUILD_TIMEOUT'
219           fail: true
220       - timestamps
221       - ssh-agent-credentials:
222           users:
223             - '{jenkins-ssh-credential}'
224       - openstack:
225           single-use: true