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