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