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