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