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