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