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