Use single macro and single trigger word for all every-patch jobs
[releng/builder.git] / jjb / integration / integration-macros.yaml
1 - parameter:
2     name: integration-branch
3     parameters:
4         - string:
5             name: BRANCH
6             default: '{branch}'
7             description: 'Distribution GIT branch'
8
9 - parameter:
10     name: integration-bundleurl
11     parameters:
12         - string:
13             name: BUNDLEURL
14             default: '{bundleurl}'
15             description: 'URL to karaf distribution zip'
16
17 - parameter:
18     name: integration-jdk-version
19     parameters:
20         - string:
21             name: JDKVERSION
22             default: '{jdkversion}'
23             description: 'Parameter to indicate JAVA Version'
24
25 - parameter:
26     name: integration-controller-scope
27     parameters:
28         - string:
29             name: CONTROLLERSCOPE
30             default: '{controller-scope}'
31             description: 'Feature Only or Feature All test'
32
33 - parameter:
34     name: integration-controller-features
35     parameters:
36         - string:
37             name: CONTROLLERFEATURES
38             default: '{controller-features}'
39             description: 'Features to install in the controller separated by comma'
40
41 - parameter:
42     name: integration-distribution-stream
43     parameters:
44         - string:
45             name: DISTROSTREAM
46             default: '{stream}'
47             description: 'Distribution stream string, for suites to know which behavior to expect'
48
49 - parameter:
50     name: integration-stream-test-plan
51     parameters:
52         - string:
53             name: STREAMTESTPLAN
54             default: '{stream-test-plan}'
55             description: 'Stream-specific test plan we will run'
56
57 - parameter:
58     name: integration-test-plan
59     parameters:
60         - string:
61             name: TESTPLAN
62             default: '{test-plan}'
63             description: 'General test plan we will run unless stream-specific one is found'
64
65 - parameter:
66     name: integration-test-options
67     parameters:
68         - string:
69             name: TESTOPTIONS
70             default: '{test-options}'
71             description: 'Robot command options'
72
73 - parameter:
74     name: integration-distribution-git-url
75     parameters:
76         - string:
77             name: DISTROGITURL
78             default: 'ssh://jenkins-$SILO@git.opendaylight.org:29418/integration/distribution'
79             description: 'Distribution GIT URL (do not modify)'
80
81 - parameter:
82     name: integration-patch-refspec
83     parameters:
84         - string:
85             name: PATCHREFSPEC
86             default: '{branch}'
87             description: 'Integration Patch Refspec'
88
89 # Macro: integration-gerrit-scm
90 # Operation: this macro downloads a project gerrit
91 # Used by: all csit jobs
92
93 - scm:
94     name: integration-gerrit-scm
95     scm:
96         - git:
97             credentials-id: 'opendaylight-jenkins-ssh'
98             url: '$GIT_BASE'
99             basedir: '{basedir}'
100             refspec: '{refspec}'
101             branches:
102                 - 'origin/{branch}'
103             skip-tag: true
104             choosing-strategy: 'gerrit'
105
106 # Macro: integration-distribution-scm
107 # Operation: this macro downloads the integration/distribution repo using distribution as basedir
108 # Used by: integration-patch-test-{stream} job template
109
110 - scm:
111     name: integration-distribution-scm
112     scm:
113         - git:
114             credentials-id: 'opendaylight-jenkins-ssh'
115             basedir: 'distribution'
116             url: '$DISTROGITURL'
117             refspec: ''
118             branches:
119                 - 'origin/{branch}'
120             skip-tag: true
121
122 # Macro: integration-trigger-patch-submitted
123 # This is a single macro to use for all csit jobs who vote on every (relevant) patch set.
124 # Only 'recheck' trigger word is supported, it always triggers the full set of relevant jobs,
125 # in order to prevent Jenkins from starting only a subset and still voting Verified+1.
126 # Contrary to gerrit-trigger-patch-submitted, this votes +1 also on unstable runs.
127 # Arguments:
128 #     server: name of gerrit server to listen to
129 #     project: pattern to match triggering projects
130 #     branch: triggering branch name
131 #     files: pattern to match triggering filepaths
132 - trigger:
133     name: integration-trigger-patch-submitted
134     triggers:
135         - gerrit:
136             server-name: '{server}'
137             trigger-on:
138                 - patchset-created-event:
139                     exclude-drafts: 'true'
140                     exclude-trivial-rebase: 'false'
141                     exclude-no-code-change: 'true'
142                 - draft-published-event
143                 - comment-added-contains-event:
144                     comment-contains-value: 'recheck'
145             override-votes: true
146             gerrit-build-unstable-verified-value: +1
147             gerrit-build-unstable-codereview-value: 0
148             projects:
149                 - project-compare-type: 'ANT'
150                   project-pattern: '{project}'
151                   branches:
152                       - branch-compare-type: 'ANT'
153                         branch-pattern: '**/{branch}'
154                   file-paths:
155                       - compare-type: 'ANT'
156                         pattern: '{files}'
157
158 # Macro: integration-csit-only
159 # Operation: this macro sets a trigger on reverse job list
160 # Used by: csit -only- job templates
161
162 - trigger:
163     name: integration-csit-only
164     triggers:
165         - reverse:
166             jobs: '{jobs}'
167             result: 'success'
168
169 # Macro: integration-csit-all
170 # Operation: this macro sets a periodic trigger
171 # Used by: csit -all- job teamplates
172
173 - trigger:
174     name: integration-csit-all
175     triggers:
176         - timed: 'H H * * *'
177
178 # Macro: integration-jclouds-controller-mininet
179 # Operation: this macro will spin the controller and mininet vms
180 # Used by: {project}-csit-* job templates
181
182 - wrapper:
183     name: integration-jclouds-controller-mininet
184     wrappers:
185       - jclouds:
186           instances:
187             - '{controller-image}':
188                 cloud-name: 'ODLPUB'
189                 count: '{controller-vms}'
190             - '{mininet-image}':
191                 cloud-name: 'ODLPUB'
192                 count: '{mininet-vms}'
193
194 # Macro: integration-openstack-controller-mininet
195 # Operation: this macro will spin the controller and mininet vms
196 # Used by: {project}-csit-* job templates
197
198 - wrapper:
199     name: integration-openstack-controller-mininet
200     wrappers:
201       - openstack:
202           instances:
203             - cloud-name: 'ODLRPC'
204               template-name: '{controller-image}'
205               count: '{controller-vms}'
206             - cloud-name: 'ODLRPC'
207               template-name: '{mininet-image}'
208               count: '{mininet-vms}'
209
210 # Macro: integration-jclouds-controller-devstack
211 # Operation: this macro will spin the controller and devstack vms
212 # Used by: {project}-csit-openstack job templates
213 - wrapper:
214     name: integration-jclouds-controller-devstack
215     wrappers:
216       - jclouds:
217           instances:
218             - '{controller-image}':
219                 cloud-name: 'ODLPUB'
220                 count: '{controller-vms}'
221             - '{openstack-image}':
222                 cloud-name: 'ODLPUB'
223                 count: '{openstack-vms}'
224
225 # Macro: integration-openstack-controller-devstack
226 # Operation: this macro will spin the controller and devstack vms
227 # Used by: {project}-csit-openstack job templates
228 - wrapper:
229     name: integration-openstack-controller-devstack
230     wrappers:
231       - openstack:
232           instances:
233             - cloud-name: 'ODLRPC'
234               template-name: '{controller-image}'
235               count: '{controller-vms}'
236             - cloud-name: 'ODLRPC'
237               template-name: '{openstack-image}'
238               count: '{openstack-vms}'
239
240 # Macro: integration-jclouds-controller-docker
241 # Operation: this macro will sping the controller and docker vms
242 # Used by: {project}-csit-docker job templates
243 - wrapper:
244     name: integration-jclouds-controller-docker
245     wrappers:
246       - jclouds:
247           instances:
248             - '{controller-image}':
249                 cloud-name: 'ODLPUB'
250                 count: '{controller-vms}'
251             - '{docker-image}':
252                 cloud-name: 'ODLPUB'
253                 count: '{docker-vms}'
254
255 #################
256 # Shell Scripts #
257 #################
258
259 # Macro: integration-copy-ssh-keys
260 # Operation: Copy ssh public key used as authentication for robot
261 # Used by: {project}-csit-* job templates
262
263 - builder:
264     name: integration-copy-ssh-keys
265     builders:
266         - shell: |
267             #!/bin/bash
268             function copy-ssh-keys-to-slave() {
269                 RETRIES=60
270                 for j in $(seq 1 $RETRIES); do
271                     if `ssh-copy-id -i /home/jenkins/.ssh/id_rsa.pub "jenkins@${i}" > /dev/null 2>&1`; then
272                         ssh jenkins@${i} 'echo "$(facter ipaddress_eth0) $(/bin/hostname)" | sudo tee -a /etc/hosts'
273                         echo "Successfully copied public keys to slave ${i}"
274                         break
275                     elif [ $j -eq $RETRIES ]; then
276                         echo "SSH not responding on ${i} after $RETIRES tries. Giving up."
277                         exit 1
278                     else
279                         echo "SSH not responding on ${i}. Retrying in 10 seconds..."
280                         sleep 10
281                     fi
282                 done
283             }
284
285             echo "OpenStack IPS are ${JCLOUDS_IPS}"
286
287             IFS=',' read -ra ADDR <<< "${JCLOUDS_IPS}"
288             pids=""
289             for i in "${ADDR[@]}"; do
290                 ( copy-ssh-keys-to-slave ) &
291                 # Store PID of process
292                 pids+=" $!"
293             done
294
295             # Detect when a process failed to copy ssh keys and fail build
296             for p in $pids; do
297                 if wait $p; then
298                     echo "Process $p successfully copied ssh keys."
299                 else
300                     echo "Process $p failed to copy ssh keys."
301                     exit 1
302                 fi
303             done
304             echo "Copying ssh keys complete."
305
306 # Macro: integration-get-slave-addresses
307 # Operation: this macro gets the IP addresses of the dynamic vms
308 # Used by: {project}-csit-* job templates
309
310 - builder:
311     name: integration-get-slave-addresses
312     builders:
313         - shell:
314             !include-raw:
315                 - include-raw-integration-get-slave-addresses.sh
316
317 # Macro: integration-get-bundle-vars
318 # Operation: this macro gets all bundle related variables
319 # Used by: {project}-csit-3node-* job templates
320
321 - builder:
322     name: integration-get-bundle-vars
323     builders:
324         - shell:
325             !include-raw:
326                 - include-raw-integration-get-bundle-vars.sh
327
328 # Macro: integration-distribution-check
329 # Operation: this macro deploys the controller with all fetures
330 # Used by: {project}-distribution-check-{stream} job template
331
332 - builder:
333     name: integration-distribution-check
334     builders:
335         - shell:
336             !include-raw:
337                 - include-raw-integration-distribution-check.sh
338
339 # Macro: integration-deploy-controller-verify
340 # Operation: this macro deploys the controller with all fetures
341 # Used by: integration-distribution-deploy-{stream} job template
342
343 - builder:
344     name: integration-deploy-controller-verify
345     builders:
346         - shell:
347             !include-raw:
348                 - include-raw-integration-deploy-controller-verify.sh
349
350 # Macro: integration-deploy-controller-offline
351 # Operation: this macro deploys the controller with no external repo configuration
352 # Used by: integration-distrbution-offline-{stream} job template
353
354 - builder:
355     name: integration-deploy-controller-offline
356     builders:
357         - shell:
358             !include-raw:
359                 - include-raw-integration-deploy-controller-offline.sh
360
361 # Macro: integration-deply-controller-run-test
362 # Operation: this macro deploys single contoller and runs test
363 # Used by: {project}-csit-1node-* job templates
364
365 - builder:
366     name: integration-deploy-controller-run-test
367     builders:
368         - shell:
369             !include-raw:
370                 - include-raw-integration-deploy-controller-run-test.sh
371
372 # Macro: integration-configure-clustering
373 # Operation: this macro configures the clustering
374 # Used by: {project}-csit-3node-* job templates
375
376 - builder:
377     name: integration-configure-clustering
378     builders:
379         - shell:
380             !include-raw:
381                 - include-raw-integration-configure-clustering.sh
382
383 # Macro: integration-start-cluster-run-test
384 # Operation: this macro starts the 3-node cluster and runs test
385 # Used by: {project}-csit-3node-* job templates
386
387 - builder:
388     name: integration-start-cluster-run-test
389     builders:
390         - shell:
391             !include-raw:
392                 - include-raw-integration-start-cluster-run-test.sh
393
394 # Macro: integration-get-bundle-url
395 # Operation: this macro gets the job generated distribution URL from distribution pom.xml
396 # Used by: integration-patch-test-{stream} job template
397
398 - builder:
399     name: integration-get-bundle-url
400     builders:
401         - shell:
402             !include-raw:
403                 - include-raw-integration-get-bundle-url.sh
404
405 # Macro: integration-get-bundle-url-root
406 # Operation: this macro gets the job generated distribution URL from root pom.xml
407 # Used by: integration-distribution-verify-{stream} job template
408
409 - builder:
410     name: integration-get-bundle-url-root
411     builders:
412         - shell:
413             !include-raw:
414                 - include-raw-integration-get-bundle-url-root.sh
415
416 # Macro: integration-install-robotframework
417 # Operation: Installs robotframework using pip to a virtualenv
418 # Used by: {project}-csit-* job templates
419
420 - builder:
421     name: integration-install-robotframework
422     builders:
423         - shell:
424             !include-raw:
425                 - include-raw-integration-install-robotframework.sh
426
427 # Macro: integration-cleanup-tmp
428 # Operation: Cleans up temporary files created by build
429 # Used by: {project}-csit-* job templates
430
431 - builder:
432     name: integration-cleanup-tmp
433     builders:
434         - shell:
435             !include-raw:
436                 - include-raw-integration-cleanup-tmp.sh
437
438 # Macro: integration-multipatch-builder
439 # Operation: checks out multiple patches and builds custom distribution
440 # Used by: integration-multipatch-test-* job templates
441
442 - builder:
443     name: integration-multipatch-builder
444     builders:
445         - shell:
446             !include-raw:
447                 - include-raw-integration-multipatch-distribution-test.sh
448
449 # Macro: integration-cleanup-worspace
450 # Operation: Cleans up files possibly left there by the previous build
451 # Used by: {project}-csit-* job templates
452
453 - builder:
454     name: integration-cleanup-workspace
455     builders:
456         - shell:
457             !include-raw:
458                 - include-raw-integration-cleanup-workspace.sh
459
460 # Macro: integration-rebase-patch
461 # Operation: For cloned project, rebase checked-out Gerrit patch onto $BRANCH.
462 # Used by: integration-patch-distribution-* job template
463
464 - builder:
465     name: integration-rebase-gerrit-patch
466     builders:
467         - shell:
468             !include-raw:
469                 - include-raw-integration-rebase-gerrit-patch.sh
470
471 - builder:
472     name: integration-deploy-openstack-run-test
473     builders:
474         - shell:
475             !include-raw:
476                 - include-raw-integration-deploy-openstack-run-test.sh
477 ##############
478 # Publishers #
479 ##############
480
481 # Macro: integration-robot
482 # Operation: this macro publishes robot results
483 # Used by: {project}-csit-* job templates
484
485 - publisher:
486     name: integration-robot
487     publishers:
488         - robot:
489             output-path: ''
490             other-files: ''
491             unstable-threshold: '{unstable-if}'
492             pass-threshold: '{pass-if}'
493             only-critical: false
494
495 - publisher:
496     name: integration-robot-tempest
497     publishers:
498         - robot:
499             output-path: ''
500             other-files:
501                 - tempest_results.html
502             unstable-threshold: '{unstable-if}'
503             pass-threshold: '{pass-if}'
504             only-critical: false
505
506 - publisher:
507     name: integration-csit-archive-build
508     publishers:
509         - postbuildscript:
510             builders:
511                 - shell: |
512                     #!/bin/bash
513                     mkdir -p $WORKSPACE/archives
514                     curl --output robot-plugin.zip "$BUILD_URL/robot/report/*zip*/robot-plugin.zip"
515                     unzip -d $WORKSPACE/archives robot-plugin.zip
516                     mv *log* *.log *.log.gz *.csv *.png $WORKSPACE/archives || true  # Don't fail if file missing
517             script-only-if-succeeded: False
518             script-only-if-failed: False
519             mark-unstable-if-failed: True