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