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