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