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