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