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