bugfix: a wrong statement of calculating md5
[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'
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 #        - 'builder-compass-backup-logs'
159 #    publishers:
160 #        - archive:
161 #            artifacts: 'ansible.log'
162 #            allow-empty: 'true'
163 #            fingerprint: true
164
165 - job-template:
166     name: 'compass-merge'
167
168     # builder-merge job to run JJB update
169     #
170     # This job's purpose is to update all the JJB
171
172     project-type: freestyle
173
174     node: huawei-build
175
176     logrotate:
177         daysToKeep: 30
178         numToKeep: 40
179         artifactDaysToKeep: -1
180         artifactNumToKeep: 5
181
182     parameters:
183         - project-parameter:
184             project: '{project}'
185         - gerrit-parameter:
186             branch: 'master'
187         - compass-parameter:
188             installer: '{installer}'
189
190     scm:
191         - gerrit-trigger-scm:
192             credentials-id: '{ssh-credentials}'
193             refspec: ''
194             choosing-strategy: 'default'
195
196     wrappers:
197         - ssh-agent-credentials:
198             user: '{ssh-credentials}'
199
200     triggers:
201         - gerrit:
202             trigger-on:
203                 - change-merged-event
204                 - comment-added-contains-event:
205                     comment-contains-value: 'remerge'
206             projects:
207               - project-compare-type: 'ANT'
208                 project-pattern: '{project}'
209                 branches:
210                     - branch-compare-type: 'ANT'
211                       branch-pattern: '**/master'
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         - pollscm: '@midnight'
236
237     logrotate:
238         daysToKeep: 30
239         numToKeep: 10
240         artifactDaysToKeep: -1
241         artifactNumToKeep: -1
242
243     builders:
244         #- 'builder-compass-build-iso'
245         #- 'builder-compass-upload-artifact'
246         #- 'builder-compass-workspace-cleanup'
247         - shell: |
248             echo "Hello world!"
249             echo "compass-deploy-virtual job will be triggered!"
250
251     publishers:
252         - trigger:
253             project: 'compass-build'
254             threshold: SUCCESS
255         - trigger:
256             project: 'compass-deploy-virtual-cluster'
257             threshold: SUCCESS
258
259 - job-template:
260     name: 'compass-build-iso'
261
262     project-type: freestyle
263
264     node: ericsson-build
265
266     logrotate:
267         daysToKeep: 30
268         numToKeep: 10
269         artifactDaysToKeep: -1
270         artifactNumToKeep: -1
271
272     parameters:
273         - project-parameter:
274             project: '{project}'
275         - compass-parameter:
276             installer: '{installer}'
277
278     scm:
279         - git-scm:
280             credentials-id: '{ssh-credentials}'
281             refspec: ''
282             branch: 'master'
283
284     builders:
285         - 'builder-compass-build-iso'
286         - 'builder-compass-upload-artifact'
287         - 'builder-compass-workspace-cleanup'
288
289 - job-template:
290     name: 'compass-build'
291
292     description: "build ppa(using docker) in huawei lab"
293
294     project-type: freestyle
295
296     node: huawei-build
297
298     logrotate:
299         daysToKeep: 30
300         numToKeep: 10
301         artifactDaysToKeep: -1
302         artifactNumToKeep: -1
303
304     parameters:
305         - project-parameter:
306             project: '{project}'
307         - compass-parameter:
308             installer: '{installer}'
309
310     scm:
311         - git-scm:
312             credentials-id: '{ssh-credentials}'
313
314             refspec: ''
315             branch: 'master'
316
317     builders:
318         - 'builder-compass-make-ppa'
319         - trigger-builds:
320           - project: 'compass-build-iso'
321             git-revision: true
322             block: true
323
324 - job-template:
325     name: 'compass-deploy-virtual-{flavor}'
326
327     project-type: freestyle
328
329     disabled: false
330
331     node: '{node}'
332
333     parameters:
334         - project-parameter:
335             project: '{project}'
336         - compass-parameter:
337             installer: '{installer}'
338         - string:
339             name: FLAVOR_CONF
340             default: '{conf}'
341             description: ""
342
343     triggers:
344         - pollscm: "H/2 * * * *"
345
346     logrotate:
347         daysToKeep: 30
348         numToKeep: 10
349         artifactDaysToKeep: -1
350         artifactNumToKeep: -1
351
352     builders:
353         - 'builder-compass-ci-preclean-workspace'
354         - 'builder-compass-download-artifact'
355         - 'builder-compass-deploy-virtual-flavor'
356         - 'builder-compass-backup-logs'
357     publishers:
358         - archive:
359             artifacts: 'ansible.log'
360             allow-empty: 'true'
361             fingerprint: true
362
363 ########################
364 # parameter macros
365 ########################
366 - parameter:
367     name: compass-parameter
368     parameters:
369         - string:
370             name: INSTALLER
371             default: '{installer}'
372             description: "Installer to use."
373         - string:
374             name: BUILD_DIRECTORY
375             default: $WORKSPACE/build_output
376             description: "Directory where the build artifact will be located upon the completion of the build."
377         - string:
378             name: CACHE_DIRECTORY
379             default: $HOME/opnfv/cache/$PROJECT
380             description: "Directory where the cache to be used during the build is located."
381         - string:
382             name: GIT_BASE
383             default: https://gerrit.opnfv.org/gerrit/$PROJECT
384             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
385         - string:
386             name: GS_URL
387             default: artifacts.opnfv.org/$PROJECT/
388             description: "URL to Google Storage."
389         - string:
390             name: GS_URL_PROXY
391             default: build.opnfv.org/artifacts/$PROJECT/
392             description: "URL to Google Storage proxy"
393         - string:
394             name: INTERNAL_REPO_XA
395             default: "root@192.168.127.11:~/xh/work/build/work"
396             description: "Artifact Repository"
397
398         - string:
399             name: installer_ip
400             default: "10.1.0.12"
401         - string:
402             name: PPA_REPO
403             default: "http://58.251.166.184:9999"
404         - string:
405             name: PPA_CACHE
406             default: "$WORKSPACE/work/repo/"
407
408 ########################
409 # builder macros
410 ########################
411 - builder:
412     name: 'builder-compass-merge'
413     builders:
414         - shell: |
415             #!/bin/bash
416             echo "Hello World!"
417
418 - builder:
419     name: 'builder-compass-make-ppa'
420     builders:
421         - shell: |
422             #!/bin/bash
423             set -x
424             set -o errexit
425             set -o nounset
426             set -o pipefail
427             # make ppa
428             cd $WORKSPACE/
429             ./build/make_repo.sh
430             # calc MD5 of ppa
431             cd $PPA_CACHE
432             for i in `find *.gz *.iso *.img -type f`
433             do
434                 md5=`md5sum $i | cut -d ' ' -f1`
435                 echo $md5 > $i.md5
436             done
437             # upload PPA
438             for i in `find *.* -type f`
439             do
440                 curl -T $i $PPA_REPO
441             done
442
443 - builder:
444     name: 'builder-compass-build-iso'
445     builders:
446         - shell: |
447             #!/bin/bash
448             set -o errexit
449             set -o nounset
450             set -o pipefail
451
452             # log info to console
453             echo "Starting the build of $INSTALLER. This could take some time..."
454             echo "--------------------------------------------------------"
455             echo
456
457             # create the cache directory if it doesn't exist
458             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
459             [[ -d $BUILD_DIRECTORY ]] || mkdir -p $BUILD_DIRECTORY
460
461             # set OPNFV_ARTIFACT_VERSION
462             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
463
464             # start the build
465             if [ -d $PPA_CACHE ]
466             then
467                 cp $PPA_CACHE/*.tar.gz $PPA_CACHE/*.iso $PPA_CACHE/*.img $CACHE_DIRECTORY/ -f
468             fi
469
470             cd $WORKSPACE/
471             ./build.sh  --iso-dir $BUILD_DIRECTORY/ --iso-name compass.iso -c $CACHE_DIRECTORY
472
473             # list the build artifacts
474             ls -al $BUILD_DIRECTORY
475
476             # save information regarding artifact into file
477             (
478                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
479                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
480                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
481                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
482                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/compass.iso | cut -d' ' -f1)"
483                 echo "OPNFV_BUILD_URL=$BUILD_URL"
484             ) > $BUILD_DIRECTORY/opnfv.properties
485             echo
486             echo "--------------------------------------------------------"
487             echo "Done!"
488
489 - builder:
490     name: 'builder-compass-deploy-virtual-flavor'
491     builders:
492         - shell: |
493             #!/bin/bash
494             set -o errexit
495             set -o nounset
496             set -o pipefail
497             set -x
498
499             # log info to console
500             echo "Starting the deployment on virtual environment using $INSTALLER. This could take some time..."
501             echo "--------------------------------------------------------"
502             echo
503
504             export ISO_URL=file://$BUILD_DIRECTORY/compass.iso
505             cd $WORKSPACE
506             ./deploy.sh $FLAVOR_CONF
507
508             echo
509             echo "--------------------------------------------------------"
510             echo "Done!"
511
512 - builder:
513     name: 'builder-compass-upload-artifact'
514     builders:
515         - shell: |
516             #!/bin/bash
517             set -o errexit
518             set -o nounset
519             set -o pipefail
520
521             # log info to console
522             echo "Uploading the $INSTALLER artifact. This could take some time..."
523             echo "--------------------------------------------------------"
524             echo
525
526             # source the opnfv.properties to get ARTIFACT_VERSION
527             source $BUILD_DIRECTORY/opnfv.properties
528
529             # upload artifact and additional files to google storage
530             gsutil cp $BUILD_DIRECTORY/compass.iso gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
531             gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
532             gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
533
534
535             echo
536             echo "--------------------------------------------------------"
537             echo "Done!"
538             echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
539
540 - builder:
541     name: 'builder-compass-download-artifact'
542     builders:
543         - shell: |
544             #!/bin/bash
545             set -o errexit
546             set -o nounset
547             set -o pipefail
548
549             # log info to console
550             echo "Downloading the $INSTALLER artifact. This could take some time..."
551             echo "--------------------------------------------------------"
552             echo
553
554             # get the latest.properties file in order to get info regarding latest artifact
555             curl -s -o $WORKSPACE/latest.properties http://$GS_URL/latest.properties
556
557             # check if we got the file
558             [[ -f latest.properties ]] || exit 1
559
560             # source the file so we get OPNFV vars
561             source latest.properties
562
563             # download the file
564             curl -s -o $WORKSPACE/compass.iso http://$OPNFV_ARTIFACT_URL > gsutil.iso.log 2>&1
565
566             # list the file
567             ls -al $WORKSPACE/compass.iso
568
569             echo
570             echo "--------------------------------------------------------"
571             echo "Done!"
572
573 - builder:
574     name: 'builder-compass-workspace-cleanup'
575     builders:
576         - shell: |
577             #!/bin/bash
578             set -o errexit
579             set -o nounset
580             set -o pipefail
581
582             # delete everything that is in $WORKSPACE
583             /bin/rm -rf $WORKSPACE
584
585 - builder:
586     name: 'builder-compass-ci-preclean-workspace'
587     builders:
588         - shell: |
589             #!/bin/bash
590             set -o errexit
591             set -o nounset
592             set -o pipefail
593
594             cd $WORKSPACE/..
595             sudo rm $WORKSPACE -rf
596             git clone $GIT_BASE  $WORKSPACE
597
598 - builder:
599     name: 'builder-compass-backup-logs'
600     builders:
601         - shell: |
602             ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
603             sshpass -p root scp 2>/dev/null $ssh_options root@${installer_ip}:/var/ansible/run/openstack_juno-opnfv2/ansible.log ./  &> /dev/null