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