3d98437d3eb3d43e17f7603f655da5bb73fb59b8
[releng.git] / jjb / genesis / genesis-foreman.yml
1 # this is the job configuration for bgs
2 - project:
3
4     name: genesis-foreman
5
6     project: 'genesis'
7
8     installer:
9         - foreman
10
11     jobs:
12         - 'genesis-{installer}-verify'
13         - 'genesis-{installer}-merge'
14         - 'genesis-{installer}-daily-{stream}'
15         - 'genesis-{installer}-build'
16         - 'genesis-{installer}-deploy'
17
18     # stream:    branch with - in place of / (eg. stable-helium)
19     # branch:    branch (eg. stable/helium)
20     stream:
21         - master:
22             branch: 'master'
23
24
25 ########################
26 # job templates
27 ########################
28
29 - job-template:
30     name: 'genesis-{installer}-verify'
31
32     project-type: freestyle
33
34     node: ericsson-build
35
36     logrotate:
37         daysToKeep: 30
38         numToKeep: 10
39         artifactDaysToKeep: -1
40         artifactNumToKeep: -1
41
42     parameters:
43         - string:
44             name: INSTALLER
45             default: '{installer}'
46             description: "Installer to use."
47         - string:
48             name: BUILD_DIRECTORY
49             default: $WORKSPACE/build_output
50         - string:
51             name: CACHE_DIRECTORY
52             default: '$HOME/opnfv/cache/genesis-{installer}'
53         - string:
54             name: GIT_BASE
55             default: https://gerrit.opnfv.org/gerrit/genesis
56         - project-parameter:
57             project: '{project}'
58         - gerrit-parameter:
59             branch: 'master'
60
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: '**/master'
89                 file-paths:
90                   - compare-type: ANT
91                     pattern: 'common/**'
92                   - compare-type: ANT
93                     pattern: '{installer}/**'
94
95
96     builders:
97         - 'verify'
98
99 - job-template:
100     name: 'genesis-{installer}-merge'
101
102     # builder-merge job to run JJB update
103     #
104     # This job's purpose is to update all the JJB
105
106     project-type: freestyle
107
108     node: ericsson-build
109
110     logrotate:
111         daysToKeep: 30
112         numToKeep: 40
113         artifactDaysToKeep: -1
114         artifactNumToKeep: 5
115
116     parameters:
117         - string:
118             name: INSTALLER
119             default: '{installer}'
120             description: "Installer to use."
121         - string:
122             name: BUILD_DIRECTORY
123             default: $WORKSPACE/build_output
124         - string:
125             name: CACHE_DIRECTORY
126             default: '$HOME/opnfv/cache/genesis-{installer}'
127         - string:
128             name: GIT_BASE
129             default: https://gerrit.opnfv.org/gerrit/genesis
130         - project-parameter:
131             project: '{project}'
132         - gerrit-parameter:
133             branch: 'master'
134
135     scm:
136         - gerrit-trigger-scm:
137             credentials-id: '{ssh-credentials}'
138             refspec: ''
139             choosing-strategy: 'default'
140
141     wrappers:
142         - ssh-agent-credentials:
143             user: '{ssh-credentials}'
144
145     triggers:
146         - gerrit:
147             trigger-on:
148                 - change-merged-event
149                 - comment-added-contains-event:
150                     comment-contains-value: 'remerge'
151             projects:
152               - project-compare-type: 'ANT'
153                 project-pattern: 'genesis'
154                 branches:
155                     - branch-compare-type: 'ANT'
156                       branch-pattern: '**/master'
157                 file-paths:
158                   - compare-type: ANT
159                     pattern: 'common/**'
160                   - compare-type: ANT
161                     pattern: '{installer}/**'
162
163     builders:
164         - 'merge'
165
166 - job-template:
167     name: 'genesis-{installer}-daily-{stream}'
168
169     project-type: freestyle
170
171     node: ericsson-build
172
173     parameters:
174         - string:
175             name: INSTALLER
176             default: '{installer}'
177             description: "Installer to use."
178         - string:
179             name: BUILD_DIRECTORY
180             default: $WORKSPACE/build_output
181             description: "Directory where the build artifact will be located upon the completion of the build."
182         - string:
183             name: CACHE_DIRECTORY
184             default: '$HOME/opnfv/cache/genesis-{installer}'
185         - string:
186             name: GS_URL
187             default: 'artifacts.opnfv.org/genesis/{installer}'
188             description: "URL to Google Storage."
189         - string:
190             name: GIT_BASE
191             default: https://gerrit.opnfv.org/gerrit/genesis
192         - string:
193             name: GERRIT_BRANCH
194             default: origin/master
195             description: "Branch to build, deploy and test."
196         - string:
197             name: GERRIT_REFSPEC
198             default: refs/heads/master
199             description: "Refspec to retrieve."
200
201     scm:
202         - git:
203             skip-tag: true
204             url: $GIT_BASE
205             branches:
206                 - $GERRIT_BRANCH
207             refspec: $GERRIT_REFSPEC
208
209     triggers:
210         - pollscm: '@midnight'
211
212     logrotate:
213         daysToKeep: 30
214         numToKeep: 10
215         artifactDaysToKeep: -1
216         artifactNumToKeep: -1
217
218     builders:
219         - 'daily-master'
220
221
222 - job-template:
223     name: 'genesis-{installer}-build'
224
225     project-type: freestyle
226
227     node: ericsson-build
228
229     logrotate:
230         daysToKeep: 30
231         numToKeep: 10
232         artifactDaysToKeep: -1
233         artifactNumToKeep: -1
234
235     parameters:
236         - genesis-parameters:
237             installer: '{installer}'
238
239     scm:
240         - git:
241             skip-tag: true
242             url: $GIT_BASE
243             branches:
244                 - $GERRIT_BRANCH
245             refspec: $GERRIT_REFSPEC
246
247     builders:
248         - 'build'
249         - 'upload-artifact'
250
251 - job-template:
252     name: 'genesis-{installer}-deploy'
253
254     project-type: freestyle
255
256     node: opnfv-jump-2
257
258     logrotate:
259         daysToKeep: 30
260         numToKeep: 10
261         artifactDaysToKeep: -1
262         artifactNumToKeep: -1
263
264     parameters:
265         - string:
266             name: INSTALLER
267             default: '{installer}'
268             description: "Installer to use."
269         - string:
270             name: GIT_BASE
271             default: https://gerrit.opnfv.org/gerrit/genesis
272             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
273         - string:
274             name: GERRIT_BRANCH
275             default: origin/master
276             description: "Branch to build, deploy and test."
277         - string:
278             name: GERRIT_REFSPEC
279             default: refs/heads/master
280             description: "Refspec to retrieve."
281         - string:
282             name: GS_URL
283             default: 'artifacts.opnfv.org/genesis/{installer}'
284             description: "URL to Google Storage."
285         - string:
286             name: BUILD_DIRECTORY
287             default: $WORKSPACE/build_output
288             description: "Directory where the build artifact will be located upon the completion of the build."
289
290     scm:
291         - git:
292             skip-tag: true
293             url: $GIT_BASE
294             branches:
295                 - $GERRIT_BRANCH
296             refspec: $GERRIT_REFSPEC
297
298     builders:
299         - 'deploy'
300
301 ########################
302 # parameter macros
303 ########################
304 - parameter:
305     name: genesis-parameters
306     parameters:
307         - string:
308             name: INSTALLER
309             default: '{installer}'
310             description: "Installer to use."
311         - string:
312             name: BUILD_DIRECTORY
313             default: $WORKSPACE/build_output
314             description: "Directory where the build artifact will be located upon the completion of the build."
315         - string:
316             name: CACHE_DIRECTORY
317             default: '$HOME/opnfv/cache/genesis-{installer}'
318         - string:
319             name: GIT_BASE
320             default: https://gerrit.opnfv.org/gerrit/genesis
321             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
322         - string:
323             name: GERRIT_BRANCH
324             default: origin/master
325             description: "Branch to build, deploy and test."
326         - string:
327             name: GERRIT_REFSPEC
328             default: refs/heads/master
329             description: "Refspec to retrieve."
330         - string:
331             name: GS_URL
332             default: 'artifacts.opnfv.org/genesis/{installer}'
333             description: "URL to Google Storage."
334
335 ########################
336 # builder macros
337 ########################
338 - builder:
339     name: 'verify'
340     builders:
341         - shell: |
342             #!/bin/bash
343             set -o errexit
344             set -o nounset
345             set -o pipefail
346             set -x
347
348             # get the dependencies - temporary fix for RC0
349             [[ -d $WORKSPACE/$INSTALLER/build ]] || mkdir -p $WORKSPACE/$INSTALLER/build
350             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/$INSTALLER/build/
351
352             # below lines perhaps need to be enabled in order to fetch images from internet
353             # as we are having disk space issues on ericsson-build slave
354             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
355             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
356             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
357
358             # do the build
359             cd $WORKSPACE/$INSTALLER/ci
360             ./build.sh $BUILD_DIRECTORY
361
362             # list the build artifacts
363             ls -al $BUILD_DIRECTORY
364
365             # remove the BUILD_DIRECTORY to reclaim some space
366             /bin/rm -rf $BUILD_DIRECTORY
367
368 - builder:
369     name: 'merge'
370     builders:
371         - shell: |
372             #!/bin/bash
373             set -o errexit
374             set -o nounset
375             set -o pipefail
376             set -x
377
378             # get the dependencies - temporary fix for RC0
379             [[ -d $WORKSPACE/$INSTALLER/build ]] || mkdir -p $WORKSPACE/$INSTALLER/build
380             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/$INSTALLER/build/
381
382             # below lines perhaps need to be enabled in order to fetch images from internet
383             # as we are having disk space issues on ericsson-build slave
384             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
385             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
386             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
387
388             # do the build
389             cd $WORKSPACE/$INSTALLER/ci
390             ./build.sh $BUILD_DIRECTORY
391
392             # list the build artifacts
393             ls -al $BUILD_DIRECTORY
394
395             # remove the BUILD_DIRECTORY to reclaim some space
396             /bin/rm -rf $BUILD_DIRECTORY
397
398 - builder:
399     name: 'daily-master'
400     builders:
401         - shell: |
402             #!/bin/bash
403             set -o errexit
404             set -o nounset
405             set -o pipefail
406             set -x
407
408             # get the dependencies - temporary fix for RC0
409             [[ -d $WORKSPACE/$INSTALLER/build ]] || mkdir -p $WORKSPACE/$INSTALLER/build
410             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/$INSTALLER/build/
411
412             # below lines perhaps need to be enabled in order to fetch images from internet
413             # as we are having disk space issues on ericsson-build slave
414             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
415             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
416             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
417
418             # do the build
419             cd $WORKSPACE/$INSTALLER/ci
420             ./build.sh -v $BUILD_ID $BUILD_DIRECTORY
421
422         - shell: |
423             #!/bin/bash
424             set -o errexit
425             set -o nounset
426             set -o pipefail
427             set -x
428
429             # list the build artifacts
430             ls -al $BUILD_DIRECTORY
431
432             cd $BUILD_DIRECTORY
433
434             # save information regarding artifact into file
435             (
436                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
437                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
438                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$BUILD_ID.iso"
439                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum opnfv-$ARTIFACT_VERSION.iso | cut -d' ' -f1)"
440                 echo "OPNFV_BUILD_URL=$BUILD_URL"
441                 echo "OPNFV_BUILD=OK"
442             ) > opnfv-$BUILD_ID.properties
443
444             # copy artifact property file as latest.properties
445             # so we can directly get info regarding latest artifact
446             /bin/cp -f opnfv-$BUILD_ID.properties latest.properties
447
448             # upload artifact and additional files to google storage
449             gsutil cp OPNFV-CentOS-7-x86_64-$BUILD_ID.iso gs://$GS_URL/opnfv-$BUILD_ID.iso
450             gsutil cp opnfv-$BUILD_ID.properties gs://$GS_URL/opnfv-$BUILD_ID.properties
451             gsutil cp latest.properties gs://$GS_URL/latest.properties
452
453         - shell: |
454             #!/bin/bash
455             set -o errexit
456             set -o nounset
457             set -o pipefail
458             set -x
459
460             # get the latest.properties file in order to get info regarding latest artifact
461             gsutil cp gs://$GS_URL/latest.properties latest.properties
462
463             # check if we got the file
464             [[ -f latest.properties ]] || exit 1
465
466             # source the file so we get OPNFV vars
467             source latest.properties
468
469             # download the file
470             gsutil cp gs://$OPNFV_ARTIFACT_URL $WORKSPACE/opnfv.iso
471
472             # list the file
473             ls -al $WORKSPACE/opnfv.iso
474
475             # remove the BUILD_DIRECTORY and downlaoded artifact to reclaim some space
476             /bin/rm -rf $BUILD_DIRECTORY
477             /bin/rm -rf $WORKSPACE/opnfv.iso
478
479 - builder:
480     name: 'build'
481     builders:
482         - shell: |
483             #!/bin/bash
484             set -o errexit
485             set -o nounset
486             set -o pipefail
487             set -x
488
489             # create the cache directory if it doesn't exist
490             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
491
492             # set ARTIFACT_VERSION
493             export ARTIFACT_VERSION=$(date +"%Y-%m-%d_%H-%M-%S")
494
495             # start the build
496             cd $WORKSPACE/$INSTALLER/ci
497             ./build.sh -v $ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
498
499 - builder:
500     name: 'upload-artifact'
501     builders:
502         - shell: |
503             #!/bin/bash
504             set -o errexit
505             set -o nounset
506             set -o pipefail
507             set -x
508
509             # list the build output
510             ls -al $BUILD_DIRECTORY
511
512 - builder:
513     name: 'deploy'
514     builders:
515         - shell: |
516             #!/bin/bash
517             set -o errexit
518             set -o nounset
519             set -o pipefail
520             set -x
521
522             # cleanup first
523             sudo $WORKSPACE/$INSTALLER/ci/clean.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
524
525             # and then initiate deployment
526             sudo $WORKSPACE/$INSTALLER/ci/deploy.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml