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