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