excute vertual-deployment in compass verify 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'
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
158 - job-template:
159     name: 'compass-merge'
160
161     # builder-merge job to run JJB update
162     #
163     # This job's purpose is to update all the JJB
164
165     project-type: freestyle
166
167     node: huawei-build
168
169     logrotate:
170         daysToKeep: 30
171         numToKeep: 40
172         artifactDaysToKeep: -1
173         artifactNumToKeep: 5
174
175     parameters:
176         - project-parameter:
177             project: '{project}'
178         - gerrit-parameter:
179             branch: 'master'
180         - compass-parameter:
181             installer: '{installer}'
182
183     scm:
184         - gerrit-trigger-scm:
185             credentials-id: '{ssh-credentials}'
186             refspec: ''
187             choosing-strategy: 'default'
188
189     wrappers:
190         - ssh-agent-credentials:
191             user: '{ssh-credentials}'
192
193     triggers:
194         - gerrit:
195             trigger-on:
196                 - change-merged-event
197                 - comment-added-contains-event:
198                     comment-contains-value: 'remerge'
199             projects:
200               - project-compare-type: 'ANT'
201                 project-pattern: '{project}'
202                 branches:
203                     - branch-compare-type: 'ANT'
204                       branch-pattern: '**/master'
205     builders:
206         - 'compass-merge'
207
208 - job-template:
209     name: 'compass-daily-{stream}'
210
211     project-type: freestyle
212
213     node: huawei-build
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: '{branch}'
226
227     triggers:
228         - pollscm: '@midnight'
229
230     logrotate:
231         daysToKeep: 30
232         numToKeep: 10
233         artifactDaysToKeep: -1
234         artifactNumToKeep: -1
235
236     builders:
237         #- 'compass-build'
238         #- 'compass-upload-artifact'
239         #- 'compass-workspace-cleanup'
240         - shell: |
241             echo "Hello world!"
242             echo "compass-deploy-virtual job will be triggered!"
243
244     publishers:
245         - trigger:
246             project: 'compass-build'
247             threshold: SUCCESS
248         - trigger:
249             project: 'compass-deploy-virtual-cluster'
250             threshold: SUCCESS
251
252 - job-template:
253     name: 'compass-build'
254
255     project-type: freestyle
256
257     node: ericsson-build
258
259     logrotate:
260         daysToKeep: 30
261         numToKeep: 10
262         artifactDaysToKeep: -1
263         artifactNumToKeep: -1
264
265     parameters:
266         - project-parameter:
267             project: '{project}'
268         - compass-parameter:
269             installer: '{installer}'
270
271     scm:
272         - git-scm:
273             credentials-id: '{ssh-credentials}'
274             refspec: ''
275             branch: 'master'
276
277     builders:
278         - 'compass-build'
279         - 'compass-upload-artifact'
280         - 'compass-workspace-cleanup'
281
282 - job-template:
283     name: 'compass-deploy-virtual-{flavor}'
284
285     project-type: freestyle
286
287     disabled: false
288
289     node: '{node}'
290
291     parameters:
292         - project-parameter:
293             project: '{project}'
294         - compass-parameter:
295             installer: '{installer}'
296         - string:
297             name: FLAVOR_CONF
298             default: '{conf}'
299             description: ""
300
301     triggers:
302         - pollscm: "H/2 * * * *"
303
304     logrotate:
305         daysToKeep: 30
306         numToKeep: 10
307         artifactDaysToKeep: -1
308         artifactNumToKeep: -1
309
310     builders:
311         - 'compass-ci-preclean-workspace'
312         - 'compass-download-artifact'
313         - 'compass-deploy-virtual-flavor'
314
315 ########################
316 # parameter macros
317 ########################
318 - parameter:
319     name: compass-parameter
320     parameters:
321         - string:
322             name: INSTALLER
323             default: '{installer}'
324             description: "Installer to use."
325         - string:
326             name: BUILD_DIRECTORY
327             default: $WORKSPACE/build_output
328             description: "Directory where the build artifact will be located upon the completion of the build."
329         - string:
330             name: CACHE_DIRECTORY
331             default: $HOME/opnfv/cache/$PROJECT
332             description: "Directory where the cache to be used during the build is located."
333         - string:
334             name: GIT_BASE
335             default: https://gerrit.opnfv.org/gerrit/$PROJECT
336             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
337         - string:
338             name: GS_URL
339             default: artifacts.opnfv.org/$PROJECT/
340             description: "URL to Google Storage."
341         - string:
342             name: GS_URL_PROXY
343             default: build.opnfv.org/artifacts/$PROJECT/
344             description: "URL to Google Storage proxy"
345         - string:
346             name: INTERNAL_REPO_XA
347             default: "root@192.168.127.11:~/xh/work/build/work"
348             description: "Artifact Repository"
349
350
351 ########################
352 # builder macros
353 ########################
354 - builder:
355     name: compass-merge
356     builders:
357         - shell: |
358             #!/bin/bash
359             echo "Hello World!"
360
361
362
363 - builder:
364     name: 'compass-build'
365     builders:
366         - shell: |
367             #!/bin/bash
368             set -o errexit
369             set -o nounset
370             set -o pipefail
371
372             # log info to console
373             echo "Starting the build of $INSTALLER. This could take some time..."
374             echo "--------------------------------------------------------"
375             echo
376
377             # create the cache directory if it doesn't exist
378             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
379             [[ -d $BUILD_DIRECTORY ]] || mkdir -p $BUILD_DIRECTORY
380
381             # set OPNFV_ARTIFACT_VERSION
382             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
383
384             # start the build
385             cd $WORKSPACE/
386             ./build.sh  --iso-dir $BUILD_DIRECTORY/ --iso-name compass.iso -c $CACHE_DIRECTORY
387
388             # list the build artifacts
389             ls -al $BUILD_DIRECTORY
390
391             # save information regarding artifact into file
392             (
393                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
394                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
395                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
396                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
397                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/compass.iso | cut -d' ' -f1)"
398                 echo "OPNFV_BUILD_URL=$BUILD_URL"
399             ) > $BUILD_DIRECTORY/opnfv.properties
400             echo
401             echo "--------------------------------------------------------"
402             echo "Done!"
403
404 - builder:
405     name: 'compass-deploy-virtual-flavor'
406     builders:
407         - shell: |
408             #!/bin/bash
409             set -o errexit
410             set -o nounset
411             set -o pipefail
412             set -x
413
414             # log info to console
415             echo "Starting the deployment on virtual environment using $INSTALLER. This could take some time..."
416             echo "--------------------------------------------------------"
417             echo
418
419             export ISO_URL=file://$BUILD_DIRECTORY/compass.iso
420             cd $WORKSPACE
421             ./deploy.sh $FLAVOR_CONF
422
423             echo
424             echo "--------------------------------------------------------"
425             echo "Done!"
426
427 - builder:
428     name: 'compass-upload-artifact'
429     builders:
430         - shell: |
431             #!/bin/bash
432             set -o errexit
433             set -o nounset
434             set -o pipefail
435
436             # log info to console
437             echo "Uploading the $INSTALLER artifact. This could take some time..."
438             echo "--------------------------------------------------------"
439             echo
440
441             # source the opnfv.properties to get ARTIFACT_VERSION
442             source $BUILD_DIRECTORY/opnfv.properties
443
444             # upload artifact and additional files to google storage
445             gsutil cp $BUILD_DIRECTORY/compass.iso gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
446             gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
447             gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
448
449
450             echo
451             echo "--------------------------------------------------------"
452             echo "Done!"
453             echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
454
455 - builder:
456     name: 'compass-download-artifact'
457     builders:
458         - shell: |
459             #!/bin/bash
460             set -o errexit
461             set -o nounset
462             set -o pipefail
463
464             # log info to console
465             echo "Downloading the $INSTALLER artifact. This could take some time..."
466             echo "--------------------------------------------------------"
467             echo
468
469             # get the latest.properties file in order to get info regarding latest artifact
470             curl -s -o $WORKSPACE/latest.properties http://$GS_URL/latest.properties
471
472             # check if we got the file
473             [[ -f latest.properties ]] || exit 1
474
475             # source the file so we get OPNFV vars
476             source latest.properties
477
478             # download the file
479             curl -s -o $WORKSPACE/opnfv.iso http://$OPNFV_ARTIFACT_URL > gsutil.iso.log 2>&1
480
481             # list the file
482             ls -al $WORKSPACE/opnfv.iso
483
484             echo
485             echo "--------------------------------------------------------"
486             echo "Done!"
487
488 - builder:
489     name: 'compass-workspace-cleanup'
490     builders:
491         - shell: |
492             #!/bin/bash
493             set -o errexit
494             set -o nounset
495             set -o pipefail
496
497             # delete everything that is in $WORKSPACE
498             /bin/rm -rf $WORKSPACE
499
500 - builder:
501     name: 'compass-ci-preclean-workspace'
502     builders:
503         - shell: |
504             #!/bin/bash
505             set -o errexit
506             set -o nounset
507             set -o pipefail
508
509             cd $WORKSPACE/..
510             sudo rm $WORKSPACE -rf
511             git clone $GIT_BASE  $WORKSPACE
512