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