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