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