64936a56b8e21ba0ecfde079e045811d48b26802
[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
413             # log info to console
414             echo "Starting the deployment on virtual environment using $INSTALLER. This could take some time..."
415             echo "--------------------------------------------------------"
416             echo
417
418             export ISO_URL=file://$BUILD_DIRECTORY/compass.iso
419             cd $WORKSPACE
420             ./deploy.sh $FLAVOR_CONF
421
422             echo
423             echo "--------------------------------------------------------"
424             echo "Done!"
425
426 - builder:
427     name: 'compass-upload-artifact'
428     builders:
429         - shell: |
430             #!/bin/bash
431             set -o errexit
432             set -o nounset
433             set -o pipefail
434
435             # log info to console
436             echo "Uploading the $INSTALLER artifact. This could take some time..."
437             echo "--------------------------------------------------------"
438             echo
439
440             # source the opnfv.properties to get ARTIFACT_VERSION
441             source $BUILD_DIRECTORY/opnfv.properties
442
443             # upload artifact and additional files to google storage
444             gsutil cp $BUILD_DIRECTORY/compass.iso gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
445             gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
446             gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
447
448
449             echo
450             echo "--------------------------------------------------------"
451             echo "Done!"
452             echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
453
454 - builder:
455     name: 'compass-download-artifact'
456     builders:
457         - shell: |
458             #!/bin/bash
459             set -o errexit
460             set -o nounset
461             set -o pipefail
462
463             # log info to console
464             echo "Downloading the $INSTALLER artifact. This could take some time..."
465             echo "--------------------------------------------------------"
466             echo
467
468             # get the latest.properties file in order to get info regarding latest artifact
469             curl -s -o $WORKSPACE/latest.properties http://$GS_URL/latest.properties
470
471             # check if we got the file
472             [[ -f latest.properties ]] || exit 1
473
474             # source the file so we get OPNFV vars
475             source latest.properties
476
477             # download the file
478             curl -s -o $WORKSPACE/opnfv.iso http://$OPNFV_ARTIFACT_URL > gsutil.iso.log 2>&1
479
480             # list the file
481             ls -al $WORKSPACE/opnfv.iso
482
483             echo
484             echo "--------------------------------------------------------"
485             echo "Done!"
486
487 - builder:
488     name: 'compass-workspace-cleanup'
489     builders:
490         - shell: |
491             #!/bin/bash
492             set -o errexit
493             set -o nounset
494             set -o pipefail
495
496             # delete everything that is in $WORKSPACE
497             /bin/rm -rf $WORKSPACE
498
499 - builder:
500     name: 'compass-ci-preclean-workspace'
501     builders:
502         - shell: |
503             #!/bin/bash
504             set -o errexit
505             set -o nounset
506             set -o pipefail
507
508             cd $WORKSPACE/..
509             sudo rm $WORKSPACE -rf
510             git clone $GIT_BASE  $WORKSPACE
511