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