Merge "Docker spin-up script allows jenkins user to run sudo without password"
[releng/builder.git] / jjb / releng-macros.yaml
1 # OLD Releng macros
2
3 - parameter:
4     name: opendaylight-infra-parameters
5     parameters:
6         - string:
7             name: PROJECT
8             default: '{project}'
9             description: 'Parameter to identify an ODL Gerrit project'
10         - string:
11             name: ARCHIVE_ARTIFACTS
12             default: '{artifacts} **/target/surefire-reports/*-output.txt'
13             description: 'Artifacts to archive into logs.opendaylight.org'
14         - string:
15             name: GERRIT_PROJECT
16             default: '{project}'
17             description: "GERRIT_PROJECT parameter if not given by trigger"
18         - string:
19             name: GERRIT_BRANCH
20             default: '{branch}'
21             description: "JJB configured GERRIT_BRANCH parameter"
22         - string:
23             name: GERRIT_REFSPEC
24             default: '{refspec}'
25             description: "GERRIT_REFSPEC parameter if not given by trigger"
26
27 - parameter:
28     name: build-tag
29     parameters:
30         - string:
31             name: BUILD_TAG
32             default: ''
33             description: 'Tag in Git to checkout'
34
35 - parameter:
36     name: controller-version-parameter
37     parameters:
38         - string:
39             name: ODL_VERSION
40             default: '{odl_version}'
41             description: 'Controller version (for use with openstacks networking_odl project)'
42
43 - parameter:
44     name: patches-to-build-parameter
45     parameters:
46         - string:
47             name: PATCHES_TO_BUILD
48             default: ''
49             description: 'csv list of patches in project:changeset format to build distribution with'
50
51 - parameter:
52     name: distribution-branch-to-build-parameter
53     parameters:
54         - string:
55             name: DISTRIBUTION_BRANCH_TO_BUILD
56             default: 'master'
57             description: 'distribution repo branch to build with'
58
59 - parameter:
60     name: p2zip-parameter
61     parameters:
62         - string:
63             name: P2ZIP_URL
64             default: ''
65             description: 'Nexus staging profile id'
66
67 - parameter:
68     name: stage-id-parameter
69     parameters:
70         - string:
71             name: STAGING_PROFILE_ID
72             default: '{stage-id}'
73             description: 'Nexus staging profile id'
74
75 - scm:
76     name: git-scm
77     scm:
78         - git:
79             credentials-id: 'opendaylight-jenkins-ssh'
80             url: '$GIT_BASE'
81             refspec: ''
82             branches:
83                 - 'origin/{branch}'
84             skip-tag: true
85             wipe-workspace: true
86
87 - scm:
88     name: git-scm-with-submodules
89     scm:
90         - git:
91             credentials-id: 'opendaylight-jenkins-ssh'
92             url: '$GIT_BASE'
93             refspec: ''
94             branches:
95                 - 'refs/heads/{branch}'
96             skip-tag: true
97             wipe-workspace: true
98             submodule:
99                 recursive: true
100
101 - scm:
102     name: gerrit-trigger-scm
103     scm:
104         - git:
105             credentials-id: 'opendaylight-jenkins-ssh'
106             url: '$GIT_BASE'
107             refspec: '{refspec}'
108             branches:
109                 - 'origin/$GERRIT_BRANCH'
110             skip-tag: true
111             choosing-strategy: '{choosing-strategy}'
112
113 - wrapper:
114     name: build-timeout
115     wrappers:
116         - timeout:
117             type: absolute
118             timeout: 360
119             fail: true
120
121 - trigger:
122     name: gerrit-trigger-patch-submitted
123     triggers:
124         - gerrit:
125             server-name: 'OpenDaylight'
126             trigger-on:
127                 - patchset-created-event:
128                     exclude-drafts: 'false'
129                     exclude-trivial-rebase: 'false'
130                     exclude-no-code-change: 'false'
131                 - draft-published-event
132                 - comment-added-contains-event:
133                     comment-contains-value: 'recheck'
134                 - comment-added-contains-event:
135                     comment-contains-value: 'reverify'
136             projects:
137               - project-compare-type: 'ANT'
138                 project-pattern: '{name}'
139                 branches:
140                   - branch-compare-type: 'ANT'
141                     branch-pattern: '**/{branch}'
142
143 - trigger:
144     name: gerrit-trigger-relevant-patch-submitted
145     triggers:
146         - gerrit:
147             server-name: 'OpenDaylight'
148             trigger-on:
149                 - patchset-created-event:
150                     exclude-drafts: 'true'
151                     exclude-trivial-rebase: 'false'
152                     exclude-no-code-change: 'true'
153                 - draft-published-event
154                 - comment-added-contains-event:
155                     comment-contains-value: 'recheck'
156                 - comment-added-contains-event:
157                     comment-contains-value: 'reverify'
158             projects:
159               - project-compare-type: 'ANT'
160                 project-pattern: '{name}'
161                 branches:
162                   - branch-compare-type: 'ANT'
163                     branch-pattern: '**/{branch}'
164
165 - trigger:
166     name: gerrit-trigger-patch-merged
167     triggers:
168         - gerrit:
169             server-name: 'OpenDaylight'
170             trigger-on:
171                 - change-merged-event
172                 - comment-added-contains-event:
173                     comment-contains-value: 'remerge'
174             projects:
175               - project-compare-type: 'ANT'
176                 project-pattern: '{name}'
177                 branches:
178                   - branch-compare-type: 'ANT'
179                     branch-pattern: '**/{branch}'
180
181 - trigger:
182     name: gerrit-trigger-patch-sonar
183     triggers:
184         - gerrit:
185             server-name: 'OpenDaylight'
186             trigger-on:
187                 - comment-added-contains-event:
188                     comment-contains-value: 'run-sonar'
189             projects:
190               - project-compare-type: 'ANT'
191                 project-pattern: '{name}'
192                 branches:
193                   - branch-compare-type: 'ANT'
194                     branch-pattern: '**/master'
195             skip-vote:
196                 successful: true
197                 failed: true
198                 unstable: true
199                 notbuilt: true
200
201 - trigger:
202     name: gerrit-trigger-patch-site-merged
203     triggers:
204         - gerrit:
205             server-name: 'OpenDaylight'
206             trigger-on:
207                 - change-merged-event
208                 - comment-added-contains-event:
209                     comment-contains-value: 'republish'
210             projects:
211               - project-compare-type: 'ANT'
212                 project-pattern: '{name}'
213                 branches:
214                     - branch-compare-type: 'ANT'
215                       branch-pattern: '**/{branch}'
216
217 - publisher:
218     name: archive-artifacts
219     publishers:
220         - archive:
221             artifacts: '{artifacts}'
222             allow-empty: true
223             fingerprint: true
224             latest-only: true
225
226 - publisher:
227     name: email-notification
228     publishers:
229         - email-ext:
230             recipients: 'jenkins@lists.opendaylight.org'
231             reply-to:
232             content-type: default
233             subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
234             body: |
235                 $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
236
237                 Check console output at $BUILD_URL to view the results.
238             unstable: true
239             fixed: true
240             send-to:
241                 - recipients
242
243 - publisher:
244         name: jacoco-report
245         publishers:
246             - jacoco:
247                 exec-pattern: "**/**.exec"
248                 class-pattern: "**/classes"
249                 source-pattern: "**/src/main/java"
250                 exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
251                 status-update: true
252                 targets:
253                   - branch:
254                       healthy: 10
255                       unhealthy: 20
256                   - method:
257                       healthy: 50
258                       unhealthy: 40
259
260 - publisher:
261     name: archive-build
262     # To archive things the job will need to create a "archives" directory in
263     # the workspace and this macro will handle copying the contents of the
264     # archives directory.
265     #
266     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files
267     # to archive. You can pass globstar patterns for example "**/*.xml **/*.log"
268     # as the archive pattern. This is a space separated list of files to archive.
269     #
270     # Also ensure that the workspace is cleaned up at the end of the build.
271     publishers:
272         - postbuildscript:
273             builders:
274                 - shell: !include-raw: include-raw-deploy-archives.sh
275                 - maven-target:
276                         maven-version: '{maven-version}'
277                         pom: '.archives/deploy-archives.xml'
278                         goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
279                         settings: 'jenkins-log-archives-settings'
280                         settings-type: cfp
281                         global-settings: 'odl-global-settings'
282                         global-settings-type: cfp
283                 - description-setter:
284                     regexp: '^Build logs: .*'
285                 # Cleanup after ourselves
286                 - wipe-org-opendaylight-repo
287             script-only-if-succeeded: False
288             script-only-if-failed: False
289             mark-unstable-if-failed: True
290         - workspace-cleanup:
291             fail-build: false
292
293 - builder:
294     name: wipe-org-opendaylight-repo
295     builders:
296         - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
297
298 - builder:
299     name: wipe-local-maven-repo
300     builders:
301         - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
302
303 - builder:
304     name: jacoco-nojava-workaround
305     builders:
306         - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
307
308 - builder:
309     name: check-clm
310     builders:
311         - sonatype-clm:
312             application-name: '{application-name}'
313
314 - builder:
315     name: releng-check-unicode
316     builders:
317         - shell: |
318             $WORKSPACE/scripts/check-unicode.sh jjb/
319
320 - builder:
321     name: provide-maven-settings
322     builders:
323     - config-file-provider:
324         files:
325         - file-id: '{global-settings-file}'
326           variable: 'GLOBAL_SETTINGS_FILE'
327         - file-id: '{settings-file}'
328           variable: 'SETTINGS_FILE'
329
330 - builder:
331     name: releng-fetch-p2zip-if-necessary
332     builders:
333     - shell: |
334         # Cleanup any existing zips and metadata before we download the new update site
335         rm -f *.zip *.xml
336     - conditional-step:
337         condition-kind: strings-match
338         condition-string1: '$P2ZIP_URL'
339         condition-string2: ''
340         condition-basedir: workspace
341         steps:
342             # TODO: Figure out latest snapshot version number to pull rather than hardcoding 1.1.1-SNAPSHOT
343             - maven-target:
344                 maven-version: '{maven-version}'
345                 goals: 'org.apache.maven.plugins:maven-dependency-plugin:get org.apache.maven.plugins:maven-dependency-plugin:copy -V -B -Dartifact=org.opendaylight.yangide:org.opendaylight.yangide.update-site:1.1.1-SNAPSHOT:zip -DoutputDirectory=$WORKSPACE'
346                 settings: '{settings}'
347                 global-settings: '{global-settings}'
348
349 - builder:
350     name: releng-generate-p2pom
351     builders:
352         - shell: !include-raw: include-raw-generate-p2pom.sh
353
354 - builder:
355     name: releng-update-p2composite-metadata
356     builders:
357     - shell: !include-raw: include-raw-update-p2composite-metadata.sh
358     - conditional-step:
359         condition-kind: file-exists
360         condition-filename: deploy-composite-repo.xml
361         condition-basedir: workspace
362         steps:
363             - maven-target:
364                 maven-version: '{maven-version}'
365                 pom: 'deploy-composite-repo.xml'
366                 goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
367                 settings: '{settings}'
368                 global-settings: '{global-settings}'
369
370 - builder:
371     name: releng-stage-release
372     builders:
373         - shell: !include-raw: include-raw-stage-release.sh
374
375 - wrapper:
376     # This wrapper is required for all jobs as it configures the wrappers
377     # needed by OpenDaylight infra.
378     name: opendaylight-infra-wrappers
379     wrappers:
380         - timeout:
381             type: absolute
382             timeout: '{build-timeout}'
383             timeout-var: 'BUILD_TIMEOUT'
384             fail: true
385         - ssh-agent-credentials:
386             users:
387                 - 'opendaylight-jenkins-ssh'
388         - openstack:
389             single-use: True