Try using project-wide parameters in jjb
[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         - string:
238             name: EXTRA_PARAM
239             default: 'extra_value'
240             description: "Installer to use."
241         - string:
242             name: INSTALLER
243             default: 'overriden_value'
244             description: "Installer to use."
245
246     scm:
247         - git:
248             skip-tag: true
249             url: $GIT_BASE
250             branches:
251                 - $GERRIT_BRANCH
252             refspec: $GERRIT_REFSPEC
253
254     builders:
255         - 'build'
256
257 - job-template:
258     name: 'genesis-{installer}-deploy'
259
260     project-type: freestyle
261
262     node: opnfv-jump-2
263
264     logrotate:
265         daysToKeep: 30
266         numToKeep: 10
267         artifactDaysToKeep: -1
268         artifactNumToKeep: -1
269
270     parameters:
271         - string:
272             name: INSTALLER
273             default: '{installer}'
274             description: "Installer to use."
275         - string:
276             name: GIT_BASE
277             default: https://gerrit.opnfv.org/gerrit/genesis
278             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
279         - string:
280             name: GERRIT_BRANCH
281             default: origin/master
282             description: "Branch to build, deploy and test."
283         - string:
284             name: GERRIT_REFSPEC
285             default: refs/heads/master
286             description: "Refspec to retrieve."
287         - string:
288             name: GS_URL
289             default: 'artifacts.opnfv.org/genesis/{installer}'
290             description: "URL to Google Storage."
291         - string:
292             name: BUILD_DIRECTORY
293             default: $WORKSPACE/build_output
294             description: "Directory where the build artifact will be located upon the completion of the build."
295
296     scm:
297         - git:
298             skip-tag: true
299             url: $GIT_BASE
300             branches:
301                 - $GERRIT_BRANCH
302             refspec: $GERRIT_REFSPEC
303
304     builders:
305         - 'deploy'
306
307 ########################
308 # parameter macros
309 ########################
310 - parameter:
311     name: genesis-parameters
312     parameters:
313         - string:
314             name: INSTALLER
315             default: '{installer}'
316             description: "Installer to use."
317         - string:
318             name: BUILD_DIRECTORY
319             default: $WORKSPACE/build_output
320             description: "Directory where the build artifact will be located upon the completion of the build."
321         - string:
322             name: CACHE_DIRECTORY
323             default: '$HOME/opnfv/cache/genesis-{installer}'
324         - string:
325             name: GIT_BASE
326             default: https://gerrit.opnfv.org/gerrit/genesis
327             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
328         - string:
329             name: GERRIT_BRANCH
330             default: origin/master
331             description: "Branch to build, deploy and test."
332         - string:
333             name: GERRIT_REFSPEC
334             default: refs/heads/master
335             description: "Refspec to retrieve."
336         - string:
337             name: GS_URL
338             default: 'artifacts.opnfv.org/genesis/{installer}'
339             description: "URL to Google Storage."
340
341 ########################
342 # builder macros
343 ########################
344 - builder:
345     name: 'verify'
346     builders:
347         - shell: |
348             #!/bin/bash
349             set -o errexit
350             set -o nounset
351             set -o pipefail
352             set -x
353
354             # get the dependencies - temporary fix for RC0
355             [[ -d $WORKSPACE/$INSTALLER/build ]] || mkdir -p $WORKSPACE/$INSTALLER/build
356             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/$INSTALLER/build/
357
358             # below lines perhaps need to be enabled in order to fetch images from internet
359             # as we are having disk space issues on ericsson-build slave
360             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
361             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
362             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
363
364             # do the build
365             cd $WORKSPACE/$INSTALLER/ci
366             ./build.sh $BUILD_DIRECTORY
367
368             # list the build artifacts
369             ls -al $BUILD_DIRECTORY
370
371             # remove the BUILD_DIRECTORY to reclaim some space
372             /bin/rm -rf $BUILD_DIRECTORY
373
374 - builder:
375     name: 'merge'
376     builders:
377         - shell: |
378             #!/bin/bash
379             set -o errexit
380             set -o nounset
381             set -o pipefail
382             set -x
383
384             # get the dependencies - temporary fix for RC0
385             [[ -d $WORKSPACE/$INSTALLER/build ]] || mkdir -p $WORKSPACE/$INSTALLER/build
386             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/$INSTALLER/build/
387
388             # below lines perhaps need to be enabled in order to fetch images from internet
389             # as we are having disk space issues on ericsson-build slave
390             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
391             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
392             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
393
394             # do the build
395             cd $WORKSPACE/$INSTALLER/ci
396             ./build.sh $BUILD_DIRECTORY
397
398             # list the build artifacts
399             ls -al $BUILD_DIRECTORY
400
401             # remove the BUILD_DIRECTORY to reclaim some space
402             /bin/rm -rf $BUILD_DIRECTORY
403
404 - builder:
405     name: 'daily-master'
406     builders:
407         - shell: |
408             #!/bin/bash
409             set -o errexit
410             set -o nounset
411             set -o pipefail
412             set -x
413
414             # get the dependencies - temporary fix for RC0
415             [[ -d $WORKSPACE/$INSTALLER/build ]] || mkdir -p $WORKSPACE/$INSTALLER/build
416             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/$INSTALLER/build/
417
418             # below lines perhaps need to be enabled in order to fetch images from internet
419             # as we are having disk space issues on ericsson-build slave
420             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
421             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
422             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
423
424             # do the build
425             cd $WORKSPACE/$INSTALLER/ci
426             ./build.sh -v $BUILD_ID $BUILD_DIRECTORY
427
428         - shell: |
429             #!/bin/bash
430             set -o errexit
431             set -o nounset
432             set -o pipefail
433             set -x
434
435             # list the build artifacts
436             ls -al $BUILD_DIRECTORY
437
438             cd $BUILD_DIRECTORY
439
440             # save information regarding artifact into file
441             (
442                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
443                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
444                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$BUILD_ID.iso"
445                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum opnfv-$ARTIFACT_VERSION.iso | cut -d' ' -f1)"
446                 echo "OPNFV_BUILD_URL=$BUILD_URL"
447                 echo "OPNFV_BUILD=OK"
448             ) > opnfv-$BUILD_ID.properties
449
450             # copy artifact property file as latest.properties
451             # so we can directly get info regarding latest artifact
452             /bin/cp -f opnfv-$BUILD_ID.properties latest.properties
453
454             # upload artifact and additional files to google storage
455             gsutil cp OPNFV-CentOS-7-x86_64-$BUILD_ID.iso gs://$GS_URL/opnfv-$BUILD_ID.iso
456             gsutil cp opnfv-$BUILD_ID.properties gs://$GS_URL/opnfv-$BUILD_ID.properties
457             gsutil cp latest.properties gs://$GS_URL/latest.properties
458
459         - shell: |
460             #!/bin/bash
461             set -o errexit
462             set -o nounset
463             set -o pipefail
464             set -x
465
466             # get the latest.properties file in order to get info regarding latest artifact
467             gsutil cp gs://$GS_URL/latest.properties latest.properties
468
469             # check if we got the file
470             [[ -f latest.properties ]] || exit 1
471
472             # source the file so we get OPNFV vars
473             source latest.properties
474
475             # download the file
476             gsutil cp gs://$OPNFV_ARTIFACT_URL $WORKSPACE/opnfv.iso
477
478             # list the file
479             ls -al $WORKSPACE/opnfv.iso
480
481             # remove the BUILD_DIRECTORY and downlaoded artifact to reclaim some space
482             /bin/rm -rf $BUILD_DIRECTORY
483             /bin/rm -rf $WORKSPACE/opnfv.iso
484
485 - builder:
486     name: 'build'
487     builders:
488         - shell: |
489             #!/bin/bash
490             set -o errexit
491             set -o nounset
492             set -o pipefail
493             set -x
494
495             echo "Hello World"
496             env
497
498 - builder:
499     name: 'deploy'
500     builders:
501         - shell: |
502             #!/bin/bash
503             set -o errexit
504             set -o nounset
505             set -o pipefail
506             set -x
507
508             # cleanup first
509             sudo $WORKSPACE/$INSTALLER/ci/clean.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
510
511             # and then initiate deployment
512             sudo $WORKSPACE/$INSTALLER/ci/deploy.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml