5d9720e1357c645c44692c99e92bd7758d7e7c0b
[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         - genesis-parameters:
175             installer: '{installer}'
176
177     scm:
178         - git:
179             skip-tag: true
180             url: $GIT_BASE
181             branches:
182                 - $GERRIT_BRANCH
183             refspec: $GERRIT_REFSPEC
184
185     triggers:
186         - pollscm: '@midnight'
187
188     logrotate:
189         daysToKeep: 30
190         numToKeep: 10
191         artifactDaysToKeep: -1
192         artifactNumToKeep: -1
193
194     builders:
195         - trigger-builds:
196           - project: 'genesis-{installer}-build'
197             git-revision: true
198             block: true
199
200 - job-template:
201     name: 'genesis-{installer}-build'
202
203     project-type: freestyle
204
205     node: ericsson-build
206
207     logrotate:
208         daysToKeep: 30
209         numToKeep: 10
210         artifactDaysToKeep: -1
211         artifactNumToKeep: -1
212
213     parameters:
214         - genesis-parameters:
215             installer: '{installer}'
216
217     scm:
218         - git:
219             skip-tag: true
220             url: $GIT_BASE
221             branches:
222                 - $GERRIT_BRANCH
223             refspec: $GERRIT_REFSPEC
224
225     builders:
226         - 'build'
227         - 'upload-artifact'
228
229 - job-template:
230     name: 'genesis-{installer}-deploy'
231
232     project-type: freestyle
233
234     node: opnfv-jump-2
235
236     logrotate:
237         daysToKeep: 30
238         numToKeep: 10
239         artifactDaysToKeep: -1
240         artifactNumToKeep: -1
241
242     parameters:
243         - string:
244             name: INSTALLER
245             default: '{installer}'
246             description: "Installer to use."
247         - string:
248             name: GIT_BASE
249             default: https://gerrit.opnfv.org/gerrit/genesis
250             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
251         - string:
252             name: GERRIT_BRANCH
253             default: origin/master
254             description: "Branch to build, deploy and test."
255         - string:
256             name: GERRIT_REFSPEC
257             default: refs/heads/master
258             description: "Refspec to retrieve."
259         - string:
260             name: GS_URL
261             default: 'artifacts.opnfv.org/genesis/{installer}'
262             description: "URL to Google Storage."
263         - string:
264             name: BUILD_DIRECTORY
265             default: $WORKSPACE/build_output
266             description: "Directory where the build artifact will be located upon the completion of the build."
267
268     scm:
269         - git:
270             skip-tag: true
271             url: $GIT_BASE
272             branches:
273                 - $GERRIT_BRANCH
274             refspec: $GERRIT_REFSPEC
275
276     builders:
277         - 'deploy'
278
279 ########################
280 # parameter macros
281 ########################
282 - parameter:
283     name: genesis-parameters
284     parameters:
285         - string:
286             name: INSTALLER
287             default: '{installer}'
288             description: "Installer to use."
289         - string:
290             name: BUILD_DIRECTORY
291             default: $WORKSPACE/build_output
292             description: "Directory where the build artifact will be located upon the completion of the build."
293         - string:
294             name: CACHE_DIRECTORY
295             default: '$HOME/opnfv/cache/genesis-{installer}'
296         - string:
297             name: GIT_BASE
298             default: https://gerrit.opnfv.org/gerrit/genesis
299             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
300         - string:
301             name: GERRIT_BRANCH
302             default: origin/master
303             description: "Branch to build, deploy and test."
304         - string:
305             name: GERRIT_REFSPEC
306             default: refs/heads/master
307             description: "Refspec to retrieve."
308         - string:
309             name: GS_URL
310             default: 'artifacts.opnfv.org/genesis/{installer}'
311             description: "URL to Google Storage."
312
313 ########################
314 # builder macros
315 ########################
316 - builder:
317     name: 'verify'
318     builders:
319         - shell: |
320             #!/bin/bash
321             set -o errexit
322             set -o nounset
323             set -o pipefail
324             set -x
325
326             # get the dependencies - temporary fix for RC0
327             [[ -d $WORKSPACE/$INSTALLER/build ]] || mkdir -p $WORKSPACE/$INSTALLER/build
328             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/$INSTALLER/build/
329
330             # below lines perhaps need to be enabled in order to fetch images from internet
331             # as we are having disk space issues on ericsson-build slave
332             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
333             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
334             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
335
336             # do the build
337             cd $WORKSPACE/$INSTALLER/ci
338             ./build.sh $BUILD_DIRECTORY
339
340             # list the build artifacts
341             ls -al $BUILD_DIRECTORY
342
343             # remove the BUILD_DIRECTORY to reclaim some space
344             /bin/rm -rf $BUILD_DIRECTORY
345
346 - builder:
347     name: 'merge'
348     builders:
349         - shell: |
350             #!/bin/bash
351             set -o errexit
352             set -o nounset
353             set -o pipefail
354             set -x
355
356             # get the dependencies - temporary fix for RC0
357             [[ -d $WORKSPACE/$INSTALLER/build ]] || mkdir -p $WORKSPACE/$INSTALLER/build
358             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/$INSTALLER/build/
359
360             # below lines perhaps need to be enabled in order to fetch images from internet
361             # as we are having disk space issues on ericsson-build slave
362             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
363             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
364             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
365
366             # do the build
367             cd $WORKSPACE/$INSTALLER/ci
368             ./build.sh $BUILD_DIRECTORY
369
370             # list the build artifacts
371             ls -al $BUILD_DIRECTORY
372
373             # remove the BUILD_DIRECTORY to reclaim some space
374             /bin/rm -rf $BUILD_DIRECTORY
375
376 - builder:
377     name: 'build'
378     builders:
379         - shell: |
380             #!/bin/bash
381             set -o errexit
382             set -o nounset
383             set -o pipefail
384             set -x
385
386             # log info to console
387             echo "Starting build of $INSTALLER. This could take some time..."
388             echo "--------------------------------------------------------"
389             echo
390
391             # create the cache directory if it doesn't exist
392             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
393
394             # set ARTIFACT_VERSION
395             export ARTIFACT_VERSION=$(date +"%Y-%m-%d_%H-%M-%S")
396
397             # start the build
398             cd $WORKSPACE/$INSTALLER/ci
399             ./build.sh -v $ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
400
401             # save information regarding artifact into file
402             (
403                 echo "OPNFV_ARTIFACT_VERSION=$ARTIFACT_VERSION"
404                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
405                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
406                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$ARTIFACT_VERSION.iso"
407                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum opnfv-$ARTIFACT_VERSION.iso | cut -d' ' -f1)"
408                 echo "OPNFV_BUILD_URL=$BUILD_URL"
409                 echo "OPNFV_BUILD=OK"
410             ) > $WORKSPACE/opnfv.properties
411
412             echo
413             echo "--------------------------------------------------------"
414             echo "Done!"
415
416 - builder:
417     name: 'upload-artifact'
418     builders:
419         - shell: |
420             #!/bin/bash
421             set -o errexit
422             set -o nounset
423             set -o pipefail
424             set -x
425
426             # log info to console
427             echo "Uploading artifact. This could take some time..."
428             echo "--------------------------------------------------------"
429             echo
430
431             # list the build output
432             ls -al $BUILD_DIRECTORY
433
434             # source the opnfv.properties to get ARTIFACT_VERSION
435             source $WORKSPACE/opnfv.properties
436
437             # copy artifact property file as latest.properties
438             # so we can directly get info regarding latest artifact
439             /bin/cp -f $WORKSPACE/opnfv.properties $WORKSPACE/latest.properties
440
441             # upload artifact and additional files to google storage
442             echo "gsutil cp $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$ARTIFACT_VERSION.iso gs://$GS_URL/opnfv-$ARTIFACT_VERSION.iso"
443             echo "gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$ARTIFACT_VERSION.properties"
444             echo "gsutil cp $WORKSPACE/latest.properties gs://$GS_URL/latest.properties"
445
446             echo
447             echo "--------------------------------------------------------"
448             echo "Done!"
449
450 - builder:
451     name: 'deploy'
452     builders:
453         - shell: |
454             #!/bin/bash
455             set -o errexit
456             set -o nounset
457             set -o pipefail
458             set -x
459
460             # cleanup first
461             sudo $WORKSPACE/$INSTALLER/ci/clean.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
462
463             # and then initiate deployment
464             sudo $WORKSPACE/$INSTALLER/ci/deploy.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml