Enable workspace cleanup for compass jobs done on ericsson-build
[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         - 'compass-workspace-cleanup'
92
93 - job-template:
94     name: 'compass-verify'
95
96     project-type: freestyle
97
98     disabled: false
99
100     node: huawei-build
101
102     logrotate:
103         daysToKeep: 30
104         numToKeep: 10
105         artifactDaysToKeep: -1
106         artifactNumToKeep: -1
107
108     parameters:
109         - project-parameter:
110             project: '{project}'
111         - gerrit-parameter:
112             branch: 'master'
113         - compass-parameter:
114             installer: '{installer}'
115         - string:
116             name: FLAVOR_CONF
117             default: 'virtual_cluster'
118             description: ""
119     scm:
120         - gerrit-trigger-scm:
121             credentials-id: '{ssh-credentials}'
122             refspec: '$GERRIT_REFSPEC'
123             choosing-strategy: 'gerrit'
124
125     wrappers:
126         - ssh-agent-credentials:
127             user: '{ssh-credentials}'
128
129     triggers:
130         - gerrit:
131             trigger-on:
132                 - patchset-created-event:
133                     exclude-drafts: 'false'
134                     exclude-trivial-rebase: 'false'
135                     exclude-no-code-change: 'false'
136                 - draft-published-event
137                 - comment-added-contains-event:
138                     comment-contains-value: 'recheck'
139                 - comment-added-contains-event:
140                     comment-contains-value: 'reverify'
141             projects:
142               - project-compare-type: 'ANT'
143                 project-pattern: '{project}'
144                 branches:
145                   - branch-compare-type: 'ANT'
146                     branch-pattern: '**/master'
147
148     builders:
149         - 'compass-build'
150         #- 'compass-deploy-virtual-flavor'
151
152 - job-template:
153     name: 'compass-merge'
154
155     # builder-merge job to run JJB update
156     #
157     # This job's purpose is to update all the JJB
158
159     project-type: freestyle
160
161     node: huawei-build
162
163     logrotate:
164         daysToKeep: 30
165         numToKeep: 40
166         artifactDaysToKeep: -1
167         artifactNumToKeep: 5
168
169     parameters:
170         - project-parameter:
171             project: '{project}'
172         - gerrit-parameter:
173             branch: 'master'
174         - compass-parameter:
175             installer: '{installer}'
176
177     scm:
178         - gerrit-trigger-scm:
179             credentials-id: '{ssh-credentials}'
180             refspec: ''
181             choosing-strategy: 'default'
182
183     wrappers:
184         - ssh-agent-credentials:
185             user: '{ssh-credentials}'
186
187     triggers:
188         - gerrit:
189             trigger-on:
190                 - change-merged-event
191                 - comment-added-contains-event:
192                     comment-contains-value: 'remerge'
193             projects:
194               - project-compare-type: 'ANT'
195                 project-pattern: '{project}'
196                 branches:
197                     - branch-compare-type: 'ANT'
198                       branch-pattern: '**/master'
199     builders:
200         - 'compass-merge'
201
202 - job-template:
203     name: 'compass-daily-{stream}'
204
205     project-type: freestyle
206
207     node: huawei-build
208
209     parameters:
210         - project-parameter:
211             project: '{project}'
212         - compass-parameter:
213             installer: '{installer}'
214
215     scm:
216         - git-scm:
217             credentials-id: '{ssh-credentials}'
218             refspec: ''
219             branch: '{branch}'
220
221     triggers:
222         - pollscm: '@midnight'
223
224     logrotate:
225         daysToKeep: 30
226         numToKeep: 10
227         artifactDaysToKeep: -1
228         artifactNumToKeep: -1
229
230     builders:
231         #- 'compass-build'
232         #- 'compass-upload-artifact'
233         #- 'compass-workspace-cleanup'
234         - shell: |
235             echo "Hello world!"
236             echo "compass-deploy-virtual job will be triggered!"
237
238     publishers:
239         - trigger:
240             project: 'compass-build'
241             threshold: SUCCESS
242         - trigger:
243             project: 'compass-deploy-virtual-cluster'
244             threshold: SUCCESS
245
246 - job-template:
247     name: 'compass-build'
248
249     project-type: freestyle
250
251     node: ericsson-build
252
253     logrotate:
254         daysToKeep: 30
255         numToKeep: 10
256         artifactDaysToKeep: -1
257         artifactNumToKeep: -1
258
259     parameters:
260         - project-parameter:
261             project: '{project}'
262         - compass-parameter:
263             installer: '{installer}'
264
265     scm:
266         - git-scm:
267             credentials-id: '{ssh-credentials}'
268             refspec: ''
269             branch: 'master'
270
271     builders:
272         - 'compass-build'
273         - 'compass-upload-artifact'
274         - 'compass-workspace-cleanup'
275
276 - job-template:
277     name: 'compass-deploy-virtual-{flavor}'
278
279     project-type: freestyle
280
281     disabled: false
282
283     node: '{node}'
284
285     parameters:
286         - project-parameter:
287             project: '{project}'
288         - compass-parameter:
289             installer: '{installer}'
290         - string:
291             name: FLAVOR_CONF
292             default: '{conf}'
293             description: ""
294
295     triggers:
296         - pollscm: "H/2 * * * *"
297
298     logrotate:
299         daysToKeep: 30
300         numToKeep: 10
301         artifactDaysToKeep: -1
302         artifactNumToKeep: -1
303
304     builders:
305         - 'compass-ci-preclean-workspace'
306         - 'compass-download-artifact'
307         - 'compass-deploy-virtual-flavor'
308
309 ########################
310 # parameter macros
311 ########################
312 - parameter:
313     name: compass-parameter
314     parameters:
315         - string:
316             name: INSTALLER
317             default: '{installer}'
318             description: "Installer to use."
319         - string:
320             name: BUILD_DIRECTORY
321             default: $WORKSPACE/build_output
322             description: "Directory where the build artifact will be located upon the completion of the build."
323         - string:
324             name: CACHE_DIRECTORY
325             default: $HOME/opnfv/cache/$PROJECT
326             description: "Directory where the cache to be used during the build is located."
327         - string:
328             name: GIT_BASE
329             default: https://gerrit.opnfv.org/gerrit/$PROJECT
330             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
331         - string:
332             name: GS_URL
333             default: artifacts.opnfv.org/$PROJECT/
334             description: "URL to Google Storage."
335         - string:
336             name: GS_URL_PROXY
337             default: build.opnfv.org/artifacts/$PROJECT/
338             description: "URL to Google Storage proxy"
339         - string:
340             name: INTERNAL_REPO_XA
341             default: "root@192.168.127.11:~/xh/work/build/work"
342             description: "Artifact Repository"
343
344
345 ########################
346 # builder macros
347 ########################
348 - builder:
349     name: compass-merge
350     builders:
351         - shell: |
352             #!/bin/bash
353             echo "Hello World!"
354
355
356
357 - builder:
358     name: 'compass-build'
359     builders:
360         - shell: |
361             #!/bin/bash
362             set -o errexit
363             set -o nounset
364             set -o pipefail
365
366             # log info to console
367             echo "Starting the build of $INSTALLER. This could take some time..."
368             echo "--------------------------------------------------------"
369             echo
370
371             # create the cache directory if it doesn't exist
372             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
373             [[ -d $BUILD_DIRECTORY ]] || mkdir -p $BUILD_DIRECTORY
374
375             # set OPNFV_ARTIFACT_VERSION
376             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
377
378             # start the build
379             cd $WORKSPACE/
380             ./build.sh  --iso-dir $BUILD_DIRECTORY/ --iso-name compass.iso -c $CACHE_DIRECTORY
381
382             # list the build artifacts
383             ls -al $BUILD_DIRECTORY
384
385             # save information regarding artifact into file
386             (
387                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
388                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
389                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
390                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
391                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/compass.iso | cut -d' ' -f1)"
392                 echo "OPNFV_BUILD_URL=$BUILD_URL"
393             ) > $BUILD_DIRECTORY/opnfv.properties
394             echo
395             echo "--------------------------------------------------------"
396             echo "Done!"
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             /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