Reconfigure foreman and fuel daily jobs after lab reconfiguration
[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: 2
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     disabled: false
371
372     node: opnfv-jump-1
373
374     logrotate:
375         daysToKeep: 30
376         numToKeep: 10
377         artifactDaysToKeep: -1
378         artifactNumToKeep: -1
379
380     parameters:
381         - project-parameter:
382             project: '{project}'
383         - foreman-parameter:
384             installer: '{installer}'
385             gs-pathname: '{gs-pathname}'
386         - string:
387             name: GIT_BASE
388             default: ssh://gerrit.opnfv.org:29418/$PROJECT
389             description: "Used for overriding the GIT URL coming from parameters macro."
390
391     scm:
392         - git-scm:
393             credentials-id: '{ssh-credentials}'
394             refspec: ''
395             branch: '{branch}'
396
397     builders:
398         - 'foreman-deploy-virtual'
399
400 ########################
401 # parameter macros
402 ########################
403 - parameter:
404     name: foreman-parameter
405     parameters:
406         - string:
407             name: INSTALLER
408             default: '{installer}'
409             description: "Installer to use."
410         - string:
411             name: BUILD_DIRECTORY
412             default: $WORKSPACE/build_output
413             description: "Directory where the build artifact will be located upon the completion of the build."
414         - string:
415             name: CACHE_DIRECTORY
416             default: $HOME/opnfv/cache/genesis-$INSTALLER{gs-pathname}
417             description: "Directory where the cache to be used during the build is located."
418         - string:
419             name: GIT_BASE
420             default: https://gerrit.opnfv.org/gerrit/$PROJECT
421             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
422         - string:
423             name: GS_URL
424             default: artifacts.opnfv.org/$PROJECT/$INSTALLER{gs-pathname}
425             description: "URL to Google Storage."
426
427 ########################
428 # builder macros
429 ########################
430 - builder:
431     name: 'foreman-lab-reconfig'
432     builders:
433         - shell: |
434             #!/bin/bash
435             set -o errexit
436             set -o nounset
437             set -o pipefail
438
439             # check to see if ucs login info file exists
440             if [ -e ~/.ssh/ucs_creds ];then
441               source ~/.ssh/ucs_creds
442             else
443               echo "Unable to find UCS credentials for LF lab reconfiguration...Exiting"
444               exit 1
445             fi
446
447             # clone releng
448             echo "Cloning releng repo..."
449             if ! GIT_SSL_NO_VERIFY=true git clone https://gerrit.opnfv.org/gerrit/releng; then
450               echo "Unable to clone releng repo...Exiting"
451               exit 1
452             fi
453
454             # log info to console
455             echo "Starting the lab reconfiguration for $INSTALLER..."
456             echo "--------------------------------------------------------"
457             echo
458
459             # create venv
460             $WORKSPACE/releng/utils/lab-reconfiguration/create_venv.sh
461
462             # disable nounset because 'activate' script contains unbound variable(s)
463             set +o nounset
464             # enter venv
465             source $WORKSPACE/releng/utils/lab-reconfiguration/venv/bin/activate
466             # set nounset back again
467             set -o nounset
468
469             # verify we are in venv
470             if [[ ! $(which python | grep venv) ]]; then
471               echo "Unable to activate venv...Exiting"
472               exit 1
473             fi
474
475             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
476
477             # while undergoing reboot
478             sleep 30
479
480             # check to see if slave is back up
481             ping_counter=0
482             ping_flag=0
483             while [ "$ping_counter" -lt 20 ]; do
484               if [[ $(ping -c 5 172.30.10.72) ]]; then
485                 ping_flag=1
486                 break
487               fi
488               ((ping_counter++))
489               sleep 10
490             done
491
492             if [ "$ping_flag" -eq 1 ]; then
493               echo "Slave is pingable, now wait 90 seconds for services to start"
494               sleep 90
495             else
496               echo "Slave did not come back up after reboot: please check opnfv-jump-2"
497               exit 1
498             fi
499
500             set +o nounset
501             deactivate
502
503             echo
504             echo "--------------------------------------------------------"
505             echo "Done!"
506
507 - builder:
508     name: 'foreman-build'
509     builders:
510         - shell: |
511             #!/bin/bash
512             set -o errexit
513             set -o nounset
514             set -o pipefail
515
516             # log info to console
517             echo "Starting the build of $INSTALLER. This could take some time..."
518             echo "--------------------------------------------------------"
519             echo
520
521             # create the cache directory if it doesn't exist
522             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
523
524             # set OPNFV_ARTIFACT_VERSION
525             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
526
527             # start the build
528             cd $WORKSPACE/$INSTALLER/ci
529             ./build.sh -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
530
531             # list the contents of BUILD_OUTPUT directory
532             ls -al $BUILD_DIRECTORY
533
534             # save information regarding artifact into file
535             (
536                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
537                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
538                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
539                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
540                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
541                 echo "OPNFV_BUILD_URL=$BUILD_URL"
542             ) > $WORKSPACE/opnfv.properties
543
544             echo
545             echo "--------------------------------------------------------"
546             echo "Done!"
547
548 - builder:
549     name: 'foreman-deploy'
550     builders:
551         - shell: |
552             #!/bin/bash
553             set -o errexit
554             set -o nounset
555             set -o pipefail
556
557             # log info to console
558             echo "Starting the deployment using $INSTALLER. This could take some time..."
559             echo "--------------------------------------------------------"
560             echo
561
562             # cleanup first
563             sudo $WORKSPACE/common/ci/clean.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
564
565             # and then initiate deployment
566             sudo $WORKSPACE/$INSTALLER/ci/deploy.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
567
568             echo
569             echo "--------------------------------------------------------"
570             echo "Done!"
571
572 - builder:
573     name: 'foreman-deploy-virtual'
574     builders:
575         - shell: |
576             #!/bin/bash
577             set -o errexit
578             set -o nounset
579             set -o pipefail
580
581             # log info to console
582             echo "Starting the virtual deployment using $INSTALLER. This could take some time..."
583             echo "--------------------------------------------------------"
584             echo
585
586             # cleanup baremetal first (in case baremetal was being used on pod2, remove when moved to isolated Virtual pod)
587             sudo $WORKSPACE/common/ci/clean.sh
588
589             # initiate virtual deployment
590             sudo $WORKSPACE/$INSTALLER/ci/deploy.sh -virtual
591
592             echo
593             echo "--------------------------------------------------------"
594             echo "Done!"
595
596 - builder:
597     name: 'foreman-upload-artifact'
598     builders:
599         - shell: |
600             #!/bin/bash
601             set -o errexit
602             set -o nounset
603             set -o pipefail
604
605             # log info to console
606             echo "Uploading the $INSTALLER artifact. This could take some time..."
607             echo "--------------------------------------------------------"
608             echo
609
610             # source the opnfv.properties to get ARTIFACT_VERSION
611             source $WORKSPACE/opnfv.properties
612
613             # upload artifact and additional files to google storage
614             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
615             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
616             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
617
618             echo
619             echo "--------------------------------------------------------"
620             echo "Done!"
621             echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
622
623 - builder:
624     name: 'foreman-workspace-cleanup'
625     builders:
626         - shell: |
627             #!/bin/bash
628             set -o errexit
629             set -o nounset
630             set -o pipefail
631
632             # delete everything that is in $WORKSPACE
633             /bin/rm -rf $WORKSPACE
634
635 ########################
636 # trigger macros
637 ########################
638 - trigger:
639     name: 'foreman-master'
640     triggers:
641         - pollscm: '0 21 * * *'
642
643 - trigger:
644     name: 'foreman-stable-arno'
645     triggers:
646         - pollscm: '0 1 * * *'