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