Preserve property files to trigger test jobs
[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: 'Space separated glob patterns for 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 - parameter:
76     name: maven-exec
77     parameters:
78       - string:
79           name: MVN
80           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
81           description: 'Maven selector to be used by shell scripts'
82
83 - scm:
84     name: git-scm
85     scm:
86         - git:
87             credentials-id: 'opendaylight-jenkins-ssh'
88             url: '$GIT_BASE'
89             refspec: ''
90             branches:
91                 - 'origin/{branch}'
92             skip-tag: true
93             wipe-workspace: true
94
95 - scm:
96     name: git-scm-with-submodules
97     scm:
98         - git:
99             credentials-id: 'opendaylight-jenkins-ssh'
100             url: '$GIT_BASE'
101             refspec: ''
102             branches:
103                 - 'refs/heads/{branch}'
104             skip-tag: true
105             wipe-workspace: true
106             submodule:
107                 recursive: true
108
109 - scm:
110     name: gerrit-trigger-scm
111     scm:
112         - git:
113             credentials-id: 'opendaylight-jenkins-ssh'
114             url: '$GIT_BASE'
115             refspec: '{refspec}'
116             branches:
117                 - 'origin/$GERRIT_BRANCH'
118             skip-tag: true
119             choosing-strategy: '{choosing-strategy}'
120
121 - wrapper:
122     name: build-timeout
123     wrappers:
124         - timeout:
125             type: absolute
126             timeout: 360
127             fail: true
128
129 - trigger:
130     name: gerrit-trigger-patch-submitted
131     triggers:
132         - gerrit:
133             server-name: 'OpenDaylight'
134             trigger-on:
135                 - patchset-created-event:
136                     exclude-drafts: 'false'
137                     exclude-trivial-rebase: 'false'
138                     exclude-no-code-change: 'false'
139                 - draft-published-event
140                 - comment-added-contains-event:
141                     comment-contains-value: 'recheck'
142                 - comment-added-contains-event:
143                     comment-contains-value: 'reverify'
144             projects:
145               - project-compare-type: 'ANT'
146                 project-pattern: '{name}'
147                 branches:
148                   - branch-compare-type: 'ANT'
149                     branch-pattern: '**/{branch}'
150
151 - trigger:
152     name: gerrit-trigger-relevant-patch-submitted
153     triggers:
154         - gerrit:
155             server-name: 'OpenDaylight'
156             trigger-on:
157                 - patchset-created-event:
158                     exclude-drafts: 'true'
159                     exclude-trivial-rebase: 'false'
160                     exclude-no-code-change: 'true'
161                 - draft-published-event
162                 - comment-added-contains-event:
163                     comment-contains-value: 'recheck'
164                 - comment-added-contains-event:
165                     comment-contains-value: 'reverify'
166             projects:
167               - project-compare-type: 'ANT'
168                 project-pattern: '{name}'
169                 branches:
170                   - branch-compare-type: 'ANT'
171                     branch-pattern: '**/{branch}'
172
173 - trigger:
174     name: gerrit-trigger-patch-merged
175     triggers:
176         - gerrit:
177             server-name: 'OpenDaylight'
178             trigger-on:
179                 - change-merged-event
180                 - comment-added-contains-event:
181                     comment-contains-value: 'remerge'
182             projects:
183               - project-compare-type: 'ANT'
184                 project-pattern: '{name}'
185                 branches:
186                   - branch-compare-type: 'ANT'
187                     branch-pattern: '**/{branch}'
188
189 - trigger:
190     name: gerrit-trigger-patch-sonar
191     triggers:
192         - gerrit:
193             server-name: 'OpenDaylight'
194             trigger-on:
195                 - comment-added-contains-event:
196                     comment-contains-value: 'run-sonar'
197             projects:
198               - project-compare-type: 'ANT'
199                 project-pattern: '{name}'
200                 branches:
201                   - branch-compare-type: 'ANT'
202                     branch-pattern: '**/master'
203             skip-vote:
204                 successful: true
205                 failed: true
206                 unstable: true
207                 notbuilt: true
208
209 - trigger:
210     name: gerrit-trigger-patch-site-merged
211     triggers:
212         - gerrit:
213             server-name: 'OpenDaylight'
214             trigger-on:
215                 - change-merged-event
216                 - comment-added-contains-event:
217                     comment-contains-value: 'republish'
218             projects:
219               - project-compare-type: 'ANT'
220                 project-pattern: '{name}'
221                 branches:
222                     - branch-compare-type: 'ANT'
223                       branch-pattern: '**/{branch}'
224
225 - publisher:
226     name: archive-artifacts
227     publishers:
228         - archive:
229             artifacts: '{artifacts}'
230             allow-empty: true
231             fingerprint: true
232             latest-only: true
233
234 - publisher:
235     name: email-notification
236     publishers:
237         - email-ext:
238             recipients: 'jenkins@lists.opendaylight.org'
239             reply-to:
240             content-type: default
241             subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
242             body: |
243                 $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
244
245                 Check console output at $BUILD_URL to view the results.
246             unstable: true
247             fixed: true
248             send-to:
249                 - recipients
250
251 - publisher:
252         name: jacoco-report
253         publishers:
254             - jacoco:
255                 exec-pattern: "**/**.exec"
256                 class-pattern: "**/classes"
257                 source-pattern: "**/src/main/java"
258                 exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
259                 status-update: true
260                 targets:
261                   - branch:
262                       healthy: 10
263                       unhealthy: 20
264                   - method:
265                       healthy: 50
266                       unhealthy: 40
267
268 - publisher:
269     name: opendaylight-infra-shiplogs
270     # To archive things the job will need to create a "archives" directory in
271     # the workspace and this macro will handle copying the contents of the
272     # archives directory.
273     #
274     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files
275     # to archive. You can pass globstar patterns for example "**/*.xml **/*.log"
276     # as the archive pattern. This is a space separated list of files to archive.
277     #
278     # Also ensure that the workspace is cleaned up at the end of the build.
279     publishers:
280         - postbuildscript:
281             builders:
282                 - shell: !include-raw: include-raw-deploy-archives.sh
283                 - maven-target:
284                         maven-version: '{maven-version}'
285                         pom: '.archives/deploy-archives.xml'
286                         goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
287                         settings: 'jenkins-log-archives-settings'
288                         settings-type: cfp
289                         global-settings: 'odl-global-settings'
290                         global-settings-type: cfp
291                 - description-setter:
292                     regexp: '^Build logs: .*'
293                 # Cleanup after ourselves
294                 - wipe-org-opendaylight-repo
295             script-only-if-succeeded: False
296             script-only-if-failed: False
297             mark-unstable-if-failed: True
298         - workspace-cleanup:
299             exclude:
300               # autorelease-release-{stream} reqires vaiables.prop file to be preserved
301               # as the downstream test jobs fails invoke without automatically
302               - variables.prop
303             fail-build: false
304
305 - builder:
306     name: wipe-org-opendaylight-repo
307     builders:
308         - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
309
310 - builder:
311     name: wipe-local-maven-repo
312     builders:
313         - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
314
315 - builder:
316     name: jacoco-nojava-workaround
317     builders:
318         - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
319
320 - builder:
321     name: check-clm
322     builders:
323         - sonatype-clm:
324             application-name: '{application-name}'
325
326 - builder:
327     name: releng-check-unicode
328     builders:
329         - shell: |
330             $WORKSPACE/scripts/check-unicode.sh jjb/
331
332 - builder:
333     name: provide-maven-settings
334     builders:
335     - config-file-provider:
336         files:
337         - file-id: '{global-settings-file}'
338           variable: 'GLOBAL_SETTINGS_FILE'
339         - file-id: '{settings-file}'
340           variable: 'SETTINGS_FILE'
341
342 - builder:
343     name: releng-fetch-p2zip-if-necessary
344     builders:
345     - shell: |
346         # Cleanup any existing zips and metadata before we download the new update site
347         rm -f *.zip *.xml
348     - conditional-step:
349         condition-kind: strings-match
350         condition-string1: '$P2ZIP_URL'
351         condition-string2: ''
352         condition-basedir: workspace
353         steps:
354             # TODO: Figure out latest snapshot version number to pull rather than hardcoding 1.1.1-SNAPSHOT
355             - maven-target:
356                 maven-version: '{maven-version}'
357                 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'
358                 settings: '{settings}'
359                 global-settings: '{global-settings}'
360
361 - builder:
362     name: releng-generate-p2pom
363     builders:
364         - shell: !include-raw: include-raw-generate-p2pom.sh
365
366 - builder:
367     name: releng-update-p2composite-metadata
368     builders:
369     - shell: !include-raw: include-raw-update-p2composite-metadata.sh
370     - conditional-step:
371         condition-kind: file-exists
372         condition-filename: deploy-composite-repo.xml
373         condition-basedir: workspace
374         steps:
375             - maven-target:
376                 maven-version: '{maven-version}'
377                 pom: 'deploy-composite-repo.xml'
378                 goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
379                 settings: '{settings}'
380                 global-settings: '{global-settings}'
381
382 - builder:
383     name: releng-stage-release
384     builders:
385         - shell: !include-raw: include-raw-stage-release.sh
386
387 - wrapper:
388     # This wrapper is required for all jobs as it configures the wrappers
389     # needed by OpenDaylight infra.
390     name: opendaylight-infra-wrappers
391     wrappers:
392         - timeout:
393             type: absolute
394             timeout: '{build-timeout}'
395             timeout-var: 'BUILD_TIMEOUT'
396             fail: true
397         - timestamps
398         - ssh-agent-credentials:
399             users:
400                 - 'opendaylight-jenkins-ssh'
401         - jclouds:
402             single-use: True
403         - openstack:
404             single-use: True
405
406 - builder:
407     name: packer-validate
408     builders:
409         - config-file-provider:
410             files:
411                 - file-id: 'packer-cloud-env'
412                   variable: 'CLOUDENV'
413         - shell: |
414             cd packer
415             export PACKER_LOG="yes" && \
416             export PACKER_LOG_PATH="packer-validate.log" && \
417                         packer.io validate -var-file=$CLOUDENV \
418                          -var-file=../packer/vars/{platform}.json \
419                          ../packer/templates/{template}.json
420
421 - builder:
422     name: packer-build
423     builders:
424         - shell: |
425             cd packer
426             export PACKER_LOG="yes" && \
427             export PACKER_LOG_PATH="packer-build.log" && \
428                         packer.io build -var-file=$CLOUDENV \
429                          -var-file=../packer/vars/{platform}.json \
430                          ../packer/templates/{template}.json