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