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