c050adcdf6feff9b944a28745de924f1c8933038
[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-{stream}'
15         - 'genesis-fuel-daily-{stream}'
16         - 'genesis-fuel-build-{stream}'
17         - 'genesis-fuel-deploy-{stream}'
18         - 'genesis-fuel-deploy-virtual-master'
19         - 'genesis-fuel-deploy-runner-{stream}'
20
21     # stream:    branch with - in place of / (eg. stable-arno)
22     # branch:    branch (eg. stable/arno)
23     stream:
24         - master:
25             branch: 'master'
26             gs-pathname: ''
27         - stable-arno:
28             branch: 'stable/arno'
29             gs-pathname: '/arno'
30
31 ########################
32 # job templates
33 ########################
34
35 - job-template:
36     name: 'genesis-fuel-verify-{stream}'
37
38     project-type: freestyle
39
40     node: ericsson-build
41
42     concurrent: true
43
44     properties:
45         - throttle:
46             enabled: true
47             max-total: 3
48
49     logrotate:
50         daysToKeep: 30
51         numToKeep: 10
52         artifactDaysToKeep: -1
53         artifactNumToKeep: -1
54
55     parameters:
56         - project-parameter:
57             project: '{project}'
58         - gerrit-parameter:
59             branch: '{branch}'
60         - fuel-parameter:
61             installer: '{installer}'
62             gs-pathname: '{gs-pathname}'
63
64     scm:
65         - gerrit-trigger-scm:
66             credentials-id: '{ssh-credentials}'
67             refspec: '$GERRIT_REFSPEC'
68             choosing-strategy: 'gerrit'
69
70     wrappers:
71         - ssh-agent-credentials:
72             user: '{ssh-credentials}'
73
74     triggers:
75         - gerrit:
76             trigger-on:
77                 - patchset-created-event:
78                     exclude-drafts: 'false'
79                     exclude-trivial-rebase: 'false'
80                     exclude-no-code-change: 'false'
81                 - draft-published-event
82                 - comment-added-contains-event:
83                     comment-contains-value: 'recheck'
84                 - comment-added-contains-event:
85                     comment-contains-value: 'reverify'
86             projects:
87               - project-compare-type: 'ANT'
88                 project-pattern: 'genesis'
89                 branches:
90                   - branch-compare-type: 'ANT'
91                     branch-pattern: '**/{branch}'
92                 file-paths:
93                   - compare-type: ANT
94                     pattern: 'common/**'
95                   - compare-type: ANT
96                     pattern: '{installer}/**'
97
98     builders:
99         - 'fuel-build'
100         - 'fuel-workspace-cleanup'
101
102 - job-template:
103     name: 'genesis-fuel-merge-{stream}'
104
105     project-type: freestyle
106
107     node: ericsson-build
108
109     concurrent: true
110
111     properties:
112         - throttle:
113             enabled: true
114             max-total: 2
115
116     logrotate:
117         daysToKeep: 30
118         numToKeep: 40
119         artifactDaysToKeep: -1
120         artifactNumToKeep: 5
121
122     parameters:
123         - project-parameter:
124             project: '{project}'
125         - gerrit-parameter:
126             branch: '{branch}'
127         - fuel-parameter:
128             installer: '{installer}'
129             gs-pathname: ''
130
131     scm:
132         - gerrit-trigger-scm:
133             credentials-id: '{ssh-credentials}'
134             refspec: ''
135             choosing-strategy: 'default'
136
137     wrappers:
138         - ssh-agent-credentials:
139             user: '{ssh-credentials}'
140
141     triggers:
142         - gerrit:
143             trigger-on:
144                 - change-merged-event
145                 - comment-added-contains-event:
146                     comment-contains-value: 'remerge'
147             projects:
148               - project-compare-type: 'ANT'
149                 project-pattern: 'genesis'
150                 branches:
151                     - branch-compare-type: 'ANT'
152                       branch-pattern: '**/{branch}'
153                 file-paths:
154                   - compare-type: ANT
155                     pattern: 'common/**'
156                   - compare-type: ANT
157                     pattern: '{installer}/**'
158
159     builders:
160         - 'fuel-build'
161         - 'fuel-workspace-cleanup'
162
163 - job-template:
164     name: 'genesis-fuel-daily-{stream}'
165
166     project-type: freestyle
167
168     node: ericsson-build
169
170     disabled: false
171
172     triggers:
173         - 'fuel-{stream}'
174
175     parameters:
176         - project-parameter:
177             project: '{project}'
178         - fuel-parameter:
179             installer: '{installer}'
180             gs-pathname: '{gs-pathname}'
181
182     scm:
183         - git-scm:
184             credentials-id: '{ssh-credentials}'
185             refspec: ''
186             branch: '{branch}'
187
188     logrotate:
189         daysToKeep: 30
190         numToKeep: 10
191         artifactDaysToKeep: -1
192         artifactNumToKeep: -1
193
194     builders:
195         - trigger-builds:
196           - project: 'genesis-fuel-build-{stream}'
197             git-revision: true
198             block: true
199 #        - trigger-builds:
200 #          - project: 'genesis-fuel-deploy-runner-{stream}'
201 #            git-revision: true
202 #            block: true
203 #        - trigger-builds:
204 #          - project: 'functest-opnfv-jump-1'
205 #            block: true
206 #        - trigger-builds:
207 #          - project: 'yardstick-opnfv-jump-1'
208 #            block: true
209
210 - job-template:
211     name: 'genesis-fuel-build-{stream}'
212
213     project-type: freestyle
214
215     node: ericsson-build
216
217     logrotate:
218         daysToKeep: 30
219         numToKeep: 10
220         artifactDaysToKeep: -1
221         artifactNumToKeep: -1
222
223     parameters:
224         - project-parameter:
225             project: '{project}'
226         - fuel-parameter:
227             installer: '{installer}'
228             gs-pathname: '{gs-pathname}'
229
230     scm:
231         - git-scm:
232             credentials-id: '{ssh-credentials}'
233             refspec: ''
234             branch: '{branch}'
235
236     builders:
237         - 'fuel-build'
238         - 'fuel-upload-artifact'
239         - 'fuel-workspace-cleanup'
240
241 - job-template:
242     name: 'genesis-fuel-deploy-{stream}'
243
244     project-type: freestyle
245
246     disabled: false
247
248     node: opnfv-jump-2
249
250     parameters:
251         - project-parameter:
252             project: '{project}'
253         - fuel-parameter:
254             installer: '{installer}'
255             gs-pathname: '{gs-pathname}'
256         - string:
257             name: GIT_BASE
258             default: ssh://gerrit.opnfv.org:29418/$PROJECT
259             description: "POD2 has some issues with cloning using https so that's why GIT_BASE is overriden here again."
260
261     scm:
262         - git-scm:
263             credentials-id: '{ssh-credentials}'
264             refspec: ''
265             branch: '{branch}'
266
267     logrotate:
268         daysToKeep: 30
269         numToKeep: 10
270         artifactDaysToKeep: -1
271         artifactNumToKeep: -1
272
273     builders:
274         - 'fuel-download-artifact'
275         - 'fuel-deploy'
276
277 - job-template:
278     name: 'genesis-fuel-deploy-runner-{stream}'
279
280     project-type: freestyle
281
282     disabled: false
283
284     node: master
285
286     logrotate:
287         daysToKeep: 30
288         numToKeep: 10
289         artifactDaysToKeep: -1
290         artifactNumToKeep: -1
291
292     parameters:
293         - project-parameter:
294             project: '{project}'
295         - fuel-parameter:
296             installer: '{installer}'
297             gs-pathname: '{gs-pathname}'
298         - string:
299             name: GIT_BASE
300             default: ssh://gerrit.opnfv.org:29418/$PROJECT
301             description: "Used for overriding the GIT URL coming from parameters macro."
302
303     scm:
304         - git-scm:
305             credentials-id: '{ssh-credentials}'
306             refspec: ''
307             branch: '{branch}'
308
309     builders:
310         - 'fuel-lab-reconfig'
311         - trigger-builds:
312           - project: 'genesis-fuel-deploy-{stream}'
313             git-revision: true
314             block: true
315
316 - job-template:
317     name: 'genesis-fuel-deploy-virtual-master'
318
319     project-type: freestyle
320
321     disabled: false
322
323     node: ericsson-build
324
325     parameters:
326         - project-parameter:
327             project: '{project}'
328         - fuel-parameter:
329             installer: '{installer}'
330             gs-pathname: ''
331
332     scm:
333         - git-scm:
334             credentials-id: '{ssh-credentials}'
335             refspec: ''
336             branch: master
337
338     logrotate:
339         daysToKeep: 30
340         numToKeep: 10
341         artifactDaysToKeep: -1
342         artifactNumToKeep: -1
343
344     builders:
345         - 'fuel-deploy-virtual'
346
347 ########################
348 # parameter macros
349 ########################
350 - parameter:
351     name: fuel-parameter
352     parameters:
353         - string:
354             name: INSTALLER
355             default: '{installer}'
356             description: "Installer to use."
357         - string:
358             name: BUILD_DIRECTORY
359             default: $WORKSPACE/build_output
360             description: "Directory where the build artifact will be located upon the completion of the build."
361         - string:
362             name: CACHE_DIRECTORY
363             default: $HOME/opnfv/cache/genesis-$INSTALLER
364             description: "Directory where the cache to be used during the build is located."
365         - string:
366             name: GIT_BASE
367             default: https://gerrit.opnfv.org/gerrit/$PROJECT
368             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
369         - string:
370             name: GS_URL
371             default: artifacts.opnfv.org/$PROJECT/$INSTALLER{gs-pathname}
372             description: "URL to Google Storage."
373
374 ########################
375 # builder macros
376 ########################
377 - builder:
378     name: 'fuel-build'
379     builders:
380         - shell: |
381             #!/bin/bash
382             set -o errexit
383             set -o nounset
384             set -o pipefail
385
386             # log info to console
387             echo "Starting the build of $INSTALLER. This could take some time..."
388             echo "--------------------------------------------------------"
389             echo
390
391             # create the cache directory if it doesn't exist
392             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
393
394             # set OPNFV_ARTIFACT_VERSION
395             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
396
397             # start the build
398             cd $WORKSPACE/$INSTALLER/ci
399             ./build.sh -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
400
401             # list the build artifacts
402             ls -al $BUILD_DIRECTORY
403
404             # save information regarding artifact into file
405             (
406                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
407                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
408                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
409                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
410                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
411                 echo "OPNFV_BUILD_URL=$BUILD_URL"
412             ) > $WORKSPACE/opnfv.properties
413
414             echo
415             echo "--------------------------------------------------------"
416             echo "Done!"
417
418 - builder:
419     name: 'fuel-deploy'
420     builders:
421         - shell: |
422             #!/bin/bash
423             set -o errexit
424             set -o nounset
425             set -o pipefail
426
427             # source the file so we get OPNFV vars
428             source latest.properties
429
430             # echo the info about artifact that is used during the deployment
431             echo "Using $(echo $OPNFV_ARTIFACT_URL | cut -d'/' -f4) for deployment"
432
433             # create TMPDIR if it doesn't exist
434             export TMPDIR=$HOME/tmpdir
435             [[ -d $TMPDIR ]] || mkdir -p $TMPDIR
436
437             # change permissions down to TMPDIR
438             chmod a+x $HOME
439             chmod a+x $TMPDIR
440
441             # set CONFDIR, BRIDGE
442             export CONFDIR=$WORKSPACE/fuel/deploy/baremetal/conf/linux_foundation_lab/pod2/ha
443             export BRIDGE=pxebr
444
445             # cleanup first
446             sudo $WORKSPACE/common/ci/clean.sh -base_config $WORKSPACE/foreman/ci/inventory/lf_pod2_ksgen_settings.yml
447
448             # prepare for Fuel Deployment
449             sudo $WORKSPACE/common/ci/setup.sh
450
451             # log info to console
452             echo "Starting the deployment using $INSTALLER. This could take some time..."
453             echo "--------------------------------------------------------"
454             echo
455
456             # start the deployment
457             echo "Issuing command"
458             echo "sudo $WORKSPACE/fuel/ci/deploy.sh $WORKSPACE/opnfv.iso $CONFDIR/dea.yaml $CONFDIR/dha.yaml -s $TMPDIR -b $BRIDGE"
459             sudo $WORKSPACE/fuel/ci/deploy.sh $WORKSPACE/opnfv.iso $CONFDIR/dea.yaml $CONFDIR/dha.yaml -s $TMPDIR -b $BRIDGE
460
461             echo
462             echo "--------------------------------------------------------"
463             echo "Done!"
464
465 - builder:
466     name: 'fuel-deploy-virtual'
467     builders:
468         - shell: |
469             #!/bin/bash
470             set -o errexit
471             set -o nounset
472             set -o pipefail
473
474             # log info to console
475             echo "Starting the deployment on virtual environment using $INSTALLER. This could take some time..."
476             echo "--------------------------------------------------------"
477             echo
478
479             ssh -o BatchMode=yes -o TCPKeepAlive=yes cideploy@10.118.34.205 ./cideploy.sh
480
481             echo
482             echo "--------------------------------------------------------"
483             echo "Done!"
484
485 - builder:
486     name: 'fuel-upload-artifact'
487     builders:
488         - shell: |
489             #!/bin/bash
490             set -o errexit
491             set -o nounset
492             set -o pipefail
493
494             # log info to console
495             echo "Uploading the $INSTALLER artifact. This could take some time..."
496             echo "--------------------------------------------------------"
497             echo
498
499             # source the opnfv.properties to get ARTIFACT_VERSION
500             source $WORKSPACE/opnfv.properties
501
502             # upload artifact and additional files to google storage
503             gsutil cp $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.iso gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
504             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
505             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
506
507             echo
508             echo "--------------------------------------------------------"
509             echo "Done!"
510             echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
511
512 - builder:
513     name: 'fuel-download-artifact'
514     builders:
515         - shell: |
516             #!/bin/bash
517             set -o errexit
518             set -o nounset
519             set -o pipefail
520
521             # get the latest.properties file in order to get info regarding latest artifact
522             curl -s -o $WORKSPACE/latest.properties http://$GS_URL/latest.properties
523
524             # check if we got the file
525             [[ -f latest.properties ]] || exit 1
526
527             # source the file so we get OPNFV vars
528             source latest.properties
529
530             # log info to console
531             echo "Downloading the $INSTALLER artifact using URL http://$OPNFV_ARTIFACT_URL"
532             echo "This could take some time..."
533             echo "--------------------------------------------------------"
534             echo
535
536             # download the file
537             curl -s -o $WORKSPACE/opnfv.iso http://$OPNFV_ARTIFACT_URL > gsutil.iso.log 2>&1
538
539             # list the file
540             ls -al $WORKSPACE/opnfv.iso
541
542             echo
543             echo "--------------------------------------------------------"
544             echo "Done!"
545
546 - builder:
547     name: 'fuel-workspace-cleanup'
548     builders:
549         - shell: |
550             #!/bin/bash
551             set -o errexit
552             set -o nounset
553             set -o pipefail
554
555             # delete everything that is in $WORKSPACE
556             /bin/rm -rf $WORKSPACE
557
558 - builder:
559     name: 'fuel-lab-reconfig'
560     builders:
561         - shell: |
562             #!/bin/bash
563             set -o errexit
564             set -o nounset
565             set -o pipefail
566
567             # check to see if ucs login info file exists
568             if [ -e ~/.ssh/ucs_creds ];then
569               source ~/.ssh/ucs_creds
570             else
571               echo "Unable to find UCS credentials for LF lab reconfiguration...Exiting"
572               exit 1
573             fi
574
575             # clone releng
576             echo "Cloning releng repo..."
577             if ! GIT_SSL_NO_VERIFY=true git clone https://gerrit.opnfv.org/gerrit/releng; then
578               echo "Unable to clone releng repo...Exiting"
579               exit 1
580             fi
581
582             # log info to console
583             echo "Starting the lab reconfiguration for $INSTALLER..."
584             echo "--------------------------------------------------------"
585             echo
586
587             # create venv
588             $WORKSPACE/releng/utils/lab-reconfiguration/create_venv.sh
589
590             # disable nounset because 'activate' script contains unbound variable(s)
591             set +o nounset
592             # enter venv
593             source $WORKSPACE/releng/utils/lab-reconfiguration/venv/bin/activate
594             # set nounset back again
595             set -o nounset
596
597             # verify we are in venv
598             if [[ ! $(which python | grep venv) ]]; then
599               echo "Unable to activate venv...Exiting"
600               exit 1
601             fi
602
603             python $WORKSPACE/releng/utils/lab-reconfiguration/reconfigUcsNet.py -i $ucs_host -u $ucs_user -p $ucs_password -f $WORKSPACE/releng/utils/lab-reconfiguration/fuel.yaml
604
605             # while undergoing reboot
606             sleep 30
607
608             # check to see if slave is back up
609             ping_counter=0
610             ping_flag=0
611             while [ "$ping_counter" -lt 20 ]; do
612               if [[ $(ping -c 5 172.30.10.72) ]]; then
613                 ping_flag=1
614                 break
615               fi
616               ((ping_counter++))
617               sleep 10
618             done
619
620             if [ "$ping_flag" -eq 1 ]; then
621               echo "Slave is pingable, now wait 60 seconds for services to start"
622               sleep 60
623             else
624               echo "Slave did not come back up after reboot: please check opnfv-jump-2"
625               exit 1
626             fi
627
628             set +o nounset
629             deactivate
630
631             echo
632             echo "--------------------------------------------------------"
633             echo "Done!"
634
635 ########################
636 # trigger macros
637 ########################
638 - trigger:
639     name: 'fuel-master'
640     triggers:
641         - timed: '0 21 * * *'
642
643 - trigger:
644     name: 'fuel-stable-arno'
645     triggers:
646         - timed: '0 3 * * *'