Enable Heat for {project}-csit-verify-3node-{functionality}
[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                         # TODO: Remove the condition once we are no longer using
286                         #       JClouds plugin.
287                         if [ -z "$JCLOUDS_IPS" ]; then
288                             source $WORKSPACE/.venv-openstack/bin/activate
289                             openstack --os-cloud rackspace stack delete --yes $STACK_NAME
290                         fi
291                     fi
292                 - shell: !include-raw: include-raw-deploy-archives.sh
293                 - maven-target:
294                         maven-version: '{maven-version}'
295                         pom: '.archives/deploy-archives.xml'
296                         goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
297                         settings: 'jenkins-log-archives-settings'
298                         settings-type: cfp
299                         global-settings: 'odl-global-settings'
300                         global-settings-type: cfp
301                 - description-setter:
302                     regexp: '^Build logs: .*'
303                 # Cleanup after ourselves
304                 - wipe-org-opendaylight-repo
305             script-only-if-succeeded: False
306             script-only-if-failed: False
307             mark-unstable-if-failed: True
308         - workspace-cleanup:
309             exclude:
310               # Do not clean up *.jenkins-trigger files for jobs that use a
311               # properties file as input for triggering another build.
312               - '**/*.jenkins-trigger'
313             fail-build: false
314
315 - builder:
316     name: opendaylight-infra-stack
317     # opendaylight-infra-stack.sh has a required variable {stack-template} that
318     # must be passed into this macro.
319     builders:
320         - shell: !include-raw: opendaylight-infra-stack.sh
321         - shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
322
323 - builder:
324     name: wipe-org-opendaylight-repo
325     builders:
326         - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
327
328 - builder:
329     name: wipe-local-maven-repo
330     builders:
331         - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
332
333 - builder:
334     name: jacoco-nojava-workaround
335     builders:
336         - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
337
338 - builder:
339     name: check-clm
340     builders:
341         - sonatype-clm:
342             application-name: '{application-name}'
343
344 - builder:
345     name: releng-check-unicode
346     builders:
347         - shell: |
348             $WORKSPACE/scripts/check-unicode.sh jjb/
349
350 - builder:
351     name: provide-maven-settings
352     builders:
353     - config-file-provider:
354         files:
355         - file-id: '{global-settings-file}'
356           variable: 'GLOBAL_SETTINGS_FILE'
357         - file-id: '{settings-file}'
358           variable: 'SETTINGS_FILE'
359
360 - builder:
361     name: releng-fetch-p2zip-if-necessary
362     builders:
363     - shell: |
364         # Cleanup any existing zips and metadata before we download the new update site
365         rm -f *.zip *.xml
366     - conditional-step:
367         condition-kind: strings-match
368         condition-string1: '$P2ZIP_URL'
369         condition-string2: ''
370         condition-basedir: workspace
371         steps:
372             # TODO: Figure out latest snapshot version number to pull rather than hardcoding 1.1.1-SNAPSHOT
373             - maven-target:
374                 maven-version: '{maven-version}'
375                 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'
376                 settings: '{settings}'
377                 global-settings: '{global-settings}'
378
379 - builder:
380     name: releng-generate-p2pom
381     builders:
382         - shell: !include-raw: include-raw-generate-p2pom.sh
383
384 - builder:
385     name: releng-update-p2composite-metadata
386     builders:
387     - shell: !include-raw: include-raw-update-p2composite-metadata.sh
388     - conditional-step:
389         condition-kind: file-exists
390         condition-filename: deploy-composite-repo.xml
391         condition-basedir: workspace
392         steps:
393             - maven-target:
394                 maven-version: '{maven-version}'
395                 pom: 'deploy-composite-repo.xml'
396                 goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
397                 settings: '{settings}'
398                 global-settings: '{global-settings}'
399
400 - builder:
401     name: releng-stage-release
402     builders:
403         - shell: !include-raw: include-raw-stage-release.sh
404
405 - wrapper:
406     # This wrapper is required for all jobs as it configures the wrappers
407     # needed by OpenDaylight infra.
408     name: opendaylight-infra-wrappers
409     wrappers:
410         - mask-passwords
411         - config-file-provider:
412             files:
413                 - file-id: rackspace-heat
414                   target: '$HOME/.config/openstack/clouds.yaml'
415         - timeout:
416             type: absolute
417             timeout: '{build-timeout}'
418             timeout-var: 'BUILD_TIMEOUT'
419             fail: true
420         - timestamps
421         - ssh-agent-credentials:
422             users:
423                 - 'opendaylight-jenkins-ssh'
424         - jclouds:
425             single-use: True
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             export PACKER_LOG="yes" && \
439             export PACKER_LOG_PATH="packer-validate.log" && \
440                         packer.io validate -var-file=$CLOUDENV \
441                          -var-file=../packer/vars/{platform}.json \
442                          ../packer/templates/{template}.json
443
444 - builder:
445     name: packer-build
446     builders:
447         - shell: |
448             cd packer
449             export PACKER_LOG="yes" && \
450             export PACKER_LOG_PATH="packer-build.log" && \
451                         packer.io build -var-file=$CLOUDENV \
452                          -var-file=../packer/vars/{platform}.json \
453                          ../packer/templates/{template}.json
454
455 - builder:
456     # TODO: Verify signature after downloading users public key from a locally created
457     # repository instead of the public keymesh. This requires a process in place to get ODL
458     # developers public keys into a local repository without increasing the job thoughput.
459     name: verify-gpg-signature
460     builders:
461         - shell: !include-raw: include-raw-verify-gpg-signatures.sh