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