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