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