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