Update infra-properties macro
[releng/builder.git] / jjb / releng-macros.yaml
1 # OLD Releng macros
2 ---
3 - property:
4     name: opendaylight-infra-properties
5     properties:
6       - build-discarder:
7           days-to-keep: '{build-days-to-keep}'
8           num-to-keep: 40
9           artifact-days-to-keep: -1
10           artifact-num-to-keep: 5
11
12 - parameter:
13     name: opendaylight-infra-parameters
14     parameters:
15       - string:
16           name: PROJECT
17           default: '{project}'
18           description: 'Parameter to identify an ODL Gerrit project'
19       - string:
20           name: ARCHIVE_ARTIFACTS
21           default: '{artifacts} **/target/surefire-reports/*-output.txt **/hs_err_*.log **/target/feature/feature.xml'
22           description: 'Space separated glob patterns for artifacts to archive into logs.opendaylight.org'
23       - string:
24           name: GERRIT_PROJECT
25           default: '{project}'
26           description: "GERRIT_PROJECT parameter if not given by trigger"
27       - string:
28           name: GERRIT_BRANCH
29           default: '{branch}'
30           description: "JJB configured GERRIT_BRANCH parameter"
31       - string:
32           name: GERRIT_REFSPEC
33           default: '{refspec}'
34           description: "GERRIT_REFSPEC parameter if not given by trigger"
35       - string:
36           name: STACK_NAME
37           default: '$JOB_NAME-$BUILD_NUMBER'
38           description: "Used by Heat to generate a unique stack & vm name"
39
40 - parameter:
41     name: build-tag
42     parameters:
43       - string:
44           name: BUILD_TAG
45           default: ''
46           description: 'Tag in Git to checkout'
47
48 - parameter:
49     name: controller-version-parameter
50     parameters:
51       - string:
52           name: ODL_VERSION
53           default: '{odl_version}'
54           description: 'Controller version (for use with openstacks networking_odl project)'
55
56 - parameter:
57     name: patches-to-build-parameter
58     parameters:
59       - string:
60           name: PATCHES_TO_BUILD
61           default: ''
62           description: 'csv list of patches in project:changeset format to build distribution with'
63
64 - parameter:
65     name: distribution-branch-to-build-parameter
66     parameters:
67       - string:
68           name: DISTRIBUTION_BRANCH_TO_BUILD
69           default: 'master'
70           description: 'distribution repo branch to build with'
71
72 - parameter:
73     name: p2zip-parameter
74     parameters:
75       - string:
76           name: P2ZIP_URL
77           default: ''
78           description: 'Nexus staging profile id'
79
80 - parameter:
81     name: stage-id-parameter
82     parameters:
83       - string:
84           name: STAGING_PROFILE_ID
85           default: '{stage-id}'
86           description: 'Nexus staging profile id'
87
88 - parameter:
89     name: maven-exec
90     parameters:
91       - string:
92           name: MVN
93           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
94           description: 'Maven selector to be used by shell scripts'
95
96 - scm:
97     name: git-scm
98     scm:
99       - git:
100           credentials-id: 'opendaylight-jenkins-ssh'
101           url: '$GIT_BASE'
102           refspec: ''
103           branches:
104             - 'origin/{branch}'
105           skip-tag: true
106           wipe-workspace: true
107
108 - scm:
109     name: git-scm-with-submodules
110     scm:
111       - git:
112           credentials-id: 'opendaylight-jenkins-ssh'
113           url: '$GIT_BASE'
114           refspec: ''
115           branches:
116             - 'refs/heads/{branch}'
117           skip-tag: true
118           wipe-workspace: true
119           submodule:
120             recursive: true
121
122 - scm:
123     name: gerrit-trigger-scm
124     scm:
125       - git:
126           credentials-id: 'opendaylight-jenkins-ssh'
127           url: '$GIT_BASE'
128           refspec: '{refspec}'
129           branches:
130             - 'origin/$GERRIT_BRANCH'
131           skip-tag: true
132           choosing-strategy: '{choosing-strategy}'
133
134 - wrapper:
135     name: build-timeout
136     wrappers:
137       - timeout:
138           type: absolute
139           timeout: 360
140           fail: true
141
142 # This is a single macro to use for all jobs who vote on every (relevant) patch set.
143 # Only 'recheck' trigger word is supported, it always triggers the full set of relevant jobs,
144 # in order to prevent Jenkins from starting only a subset and still voting Verified+1.
145 # Arguments:
146 #     server: name of gerrit server to listen to
147 #     project: pattern to match triggering projects
148 #     branch: triggering branch name
149 #     files: pattern to match triggering filepaths
150 - trigger:
151     name: gerrit-trigger-patch-submitted
152     triggers:
153       - gerrit:
154           server-name: '{server}'
155           trigger-on:
156             - patchset-created-event:
157                 exclude-drafts: 'true'
158                 exclude-trivial-rebase: 'false'
159                 exclude-no-code-change: 'true'
160             - draft-published-event
161             - comment-added-contains-event:
162                 comment-contains-value: 'recheck'
163           projects:
164             - project-compare-type: 'ANT'
165               project-pattern: '{project}'
166               branches:
167                 - branch-compare-type: 'ANT'
168                   branch-pattern: '**/{branch}'
169               file-paths:
170                 - compare-type: 'ANT'
171                   pattern: '{files}'
172
173 # TODO: Unify argument names across gerrit-trigger-* macros.
174 - trigger:
175     name: gerrit-trigger-patch-merged
176     triggers:
177       - gerrit:
178           server-name: '{server-name}'
179           trigger-on:
180             - change-merged-event
181             - comment-added-contains-event:
182                 comment-contains-value: 'remerge'
183           projects:
184             - project-compare-type: 'ANT'
185               project-pattern: '{name}'
186               branches:
187                 - branch-compare-type: 'ANT'
188                   branch-pattern: '**/{branch}'
189           skip-vote:
190             successful: true
191             failed: true
192             unstable: true
193             notbuilt: true
194           # Force Jenkins always vote the values it should already have voted
195           # during the prior verify phase
196           override-votes: true
197           gerrit-build-started-verified-value: 1
198           gerrit-build-successful-verified-value: 1
199           gerrit-build-failed-verified-value: 1
200           gerrit-build-unstable-verified-value: 1
201           gerrit-build-notbuilt-verified-value: 1
202           gerrit-build-started-codereview-value: 0
203           gerrit-build-successful-codereview-value: 0
204           gerrit-build-failed-codereview-value: 0
205           gerrit-build-unstable-codereview-value: 0
206           gerrit-build-notbuilt-codereview-value: 0
207
208 # TODO: Unify argument names across gerrit-trigger-* macros.
209 - trigger:
210     name: gerrit-trigger-patch-sonar
211     triggers:
212       - gerrit:
213           server-name: '{server-name}'
214           trigger-on:
215             - comment-added-contains-event:
216                 comment-contains-value: 'run-sonar'
217           projects:
218             - project-compare-type: 'ANT'
219               project-pattern: '{name}'
220               branches:
221                 - branch-compare-type: 'ANT'
222                   branch-pattern: '**/master'
223           skip-vote:
224             successful: true
225             failed: true
226             unstable: true
227             notbuilt: true
228
229 - publisher:
230     name: archive-artifacts
231     publishers:
232       - archive:
233           artifacts: '{artifacts}'
234           allow-empty: true
235           fingerprint: true
236           latest-only: true
237
238 - publisher:
239     name: email-notification
240     publishers:
241       - email-ext:
242           recipients: '{email-recipients}'
243           reply-to: ''
244           content-type: default
245           subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
246           body: |
247               $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
248
249               Please refer to the logs server URL for console logs when possible
250               and use the Jenkins Build URL as a last resort.
251
252               Console Logs URL:
253               https://logs.opendaylight.org/$SILO/$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER
254
255               Jenkins Build URL:
256               $BUILD_URL
257           unstable: true
258           fixed: true
259           send-to:
260             - recipients
261
262 - publisher:
263     name: jacoco-report
264     publishers:
265       - jacoco:
266           exec-pattern: "**/**.exec"
267           class-pattern: "**/classes"
268           source-pattern: "**/src/main/java"
269           exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
270           status-update: true
271           targets:
272             - branch:
273                 healthy: 10
274                 unhealthy: 20
275             - method:
276                 healthy: 50
277                 unhealthy: 40
278
279 - publisher:
280     name: opendaylight-infra-shiplogs
281     # To archive things the job will need to create a "archives" directory in
282     # the workspace and this macro will handle copying the contents of the
283     # archives directory.
284     #
285     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files
286     # to archive. You can pass globstar patterns for example "**/*.xml **/*.log"
287     # as the archive pattern. This is a space separated list of files to archive.
288     #
289     # Also ensure that the workspace is cleaned up at the end of the build.
290     publishers:
291       - postbuildscript:
292           builders:
293             - shell: !include-raw: include-raw-stack-delete.sh
294             - shell: !include-raw-escape: include-raw-deploy-archives.sh
295             - maven-target:
296                 maven-version: '{maven-version}'
297                 pom: '.archives/deploy-archives.xml'
298                 goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
299                 settings: 'jenkins-log-archives-settings'
300                 settings-type: cfp
301                 global-settings: 'odl-global-settings'
302                 global-settings-type: cfp
303             - description-setter:
304                 regexp: '^Build logs: .*'
305             # Cleanup after ourselves
306             - wipe-org-opendaylight-repo
307           script-only-if-succeeded: false
308           script-only-if-failed: false
309           mark-unstable-if-failed: true
310       - workspace-cleanup:
311           exclude:
312             # Do not clean up *.jenkins-trigger files for jobs that use a
313             # properties file as input for triggering another build.
314             - '**/*.jenkins-trigger'
315           fail-build: false
316
317 - builder:
318     name: opendaylight-infra-stack
319     # opendaylight-infra-stack.sh has a required variable {stack-template} that
320     # must be passed into this macro.
321     builders:
322       - shell: !include-raw: opendaylight-infra-stack.sh
323       - shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
324
325 - builder:
326     name: opendaylight-infra-push-gerrit-patch
327     # opendaylight-infra-push-gerrit-patch.sh allows a job to push a patch to
328     # Gerrit in an automated fashion. This is meant for tasks that creates
329     # the same patch regularly and needs the ability to detect if an unreviewed
330     # patch already exists. In which case it will update the existing patch.
331     #
332     # Note: This patch assumes the $WORKSPACE contains the project repo with
333     #       the files changed already "git add" and waiting for a "git commit" call.
334     #
335     # This script requires the following JJB variables to be passed in:
336     #     {project}       Gerrit project-name
337     #     {gerrit-topic}  Gerrit topic, please make a unique topic.
338     #     {gerrit-commit-message} Commit message to assign to commit.
339     # NOTE: Requires git review to be installed on node.
340     builders:
341       - shell: !include-raw: opendaylight-infra-push-gerrit-patch.sh
342
343 - builder:
344     name: distribute-build-url
345     # Place URL of the current run of a build job to a file at given path.
346     builders:
347       - shell: 'echo "$BUILD_URL" > {path}/build.url'
348
349 - builder:
350     name: wipe-org-opendaylight-repo
351     builders:
352       - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
353
354 - builder:
355     name: wipe-local-maven-repo
356     builders:
357       - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
358
359 - builder:
360     name: jacoco-nojava-workaround
361     builders:
362       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
363
364 - builder:
365     name: check-clm
366     builders:
367       - sonatype-clm:
368           application-name: '{application-name}'
369
370 - builder:
371     name: releng-check-unicode
372     builders:
373       - shell: |
374           $WORKSPACE/scripts/check-unicode.sh jjb/
375
376 - builder:
377     name: provide-maven-settings
378     builders:
379       - config-file-provider:
380           files:
381             - file-id: '{global-settings-file}'
382               variable: 'GLOBAL_SETTINGS_FILE'
383             - file-id: '{settings-file}'
384               variable: 'SETTINGS_FILE'
385
386 - builder:
387     name: releng-fetch-p2zip-if-necessary
388     builders:
389       - shell: |
390           # Cleanup any existing zips and metadata before we download the new update site
391           rm -f *.zip *.xml
392       - conditional-step:
393           condition-kind: strings-match
394           condition-string1: '$P2ZIP_URL'
395           condition-string2: ''
396           condition-basedir: workspace
397           steps:
398             # TODO: Figure out latest snapshot version number to pull rather than hardcoding 1.1.1-SNAPSHOT
399             - maven-target:
400                 maven-version: '{maven-version}'
401                 goals: >
402                     org.apache.maven.plugins:maven-dependency-plugin:get
403                     org.apache.maven.plugins:maven-dependency-plugin:copy
404                     -V -B
405                     -Dartifact=org.opendaylight.yangide:org.opendaylight.yangide.update-site:1.1.1-SNAPSHOT:zip
406                     -DoutputDirectory=$WORKSPACE
407                 settings: '{settings}'
408                 global-settings: '{global-settings}'
409
410 - builder:
411     name: releng-generate-p2pom
412     builders:
413       - shell: !include-raw: include-raw-generate-p2pom.sh
414
415 - builder:
416     name: releng-update-p2composite-metadata
417     builders:
418       - shell: !include-raw: include-raw-update-p2composite-metadata.sh
419       - conditional-step:
420           condition-kind: file-exists
421           condition-filename: deploy-composite-repo.xml
422           condition-basedir: workspace
423           steps:
424             - maven-target:
425                 maven-version: '{maven-version}'
426                 pom: 'deploy-composite-repo.xml'
427                 goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
428                 settings: '{settings}'
429                 global-settings: '{global-settings}'
430
431 - builder:
432     name: releng-stage-release
433     builders:
434       - shell: !include-raw: include-raw-stage-release.sh
435
436 - wrapper:
437     # This wrapper is required for all jobs as it configures the wrappers
438     # needed by OpenDaylight infra.
439     name: opendaylight-infra-wrappers
440     wrappers:
441       - mask-passwords
442       - config-file-provider:
443           files:
444             - file-id: rackspace-heat
445               target: '$HOME/.config/openstack/clouds.yaml'
446       - timeout:
447           type: absolute
448           timeout: '{build-timeout}'
449           timeout-var: 'BUILD_TIMEOUT'
450           fail: true
451       - timestamps
452       - ssh-agent-credentials:
453           users:
454             - 'opendaylight-jenkins-ssh'
455       - openstack:
456           single-use: true
457
458 - builder:
459     name: packer-validate
460     builders:
461       - config-file-provider:
462           files:
463             - file-id: 'packer-cloud-env'
464               variable: 'CLOUDENV'
465       - shell: |
466           cd packer
467           varfiles="../packer/vars/*"
468           templates="../packer/templates/*"
469           provision="../packer/provision/*.sh"
470           for v in $varfiles; do
471               [[ "${v##*/}" =~ ^(cloud-env.*)$ ]] && continue
472               for t in $templates; do
473                   export PACKER_LOG="yes" && \
474                   export PACKER_LOG_PATH="packer-validate-${v##*/}-${t##*/}.log" && \
475                               packer.io validate -var-file=$CLOUDENV \
476                               -var-file=$v $t
477                   if [ $? -ne 0 ]; then
478                       break
479                   fi
480               done
481           done
482           for p in $provision; do
483               /bin/bash -n $p > provision-validate-${p##*/}.log 2>&1
484           done
485
486
487 - builder:
488     name: packer-build
489     builders:
490       - config-file-provider:
491           files:
492             - file-id: 'packer-cloud-env'
493               variable: 'CLOUDENV'
494       - shell: |
495           cd packer
496           export PACKER_LOG="yes" && \
497           export PACKER_LOG_PATH="packer-build.log" && \
498                       packer.io build -var-file=$CLOUDENV \
499                        -var-file=../packer/vars/{platform}.json \
500                        ../packer/templates/{template}.json
501
502 - builder:
503     # TODO: Verify signature after downloading users public key from a locally created
504     # repository instead of the public keymesh. This requires a process in place to get ODL
505     # developers public keys into a local repository without increasing the job thoughput.
506     name: verify-gpg-signature
507     builders:
508       - shell: !include-raw: include-raw-verify-gpg-signatures.sh
509
510 - builder:
511     name: opendaylight-infra-jjbini
512     builders:
513       - config-file-provider:
514           files:
515             - file-id: 'jjbini'
516               target: '$HOME/.config/jenkins_jobs/jenkins_jobs.ini'