create deployment jobs of openstack+odl and openstack_onos
[releng.git] / jjb / compass4nfv / compass4nfv.yml
1 # this is the job configuration for bgs
2 - project:
3
4     name: compass
5
6     installer: 'compass'
7
8     jobs:
9         - 'compass-verify'
10         - 'compass-verify-on-ericsson-node'
11         - 'compass-merge'
12         - 'compass-daily-{stream}'
13         - 'compass-build-iso'
14         - 'compass-build-ppa'
15         - 'compass-deploy-virtual-{flavor}'
16
17     # stream:    branch with - in place of / (eg. stable-helium)
18     # branch:    branch (eg. stable/helium)
19     stream:
20         - master:
21             branch: 'master'
22
23     flavor:
24         - cluster-odl:
25             conf: 'virtual_cluster_odl'
26             node: 'huawei-deploy-vm'
27         - cluster-onos:
28             conf: 'virtual_cluster_onos'
29             node: 'huawei-deploy-vm'
30         - cluster:
31             conf: 'virtual_cluster'
32             node: 'huawei-build'
33
34
35
36     project: 'compass4nfv'
37
38 ########################
39 # job templates
40 ########################
41 - job-template:
42     name: 'compass-verify-on-ericsson-node'
43
44     project-type: freestyle
45
46     disabled: true
47
48     node: ericsson-build
49
50     logrotate:
51         daysToKeep: 30
52         numToKeep: 10
53         artifactDaysToKeep: -1
54         artifactNumToKeep: -1
55
56     parameters:
57         - project-parameter:
58             project: '{project}'
59         - gerrit-parameter:
60             branch: 'master'
61         - compass-parameter:
62             installer: '{installer}'
63
64     scm:
65         - gerrit-trigger-scm:
66             credentials-id: '{ssh-credentials}'
67             refspec: '$GERRIT_REFSPEC'
68             choosing-strategy: 'gerrit'
69
70     wrappers:
71         - ssh-agent-credentials:
72             user: '{ssh-credentials}'
73
74     triggers:
75         - gerrit:
76             trigger-on:
77                 - patchset-created-event:
78                     exclude-drafts: 'false'
79                     exclude-trivial-rebase: 'false'
80                     exclude-no-code-change: 'false'
81                 - draft-published-event
82                 - comment-added-contains-event:
83                     comment-contains-value: 'recheck'
84                 - comment-added-contains-event:
85                     comment-contains-value: 'reverify'
86             projects:
87               - project-compare-type: 'ANT'
88                 project-pattern: '{project}'
89                 branches:
90                   - branch-compare-type: 'ANT'
91                     branch-pattern: '**/master'
92                 forbidden-file-paths:
93                   - compare-type: ANT
94                     pattern: 'docs/**'
95
96     builders:
97         - 'builder-compass-build-iso'
98         - 'builder-compass-workspace-cleanup'
99
100 - job-template:
101     name: 'compass-verify'
102
103     project-type: freestyle
104
105     disabled: false
106
107     node: huawei-build
108
109     logrotate:
110         daysToKeep: 30
111         numToKeep: 10
112         artifactDaysToKeep: -1
113         artifactNumToKeep: -1
114
115     parameters:
116         - project-parameter:
117             project: '{project}'
118         - gerrit-parameter:
119             branch: 'master'
120         - compass-parameter:
121             installer: '{installer}'
122         - string:
123             name: FLAVOR_CONF
124             default: 'virtual_cluster'
125             description: ""
126     scm:
127         - gerrit-trigger-scm:
128             credentials-id: '{ssh-credentials}'
129             refspec: '$GERRIT_REFSPEC'
130             choosing-strategy: 'gerrit'
131
132     wrappers:
133         - ssh-agent-credentials:
134             user: '{ssh-credentials}'
135
136     triggers:
137         - gerrit:
138             trigger-on:
139                 - patchset-created-event:
140                     exclude-drafts: 'false'
141                     exclude-trivial-rebase: 'false'
142                     exclude-no-code-change: 'false'
143                 - draft-published-event
144                 - comment-added-contains-event:
145                     comment-contains-value: 'recheck'
146                 - comment-added-contains-event:
147                     comment-contains-value: 'reverify'
148             projects:
149               - project-compare-type: 'ANT'
150                 project-pattern: '{project}'
151                 branches:
152                   - branch-compare-type: 'ANT'
153                     branch-pattern: '**/master'
154                 forbidden-file-paths:
155                   - compare-type: ANT
156                     pattern: 'docs/**'
157
158     builders:
159         - 'builder-compass-build-iso'
160         - 'builder-compass-deploy-virtual-flavor'
161     publishers:
162         - archive:
163             artifacts: 'ansible.log'
164             allow-empty: 'true'
165             fingerprint: true
166
167 - job-template:
168     name: 'compass-merge'
169
170     # builder-merge job to run JJB update
171     #
172     # This job's purpose is to update all the JJB
173
174     project-type: freestyle
175
176     node: huawei-build
177
178     logrotate:
179         daysToKeep: 30
180         numToKeep: 40
181         artifactDaysToKeep: -1
182         artifactNumToKeep: 5
183
184     parameters:
185         - project-parameter:
186             project: '{project}'
187         - gerrit-parameter:
188             branch: 'master'
189         - compass-parameter:
190             installer: '{installer}'
191
192     scm:
193         - gerrit-trigger-scm:
194             credentials-id: '{ssh-credentials}'
195             refspec: ''
196             choosing-strategy: 'default'
197
198     wrappers:
199         - ssh-agent-credentials:
200             user: '{ssh-credentials}'
201
202     triggers:
203         - gerrit:
204             trigger-on:
205                 - change-merged-event
206                 - comment-added-contains-event:
207                     comment-contains-value: 'remerge'
208             projects:
209               - project-compare-type: 'ANT'
210                 project-pattern: '{project}'
211                 branches:
212                     - branch-compare-type: 'ANT'
213                       branch-pattern: '**/master'
214
215     builders:
216         - 'builder-compass-merge'
217
218 - job-template:
219     name: 'compass-daily-{stream}'
220
221     project-type: freestyle
222
223     node: huawei-build
224
225     parameters:
226         - project-parameter:
227             project: '{project}'
228         - compass-parameter:
229             installer: '{installer}'
230
231     scm:
232         - git-scm:
233             credentials-id: '{ssh-credentials}'
234             refspec: ''
235             branch: '{branch}'
236
237     triggers:
238         - timed: '@midnight'
239
240     logrotate:
241         daysToKeep: 30
242         numToKeep: 10
243         artifactDaysToKeep: -1
244         artifactNumToKeep: -1
245
246     builders:
247         - trigger-builds:
248           - project: 'compass-build-iso'
249             git-revision: true
250             block: true
251         - trigger-builds:
252           - project: 'compass-deploy-virtual-cluster'
253             git-revision: true
254             block: true
255         - trigger-builds:
256           - project: 'compass-deploy-virtual-cluster-odl'
257             git-revision: true
258             block: true
259         - trigger-builds:
260           - project: 'compass-deploy-virtual-cluster-onos'
261             git-revision: true
262             block: true
263
264 - job-template:
265     name: 'compass-build-iso'
266
267     project-type: freestyle
268
269     node: ericsson-build
270
271     logrotate:
272         daysToKeep: 30
273         numToKeep: 10
274         artifactDaysToKeep: -1
275         artifactNumToKeep: -1
276
277     parameters:
278         - project-parameter:
279             project: '{project}'
280         - compass-parameter:
281             installer: '{installer}'
282
283     scm:
284         - git-scm:
285             credentials-id: '{ssh-credentials}'
286             refspec: ''
287             branch: 'master'
288
289     builders:
290         - 'builder-compass-build-iso'
291         - 'builder-compass-upload-artifact'
292         - 'builder-compass-workspace-cleanup'
293
294 - job-template:
295     name: 'compass-build-ppa'
296
297     description: "build ppa(using docker) in huawei lab"
298
299     project-type: freestyle
300
301     node: huawei-build
302
303     logrotate:
304         daysToKeep: 30
305         numToKeep: 10
306         artifactDaysToKeep: -1
307         artifactNumToKeep: -1
308
309     parameters:
310         - project-parameter:
311             project: '{project}'
312         - compass-parameter:
313             installer: '{installer}'
314
315     scm:
316         - git-scm:
317             credentials-id: '{ssh-credentials}'
318             refspec: ''
319             branch: 'master'
320
321     triggers:
322         - timed: 'H 16 * * *'
323
324     builders:
325         - 'builder-compass-make-ppa'
326
327 - job-template:
328     name: 'compass-deploy-virtual-{flavor}'
329
330     project-type: freestyle
331
332     disabled: false
333
334     node: '{node}'
335
336     parameters:
337         - project-parameter:
338             project: '{project}'
339         - compass-parameter:
340             installer: '{installer}'
341         - string:
342             name: FLAVOR_CONF
343             default: '{conf}'
344             description: ""
345
346
347     logrotate:
348         daysToKeep: 30
349         numToKeep: 10
350         artifactDaysToKeep: -1
351         artifactNumToKeep: -1
352
353
354     builders:
355         - 'builder-compass-ci-preclean-workspace'
356         - 'builder-compass-download-artifact'
357         - 'builder-compass-deploy-virtual-flavor'
358     publishers:
359         - archive:
360             artifacts: 'ansible.log'
361             allow-empty: 'true'
362             fingerprint: true
363
364 ########################
365 # parameter macros
366 ########################
367 - parameter:
368     name: compass-parameter
369     parameters:
370         - string:
371             name: INSTALLER
372             default: '{installer}'
373             description: "Installer to use."
374         - string:
375             name: BUILD_DIRECTORY
376             default: $WORKSPACE/build_output
377             description: "Directory where the build artifact will be located upon the completion of the build."
378         - string:
379             name: CACHE_DIRECTORY
380             default: $HOME/opnfv/cache/$PROJECT
381             description: "Directory where the cache to be used during the build is located."
382         - string:
383             name: GIT_BASE
384             default: https://gerrit.opnfv.org/gerrit/$PROJECT
385             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
386         - string:
387             name: GS_URL
388             default: artifacts.opnfv.org/$PROJECT/
389             description: "URL to Google Storage."
390         - string:
391             name: GS_URL_PROXY
392             default: build.opnfv.org/artifacts/$PROJECT/
393             description: "URL to Google Storage proxy"
394         - string:
395             name: installer_ip
396             default: "10.1.0.12"
397         - string:
398             name: PPA_REPO
399             default: "http://58.251.166.184:9999"
400         - string:
401             name: PPA_CACHE
402             default: "$WORKSPACE/work/repo/"
403
404 ########################
405 # builder macros
406 ########################
407 - builder:
408     name: 'builder-compass-merge'
409     builders:
410         - shell: |
411             #!/bin/bash
412             echo "Hello World!"
413
414 - builder:
415     name: 'builder-compass-make-ppa'
416     builders:
417         - shell: |
418             #!/bin/bash
419             set -x
420             set -o errexit
421             set -o nounset
422             set -o pipefail
423             # make ppa
424             cd $WORKSPACE/
425             ./build/make_repo.sh
426             # calc MD5 of ppa
427             cd $PPA_CACHE
428             for i in $(find *.gz *.iso *.img -type f)
429             do
430                 md5=$(md5sum $i | cut -d ' ' -f1)
431                 echo $md5 > $i.md5
432                 curl -T $i $PPA_REPO
433                 curl -T $i.md5 $PPA_REPO
434             done
435
436 - builder:
437     name: 'builder-compass-build-iso'
438     builders:
439         - shell: |
440             #!/bin/bash
441             set -o errexit
442             set -o nounset
443             set -o pipefail
444
445             # log info to console
446             echo "Starting the build of $INSTALLER. This could take some time..."
447             echo "--------------------------------------------------------"
448             echo
449
450             # create the cache directory if it doesn't exist
451             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
452             [[ -d $BUILD_DIRECTORY ]] || mkdir -p $BUILD_DIRECTORY
453
454             # set OPNFV_ARTIFACT_VERSION
455             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
456
457             # start the build
458             if [ -d $PPA_CACHE ]
459             then
460                 cp $PPA_CACHE/*.tar.gz $PPA_CACHE/*.iso $PPA_CACHE/*.img $CACHE_DIRECTORY/ -f
461             fi
462
463             cd $WORKSPACE/
464             ./build.sh  --iso-dir $BUILD_DIRECTORY/ --iso-name compass.iso -c $CACHE_DIRECTORY
465
466             # list the build artifacts
467             ls -al $BUILD_DIRECTORY
468
469             # save information regarding artifact into file
470             (
471                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
472                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
473                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
474                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
475                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/compass.iso | cut -d' ' -f1)"
476                 echo "OPNFV_BUILD_URL=$BUILD_URL"
477             ) > $BUILD_DIRECTORY/opnfv.properties
478             echo
479             echo "--------------------------------------------------------"
480             echo "Done!"
481
482 - builder:
483     name: 'builder-compass-deploy-virtual-flavor'
484     builders:
485         - shell: |
486             #!/bin/bash
487             set -x
488
489             # log info to console
490             echo "Starting the deployment on virtual environment using $INSTALLER. This could take some time..."
491             echo "--------------------------------------------------------"
492             echo
493
494             export ISO_URL=file://$BUILD_DIRECTORY/compass.iso
495             cd $WORKSPACE
496
497             ./deploy.sh $FLAVOR_CONF
498             if [ $? -ne 0 ]; then
499                 echo "depolyment failed!"
500                 deploy_ret=1
501             fi
502
503             echo
504             echo "--------------------------------------------------------"
505             echo "Done!"
506
507             ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
508             sshpass -p root scp 2>/dev/null $ssh_options root@${installer_ip}:/var/ansible/run/openstack_juno-opnfv2/ansible.log ./  &> /dev/null
509
510             exit $deploy_ret
511
512
513 - builder:
514     name: 'builder-compass-upload-artifact'
515     builders:
516         - shell: |
517             #!/bin/bash
518             set -o errexit
519             set -o nounset
520             set -o pipefail
521
522             # log info to console
523             echo "Uploading the $INSTALLER artifact. This could take some time..."
524             echo "--------------------------------------------------------"
525             echo
526
527             # source the opnfv.properties to get ARTIFACT_VERSION
528             source $BUILD_DIRECTORY/opnfv.properties
529
530             # upload artifact and additional files to google storage
531             gsutil cp $BUILD_DIRECTORY/compass.iso gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
532             gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
533             gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
534
535
536             echo
537             echo "--------------------------------------------------------"
538             echo "Done!"
539             echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
540
541 - builder:
542     name: 'builder-compass-download-artifact'
543     builders:
544         - shell: |
545             #!/bin/bash
546             set -o errexit
547             set -o nounset
548             set -o pipefail
549
550             # log info to console
551             echo "Downloading the $INSTALLER artifact. This could take some time..."
552             echo "--------------------------------------------------------"
553             echo
554
555             # get the latest.properties file in order to get info regarding latest artifact
556             [[ -d $BUILD_DIRECTORY ]] || mkdir -p $BUILD_DIRECTORY
557             curl -s -o $BUILD_DIRECTORY/latest.properties http://$GS_URL/latest.properties
558
559             # check if we got the file
560             [[ -f $BUILD_DIRECTORY/latest.properties ]] || exit 1
561
562             # source the file so we get OPNFV vars
563             source $BUILD_DIRECTORY/latest.properties
564
565             # download the file
566             curl -s -o $BUILD_DIRECTORY/compass.iso http://$OPNFV_ARTIFACT_URL > gsutil.iso.log 2>&1
567
568             # list the file
569             ls -al $BUILD_DIRECTORY/compass.iso
570
571             echo
572             echo "--------------------------------------------------------"
573             echo "Done!"
574
575 - builder:
576     name: 'builder-compass-workspace-cleanup'
577     builders:
578         - shell: |
579             #!/bin/bash
580             set -o errexit
581             set -o nounset
582             set -o pipefail
583
584             # delete everything that is in $WORKSPACE
585             /bin/rm -rf $WORKSPACE
586
587 - builder:
588     name: 'builder-compass-ci-preclean-workspace'
589     builders:
590         - shell: |
591             #!/bin/bash
592             set -o errexit
593             set -o nounset
594             set -o pipefail
595
596             cd $WORKSPACE/..
597             sudo rm $WORKSPACE -rf
598             git clone $GIT_BASE  $WORKSPACE
599