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