Switch to build-discarder property for logrotate
[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'
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
33 - parameter:
34     name: build-tag
35     parameters:
36         - string:
37             name: BUILD_TAG
38             default: ''
39             description: 'Tag in Git to checkout'
40
41 - parameter:
42     name: controller-version-parameter
43     parameters:
44         - string:
45             name: ODL_VERSION
46             default: '{odl_version}'
47             description: 'Controller version (for use with openstacks networking_odl project)'
48
49 - parameter:
50     name: patches-to-build-parameter
51     parameters:
52         - string:
53             name: PATCHES_TO_BUILD
54             default: ''
55             description: 'csv list of patches in project:changeset format to build distribution with'
56
57 - parameter:
58     name: distribution-branch-to-build-parameter
59     parameters:
60         - string:
61             name: DISTRIBUTION_BRANCH_TO_BUILD
62             default: 'master'
63             description: 'distribution repo branch to build with'
64
65 - parameter:
66     name: p2zip-parameter
67     parameters:
68         - string:
69             name: P2ZIP_URL
70             default: ''
71             description: 'Nexus staging profile id'
72
73 - parameter:
74     name: stage-id-parameter
75     parameters:
76         - string:
77             name: STAGING_PROFILE_ID
78             default: '{stage-id}'
79             description: 'Nexus staging profile id'
80
81 - parameter:
82     name: maven-exec
83     parameters:
84       - string:
85           name: MVN
86           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
87           description: 'Maven selector to be used by shell scripts'
88
89 - scm:
90     name: git-scm
91     scm:
92         - git:
93             credentials-id: 'opendaylight-jenkins-ssh'
94             url: '$GIT_BASE'
95             refspec: ''
96             branches:
97                 - 'origin/{branch}'
98             skip-tag: true
99             wipe-workspace: true
100
101 - scm:
102     name: git-scm-with-submodules
103     scm:
104         - git:
105             credentials-id: 'opendaylight-jenkins-ssh'
106             url: '$GIT_BASE'
107             refspec: ''
108             branches:
109                 - 'refs/heads/{branch}'
110             skip-tag: true
111             wipe-workspace: true
112             submodule:
113                 recursive: true
114
115 - scm:
116     name: gerrit-trigger-scm
117     scm:
118         - git:
119             credentials-id: 'opendaylight-jenkins-ssh'
120             url: '$GIT_BASE'
121             refspec: '{refspec}'
122             branches:
123                 - 'origin/$GERRIT_BRANCH'
124             skip-tag: true
125             choosing-strategy: '{choosing-strategy}'
126
127 - wrapper:
128     name: build-timeout
129     wrappers:
130         - timeout:
131             type: absolute
132             timeout: 360
133             fail: true
134
135 # This is a single macro to use for all jobs who vote on every (relevant) patch set.
136 # Only 'recheck' trigger word is supported, it always triggers the full set of relevant jobs,
137 # in order to prevent Jenkins from starting only a subset and still voting Verified+1.
138 # Arguments:
139 #     server: name of gerrit server to listen to
140 #     project: pattern to match triggering projects
141 #     branch: triggering branch name
142 #     files: pattern to match triggering filepaths
143 - trigger:
144     name: gerrit-trigger-patch-submitted
145     triggers:
146         - gerrit:
147             server-name: '{server}'
148             trigger-on:
149                 - patchset-created-event:
150                     exclude-drafts: 'true'
151                     exclude-trivial-rebase: 'false'
152                     exclude-no-code-change: 'true'
153                 - draft-published-event
154                 - comment-added-contains-event:
155                     comment-contains-value: 'recheck'
156             projects:
157                 - project-compare-type: 'ANT'
158                   project-pattern: '{project}'
159                   branches:
160                       - branch-compare-type: 'ANT'
161                         branch-pattern: '**/{branch}'
162                   file-paths:
163                       - compare-type: 'ANT'
164                         pattern: '{files}'
165
166 # TODO: Unify argument names across gerrit-trigger-* macros.
167 - trigger:
168     name: gerrit-trigger-patch-merged
169     triggers:
170         - gerrit:
171             server-name: '{server-name}'
172             trigger-on:
173                 - change-merged-event
174                 - comment-added-contains-event:
175                     comment-contains-value: 'remerge'
176             projects:
177                 - project-compare-type: 'ANT'
178                   project-pattern: '{name}'
179                   branches:
180                       - branch-compare-type: 'ANT'
181                         branch-pattern: '**/{branch}'
182             skip-vote:
183                 successful: true
184                 failed: true
185                 unstable: true
186                 notbuilt: true
187             # Force Jenkins always vote the values it should already have voted
188             # during the prior verify phase
189             override-votes: true
190             gerrit-build-started-verified-value: 1
191             gerrit-build-successful-verified-value: 1
192             gerrit-build-failed-verified-value: 1
193             gerrit-build-unstable-verified-value: 1
194             gerrit-build-notbuilt-verified-value: 1
195             gerrit-build-started-codereview-value: 0
196             gerrit-build-successful-codereview-value: 0
197             gerrit-build-failed-codereview-value: 0
198             gerrit-build-unstable-codereview-value: 0
199             gerrit-build-notbuilt-codereview-value: 0
200
201 # TODO: Unify argument names across gerrit-trigger-* macros.
202 - trigger:
203     name: gerrit-trigger-patch-sonar
204     triggers:
205         - gerrit:
206             server-name: '{server-name}'
207             trigger-on:
208                 - comment-added-contains-event:
209                     comment-contains-value: 'run-sonar'
210             projects:
211               - project-compare-type: 'ANT'
212                 project-pattern: '{name}'
213                 branches:
214                   - branch-compare-type: 'ANT'
215                     branch-pattern: '**/master'
216             skip-vote:
217                 successful: true
218                 failed: true
219                 unstable: true
220                 notbuilt: true
221
222 - publisher:
223     name: archive-artifacts
224     publishers:
225         - archive:
226             artifacts: '{artifacts}'
227             allow-empty: true
228             fingerprint: true
229             latest-only: true
230
231 - publisher:
232     name: email-notification
233     publishers:
234         - email-ext:
235             recipients: '{email-recipients}'
236             reply-to: ''
237             content-type: default
238             subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
239             body: |
240                 $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
241
242                 Check console output at $BUILD_URL to view the results.
243             unstable: true
244             fixed: true
245             send-to:
246                 - recipients
247
248 - publisher:
249         name: jacoco-report
250         publishers:
251             - jacoco:
252                 exec-pattern: "**/**.exec"
253                 class-pattern: "**/classes"
254                 source-pattern: "**/src/main/java"
255                 exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
256                 status-update: true
257                 targets:
258                   - branch:
259                       healthy: 10
260                       unhealthy: 20
261                   - method:
262                       healthy: 50
263                       unhealthy: 40
264
265 - publisher:
266     name: opendaylight-infra-shiplogs
267     # To archive things the job will need to create a "archives" directory in
268     # the workspace and this macro will handle copying the contents of the
269     # archives directory.
270     #
271     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files
272     # to archive. You can pass globstar patterns for example "**/*.xml **/*.log"
273     # as the archive pattern. This is a space separated list of files to archive.
274     #
275     # Also ensure that the workspace is cleaned up at the end of the build.
276     publishers:
277         - postbuildscript:
278             builders:
279                 - shell: !include-raw: include-raw-deploy-archives.sh
280                 - maven-target:
281                         maven-version: '{maven-version}'
282                         pom: '.archives/deploy-archives.xml'
283                         goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
284                         settings: 'jenkins-log-archives-settings'
285                         settings-type: cfp
286                         global-settings: 'odl-global-settings'
287                         global-settings-type: cfp
288                 - description-setter:
289                     regexp: '^Build logs: .*'
290                 # Cleanup after ourselves
291                 - wipe-org-opendaylight-repo
292             script-only-if-succeeded: False
293             script-only-if-failed: False
294             mark-unstable-if-failed: True
295         - workspace-cleanup:
296             exclude:
297               # Do not clean up *.jenkins-trigger files for jobs that use a
298               # properties file as input for triggering another build.
299               - '**/*.jenkins-trigger'
300             fail-build: false
301
302 - builder:
303     name: wipe-org-opendaylight-repo
304     builders:
305         - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
306
307 - builder:
308     name: wipe-local-maven-repo
309     builders:
310         - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
311
312 - builder:
313     name: jacoco-nojava-workaround
314     builders:
315         - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
316
317 - builder:
318     name: check-clm
319     builders:
320         - sonatype-clm:
321             application-name: '{application-name}'
322
323 - builder:
324     name: releng-check-unicode
325     builders:
326         - shell: |
327             $WORKSPACE/scripts/check-unicode.sh jjb/
328
329 - builder:
330     name: provide-maven-settings
331     builders:
332     - config-file-provider:
333         files:
334         - file-id: '{global-settings-file}'
335           variable: 'GLOBAL_SETTINGS_FILE'
336         - file-id: '{settings-file}'
337           variable: 'SETTINGS_FILE'
338
339 - builder:
340     name: releng-fetch-p2zip-if-necessary
341     builders:
342     - shell: |
343         # Cleanup any existing zips and metadata before we download the new update site
344         rm -f *.zip *.xml
345     - conditional-step:
346         condition-kind: strings-match
347         condition-string1: '$P2ZIP_URL'
348         condition-string2: ''
349         condition-basedir: workspace
350         steps:
351             # TODO: Figure out latest snapshot version number to pull rather than hardcoding 1.1.1-SNAPSHOT
352             - maven-target:
353                 maven-version: '{maven-version}'
354                 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'
355                 settings: '{settings}'
356                 global-settings: '{global-settings}'
357
358 - builder:
359     name: releng-generate-p2pom
360     builders:
361         - shell: !include-raw: include-raw-generate-p2pom.sh
362
363 - builder:
364     name: releng-update-p2composite-metadata
365     builders:
366     - shell: !include-raw: include-raw-update-p2composite-metadata.sh
367     - conditional-step:
368         condition-kind: file-exists
369         condition-filename: deploy-composite-repo.xml
370         condition-basedir: workspace
371         steps:
372             - maven-target:
373                 maven-version: '{maven-version}'
374                 pom: 'deploy-composite-repo.xml'
375                 goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
376                 settings: '{settings}'
377                 global-settings: '{global-settings}'
378
379 - builder:
380     name: releng-stage-release
381     builders:
382         - shell: !include-raw: include-raw-stage-release.sh
383
384 - wrapper:
385     # This wrapper is required for all jobs as it configures the wrappers
386     # needed by OpenDaylight infra.
387     name: opendaylight-infra-wrappers
388     wrappers:
389         - timeout:
390             type: absolute
391             timeout: '{build-timeout}'
392             timeout-var: 'BUILD_TIMEOUT'
393             fail: true
394         - timestamps
395         - ssh-agent-credentials:
396             users:
397                 - 'opendaylight-jenkins-ssh'
398         - jclouds:
399             single-use: True
400         - openstack:
401             single-use: True
402
403 - builder:
404     name: packer-validate
405     builders:
406         - config-file-provider:
407             files:
408                 - file-id: 'packer-cloud-env'
409                   variable: 'CLOUDENV'
410         - shell: |
411             cd packer
412             export PACKER_LOG="yes" && \
413             export PACKER_LOG_PATH="packer-validate.log" && \
414                         packer.io validate -var-file=$CLOUDENV \
415                          -var-file=../packer/vars/{platform}.json \
416                          ../packer/templates/{template}.json
417
418 - builder:
419     name: packer-build
420     builders:
421         - shell: |
422             cd packer
423             export PACKER_LOG="yes" && \
424             export PACKER_LOG_PATH="packer-build.log" && \
425                         packer.io build -var-file=$CLOUDENV \
426                          -var-file=../packer/vars/{platform}.json \
427                          ../packer/templates/{template}.json
428
429 - builder:
430     # TODO: Verify signature after downloading users public key from a locally created
431     # repository instead of the public keymesh. This requires a process in place to get ODL
432     # developers public keys into a local repository without increasing the job thoughput.
433     name: verify-gpg-signature
434     builders:
435         - shell: !include-raw: include-raw-verify-gpg-signatures.sh