add process of building PPA into daily job
[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 #        - '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-iso'
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-ppa'
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             refspec: ''
314             branch: 'master'
315
316     triggers:
317         - timed: 'H 4-18/2 * * *'
318
319     builders:
320         - 'builder-compass-make-ppa'
321
322 - job-template:
323     name: 'compass-deploy-virtual-{flavor}'
324
325     project-type: freestyle
326
327     disabled: false
328
329     node: '{node}'
330
331     parameters:
332         - project-parameter:
333             project: '{project}'
334         - compass-parameter:
335             installer: '{installer}'
336         - string:
337             name: FLAVOR_CONF
338             default: '{conf}'
339             description: ""
340
341     triggers:
342         - pollscm: "H/2 * * * *"
343
344     logrotate:
345         daysToKeep: 30
346         numToKeep: 10
347         artifactDaysToKeep: -1
348         artifactNumToKeep: -1
349
350     builders:
351         - 'builder-compass-ci-preclean-workspace'
352         - 'builder-compass-download-artifact'
353         - 'builder-compass-deploy-virtual-flavor'
354         - 'builder-compass-backup-logs'
355     publishers:
356         - archive:
357             artifacts: 'ansible.log'
358             allow-empty: 'true'
359             fingerprint: true
360
361 ########################
362 # parameter macros
363 ########################
364 - parameter:
365     name: compass-parameter
366     parameters:
367         - string:
368             name: INSTALLER
369             default: '{installer}'
370             description: "Installer to use."
371         - string:
372             name: BUILD_DIRECTORY
373             default: $WORKSPACE/build_output
374             description: "Directory where the build artifact will be located upon the completion of the build."
375         - string:
376             name: CACHE_DIRECTORY
377             default: $HOME/opnfv/cache/$PROJECT
378             description: "Directory where the cache to be used during the build is located."
379         - string:
380             name: GIT_BASE
381             default: https://gerrit.opnfv.org/gerrit/$PROJECT
382             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
383         - string:
384             name: GS_URL
385             default: artifacts.opnfv.org/$PROJECT/
386             description: "URL to Google Storage."
387         - string:
388             name: GS_URL_PROXY
389             default: build.opnfv.org/artifacts/$PROJECT/
390             description: "URL to Google Storage proxy"
391         - string:
392             name: INTERNAL_REPO_XA
393             default: "root@192.168.127.11:~/xh/work/build/work"
394             description: "Artifact Repository"
395
396         - string:
397             name: installer_ip
398             default: "10.1.0.12"
399         - string:
400             name: PPA_REPO
401             default: "http://58.251.166.184:9999"
402         - string:
403             name: PPA_CACHE
404             default: "$WORKSPACE/work/repo/"
405
406 ########################
407 # builder macros
408 ########################
409 - builder:
410     name: 'builder-compass-merge'
411     builders:
412         - shell: |
413             #!/bin/bash
414             echo "Hello World!"
415
416 - builder:
417     name: 'builder-compass-make-ppa'
418     builders:
419         - shell: |
420             #!/bin/bash
421             set -x
422             set -o errexit
423             set -o nounset
424             set -o pipefail
425             # make ppa
426             cd $WORKSPACE/
427             ./build/make_repo.sh
428             # calc MD5 of ppa
429             cd $PPA_CACHE
430             for i in $(find *.gz *.iso *.img -type f)
431             do
432                 md5=$(md5sum $i | cut -d ' ' -f1)
433                 echo $md5 > $i.md5
434             done
435             # upload PPA
436             for i in $(find *.gz *.iso *.img *.md5 -type f)
437             do
438                 curl -T $i $PPA_REPO
439             done
440
441 - builder:
442     name: 'builder-compass-build-iso'
443     builders:
444         - shell: |
445             #!/bin/bash
446             set -o errexit
447             set -o nounset
448             set -o pipefail
449
450             # log info to console
451             echo "Starting the build of $INSTALLER. This could take some time..."
452             echo "--------------------------------------------------------"
453             echo
454
455             # create the cache directory if it doesn't exist
456             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
457             [[ -d $BUILD_DIRECTORY ]] || mkdir -p $BUILD_DIRECTORY
458
459             # set OPNFV_ARTIFACT_VERSION
460             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
461
462             # start the build
463             if [ -d $PPA_CACHE ]
464             then
465                 cp $PPA_CACHE/*.tar.gz $PPA_CACHE/*.iso $PPA_CACHE/*.img $CACHE_DIRECTORY/ -f
466             fi
467
468             cd $WORKSPACE/
469             ./build.sh  --iso-dir $BUILD_DIRECTORY/ --iso-name compass.iso -c $CACHE_DIRECTORY
470
471             # list the build artifacts
472             ls -al $BUILD_DIRECTORY
473
474             # save information regarding artifact into file
475             (
476                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
477                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
478                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
479                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
480                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/compass.iso | cut -d' ' -f1)"
481                 echo "OPNFV_BUILD_URL=$BUILD_URL"
482             ) > $BUILD_DIRECTORY/opnfv.properties
483             echo
484             echo "--------------------------------------------------------"
485             echo "Done!"
486
487 - builder:
488     name: 'builder-compass-deploy-virtual-flavor'
489     builders:
490         - shell: |
491             #!/bin/bash
492             set -o errexit
493             set -o nounset
494             set -o pipefail
495             set -x
496
497             # log info to console
498             echo "Starting the deployment on virtual environment using $INSTALLER. This could take some time..."
499             echo "--------------------------------------------------------"
500             echo
501
502             export ISO_URL=file://$BUILD_DIRECTORY/compass.iso
503             cd $WORKSPACE
504             ./deploy.sh $FLAVOR_CONF
505
506             echo
507             echo "--------------------------------------------------------"
508             echo "Done!"
509
510 - builder:
511     name: 'builder-compass-upload-artifact'
512     builders:
513         - shell: |
514             #!/bin/bash
515             set -o errexit
516             set -o nounset
517             set -o pipefail
518
519             # log info to console
520             echo "Uploading the $INSTALLER artifact. This could take some time..."
521             echo "--------------------------------------------------------"
522             echo
523
524             # source the opnfv.properties to get ARTIFACT_VERSION
525             source $BUILD_DIRECTORY/opnfv.properties
526
527             # upload artifact and additional files to google storage
528             gsutil cp $BUILD_DIRECTORY/compass.iso gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
529             gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
530             gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
531
532
533             echo
534             echo "--------------------------------------------------------"
535             echo "Done!"
536             echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
537
538 - builder:
539     name: 'builder-compass-download-artifact'
540     builders:
541         - shell: |
542             #!/bin/bash
543             set -o errexit
544             set -o nounset
545             set -o pipefail
546
547             # log info to console
548             echo "Downloading the $INSTALLER artifact. This could take some time..."
549             echo "--------------------------------------------------------"
550             echo
551
552             # get the latest.properties file in order to get info regarding latest artifact
553             curl -s -o $WORKSPACE/latest.properties http://$GS_URL/latest.properties
554
555             # check if we got the file
556             [[ -f latest.properties ]] || exit 1
557
558             # source the file so we get OPNFV vars
559             source latest.properties
560
561             # download the file
562             curl -s -o $WORKSPACE/compass.iso http://$OPNFV_ARTIFACT_URL > gsutil.iso.log 2>&1
563
564             # list the file
565             ls -al $WORKSPACE/compass.iso
566
567             echo
568             echo "--------------------------------------------------------"
569             echo "Done!"
570
571 - builder:
572     name: 'builder-compass-workspace-cleanup'
573     builders:
574         - shell: |
575             #!/bin/bash
576             set -o errexit
577             set -o nounset
578             set -o pipefail
579
580             # delete everything that is in $WORKSPACE
581             /bin/rm -rf $WORKSPACE
582
583 - builder:
584     name: 'builder-compass-ci-preclean-workspace'
585     builders:
586         - shell: |
587             #!/bin/bash
588             set -o errexit
589             set -o nounset
590             set -o pipefail
591
592             cd $WORKSPACE/..
593             sudo rm $WORKSPACE -rf
594             git clone $GIT_BASE  $WORKSPACE
595
596 - builder:
597     name: 'builder-compass-backup-logs'
598     builders:
599         - shell: |
600             ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
601             sshpass -p root scp 2>/dev/null $ssh_options root@${installer_ip}:/var/ansible/run/openstack_juno-opnfv2/ansible.log ./  &> /dev/null