Make stream for CSIT verify configurable
[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         - 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                 Check console output at $BUILD_URL to view the results.
247             unstable: true
248             fixed: true
249             send-to:
250                 - recipients
251
252 - publisher:
253         name: jacoco-report
254         publishers:
255             - jacoco:
256                 exec-pattern: "**/**.exec"
257                 class-pattern: "**/classes"
258                 source-pattern: "**/src/main/java"
259                 exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
260                 status-update: true
261                 targets:
262                   - branch:
263                       healthy: 10
264                       unhealthy: 20
265                   - method:
266                       healthy: 50
267                       unhealthy: 40
268
269 - publisher:
270     name: opendaylight-infra-shiplogs
271     # To archive things the job will need to create a "archives" directory in
272     # the workspace and this macro will handle copying the contents of the
273     # archives directory.
274     #
275     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files
276     # to archive. You can pass globstar patterns for example "**/*.xml **/*.log"
277     # as the archive pattern. This is a space separated list of files to archive.
278     #
279     # Also ensure that the workspace is cleaned up at the end of the build.
280     publishers:
281         - postbuildscript:
282             builders:
283                 - shell: |
284                     if [ -d "$WORKSPACE/.venv-openstack" ]; then
285                         source $WORKSPACE/.venv-openstack/bin/activate
286                         openstack --os-cloud rackspace stack delete --yes $STACK_NAME
287                     fi
288                 - shell: !include-raw: include-raw-deploy-archives.sh
289                 - maven-target:
290                         maven-version: '{maven-version}'
291                         pom: '.archives/deploy-archives.xml'
292                         goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
293                         settings: 'jenkins-log-archives-settings'
294                         settings-type: cfp
295                         global-settings: 'odl-global-settings'
296                         global-settings-type: cfp
297                 - description-setter:
298                     regexp: '^Build logs: .*'
299                 # Cleanup after ourselves
300                 - wipe-org-opendaylight-repo
301             script-only-if-succeeded: False
302             script-only-if-failed: False
303             mark-unstable-if-failed: True
304         - workspace-cleanup:
305             exclude:
306               # Do not clean up *.jenkins-trigger files for jobs that use a
307               # properties file as input for triggering another build.
308               - '**/*.jenkins-trigger'
309             fail-build: false
310
311 - builder:
312     name: opendaylight-infra-stack
313     # opendaylight-infra-stack.sh has a required variable {stack-template} that
314     # must be passed into this macro.
315     builders:
316         - shell: !include-raw: opendaylight-infra-stack.sh
317         - shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
318
319 - builder:
320     name: distribute-build-url
321     # Place URL of the current run of a build job to a file at given path.
322     builders:
323         - shell: 'echo "$BUILD_URL" > {path}/build.url'
324
325 - builder:
326     name: wipe-org-opendaylight-repo
327     builders:
328         - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
329
330 - builder:
331     name: wipe-local-maven-repo
332     builders:
333         - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
334
335 - builder:
336     name: jacoco-nojava-workaround
337     builders:
338         - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
339
340 - builder:
341     name: check-clm
342     builders:
343         - sonatype-clm:
344             application-name: '{application-name}'
345
346 - builder:
347     name: releng-check-unicode
348     builders:
349         - shell: |
350             $WORKSPACE/scripts/check-unicode.sh jjb/
351
352 - builder:
353     name: provide-maven-settings
354     builders:
355     - config-file-provider:
356         files:
357         - file-id: '{global-settings-file}'
358           variable: 'GLOBAL_SETTINGS_FILE'
359         - file-id: '{settings-file}'
360           variable: 'SETTINGS_FILE'
361
362 - builder:
363     name: releng-fetch-p2zip-if-necessary
364     builders:
365     - shell: |
366         # Cleanup any existing zips and metadata before we download the new update site
367         rm -f *.zip *.xml
368     - conditional-step:
369         condition-kind: strings-match
370         condition-string1: '$P2ZIP_URL'
371         condition-string2: ''
372         condition-basedir: workspace
373         steps:
374             # TODO: Figure out latest snapshot version number to pull rather than hardcoding 1.1.1-SNAPSHOT
375             - maven-target:
376                 maven-version: '{maven-version}'
377                 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'
378                 settings: '{settings}'
379                 global-settings: '{global-settings}'
380
381 - builder:
382     name: releng-generate-p2pom
383     builders:
384         - shell: !include-raw: include-raw-generate-p2pom.sh
385
386 - builder:
387     name: releng-update-p2composite-metadata
388     builders:
389     - shell: !include-raw: include-raw-update-p2composite-metadata.sh
390     - conditional-step:
391         condition-kind: file-exists
392         condition-filename: deploy-composite-repo.xml
393         condition-basedir: workspace
394         steps:
395             - maven-target:
396                 maven-version: '{maven-version}'
397                 pom: 'deploy-composite-repo.xml'
398                 goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
399                 settings: '{settings}'
400                 global-settings: '{global-settings}'
401
402 - builder:
403     name: releng-stage-release
404     builders:
405         - shell: !include-raw: include-raw-stage-release.sh
406
407 - wrapper:
408     # This wrapper is required for all jobs as it configures the wrappers
409     # needed by OpenDaylight infra.
410     name: opendaylight-infra-wrappers
411     wrappers:
412         - mask-passwords
413         - config-file-provider:
414             files:
415                 - file-id: rackspace-heat
416                   target: '$HOME/.config/openstack/clouds.yaml'
417         - timeout:
418             type: absolute
419             timeout: '{build-timeout}'
420             timeout-var: 'BUILD_TIMEOUT'
421             fail: true
422         - timestamps
423         - ssh-agent-credentials:
424             users:
425                 - 'opendaylight-jenkins-ssh'
426         - openstack:
427             single-use: True
428
429 - builder:
430     name: packer-validate
431     builders:
432         - config-file-provider:
433             files:
434                 - file-id: 'packer-cloud-env'
435                   variable: 'CLOUDENV'
436         - shell: |
437             cd packer
438             varfiles="../packer/vars/*"
439             templates="../packer/templates/*"
440             provision="../packer/provision/*.sh"
441             for v in $varfiles; do
442                 [[ "${v##*/}" =~ ^(cloud-env.*)$ ]] && continue
443                 for t in $templates; do
444                     export PACKER_LOG="yes" && \
445                     export PACKER_LOG_PATH="packer-validate-${v##*/}-${t##*/}.log" && \
446                                 packer.io validate -var-file=$CLOUDENV \
447                                 -var-file=$v $t
448                     if [ $? -ne 0 ]; then
449                         break
450                     fi
451                 done
452             done
453             for p in $provision; do
454                 /bin/bash -n $p > provision-validate-${p##*/}.log 2>&1
455             done
456
457 - builder:
458     name: packer-build
459     builders:
460         - shell: |
461             cd packer
462             export PACKER_LOG="yes" && \
463             export PACKER_LOG_PATH="packer-build.log" && \
464                         packer.io build -var-file=$CLOUDENV \
465                          -var-file=../packer/vars/{platform}.json \
466                          ../packer/templates/{template}.json
467
468 - builder:
469     # TODO: Verify signature after downloading users public key from a locally created
470     # repository instead of the public keymesh. This requires a process in place to get ODL
471     # developers public keys into a local repository without increasing the job thoughput.
472     name: verify-gpg-signature
473     builders:
474         - shell: !include-raw: include-raw-verify-gpg-signatures.sh