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