Use variables in foreman.yml file instead of hardcoded installer name
[releng.git] / jjb / genesis / genesis-foreman.yml
1 # this is the job configuration for bgs
2 - project:
3
4     name: genesis-foreman
5
6     installer:
7         - foreman
8
9     jobs:
10         - 'genesis-{installer}-verify'
11         - 'genesis-{installer}-merge'
12         - 'genesis-{installer}-daily-{stream}'
13         - 'genesis-{installer}-deploy'
14
15     # stream:    branch with - in place of / (eg. stable-helium)
16     # branch:    branch (eg. stable/helium)
17     stream:
18         - master:
19             branch: 'master'
20
21     project: 'genesis'
22
23 ########################
24 # job templates
25 ########################
26
27 - job-template:
28     name: 'genesis-{installer}-verify'
29
30     project-type: freestyle
31
32     node: ericsson-build
33
34     logrotate:
35         daysToKeep: 30
36         numToKeep: 10
37         artifactDaysToKeep: -1
38         artifactNumToKeep: -1
39
40     parameters:
41         - string:
42             name: INSTALLER
43             default: '{installer}'
44             description: "Installer to use."
45         - string:
46             name: BUILD_DIRECTORY
47             default: $WORKSPACE/build_output
48         - string:
49             name: GIT_BASE
50             default: https://gerrit.opnfv.org/gerrit/genesis
51         - project-parameter:
52             project: '{project}'
53         - gerrit-parameter:
54             branch: 'master'
55
56     scm:
57         - gerrit-trigger-scm:
58             credentials-id: '{ssh-credentials}'
59             refspec: '$GERRIT_REFSPEC'
60             choosing-strategy: 'gerrit'
61
62     wrappers:
63         - ssh-agent-credentials:
64             user: '{ssh-credentials}'
65
66     triggers:
67         - gerrit:
68             trigger-on:
69                 - patchset-created-event:
70                     exclude-drafts: 'false'
71                     exclude-trivial-rebase: 'false'
72                     exclude-no-code-change: 'false'
73                 - draft-published-event
74                 - comment-added-contains-event:
75                     comment-contains-value: 'recheck'
76                 - comment-added-contains-event:
77                     comment-contains-value: 'reverify'
78             projects:
79               - project-compare-type: 'ANT'
80                 project-pattern: 'genesis'
81                 branches:
82                   - branch-compare-type: 'ANT'
83                     branch-pattern: '**/master'
84                 file-paths:
85                   - compare-type: ANT
86                     pattern: 'common/**'
87                   - compare-type: ANT
88                     pattern: '{installer}/**'
89
90
91     builders:
92         - 'verify'
93
94 - job-template:
95     name: 'genesis-{installer}-merge'
96
97     # builder-merge job to run JJB update
98     #
99     # This job's purpose is to update all the JJB
100
101     project-type: freestyle
102
103     node: ericsson-build
104
105     logrotate:
106         daysToKeep: 30
107         numToKeep: 40
108         artifactDaysToKeep: -1
109         artifactNumToKeep: 5
110
111     parameters:
112         - string:
113             name: INSTALLER
114             default: '{installer}'
115             description: "Installer to use."
116         - string:
117             name: BUILD_DIRECTORY
118             default: $WORKSPACE/build_output
119         - string:
120             name: GIT_BASE
121             default: https://gerrit.opnfv.org/gerrit/genesis
122         - project-parameter:
123             project: '{project}'
124         - gerrit-parameter:
125             branch: 'master'
126
127     scm:
128         - gerrit-trigger-scm:
129             credentials-id: '{ssh-credentials}'
130             refspec: ''
131             choosing-strategy: 'default'
132
133     wrappers:
134         - ssh-agent-credentials:
135             user: '{ssh-credentials}'
136
137     triggers:
138         - gerrit:
139             trigger-on:
140                 - change-merged-event
141                 - comment-added-contains-event:
142                     comment-contains-value: 'remerge'
143             projects:
144               - project-compare-type: 'ANT'
145                 project-pattern: 'genesis'
146                 branches:
147                     - branch-compare-type: 'ANT'
148                       branch-pattern: '**/master'
149                 file-paths:
150                   - compare-type: ANT
151                     pattern: 'common/**'
152                   - compare-type: ANT
153                     pattern: '{installer}/**'
154
155     builders:
156         - 'merge'
157
158 - job-template:
159     name: 'genesis-{installer}-daily-{stream}'
160
161     project-type: freestyle
162
163     node: ericsson-build
164
165     parameters:
166         - string:
167             name: INSTALLER
168             default: '{installer}'
169             description: "Installer to use."
170         - string:
171             name: BUILD_DIRECTORY
172             default: $WORKSPACE/build_output
173             description: "Directory where the build artifact will be located upon the completion of the build."
174         - string:
175             name: GS_URL
176             default: 'artifacts.opnfv.org/genesis/{installer}'
177             description: "URL to Google Storage."
178         - string:
179             name: GIT_BASE
180             default: https://gerrit.opnfv.org/gerrit/genesis
181         - string:
182             name: GERRIT_BRANCH
183             default: origin/master
184             description: "Branch to build, deploy and test."
185         - string:
186             name: GERRIT_REFSPEC
187             default: refs/heads/master
188             description: "Refspec to retrieve."
189
190     scm:
191         - git:
192             skip-tag: true
193             url: $GIT_BASE
194             branches:
195                 - $GERRIT_BRANCH
196             refspec: $GERRIT_REFSPEC
197
198     triggers:
199         - pollscm: '@midnight'
200
201     logrotate:
202         daysToKeep: 30
203         numToKeep: 10
204         artifactDaysToKeep: -1
205         artifactNumToKeep: -1
206
207     builders:
208         - 'daily-master'
209
210
211 - job-template:
212     name: 'genesis-{installer}-deploy'
213
214     project-type: freestyle
215
216     node: opnfv-jump-2
217
218     logrotate:
219         daysToKeep: 30
220         numToKeep: 10
221         artifactDaysToKeep: -1
222         artifactNumToKeep: -1
223
224     parameters:
225         - string:
226             name: INSTALLER
227             default: '{installer}'
228             description: "Installer to use."
229         - string:
230             name: GIT_BASE
231             default: https://gerrit.opnfv.org/gerrit/genesis
232             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
233         - string:
234             name: GERRIT_BRANCH
235             default: origin/master
236             description: "Branch to build, deploy and test."
237         - string:
238             name: GERRIT_REFSPEC
239             default: refs/heads/master
240             description: "Refspec to retrieve."
241         - string:
242             name: GS_URL
243             default: 'artifacts.opnfv.org/genesis/fuel'
244             description: "URL to Google Storage."
245         - string:
246             name: BUILD_DIRECTORY
247             default: $WORKSPACE/build_output
248             description: "Directory where the build artifact will be located upon the completion of the build."
249
250     scm:
251         - git:
252             skip-tag: true
253             url: $GIT_BASE
254             branches:
255                 - $GERRIT_BRANCH
256             refspec: $GERRIT_REFSPEC
257
258     builders:
259         - 'deploy'
260
261 ########################
262 # builder macros
263 ########################
264 - builder:
265     name: 'verify'
266     builders:
267         - shell: |
268             #!/bin/bash
269             set -o errexit
270             set -o nounset
271             set -o pipefail
272             set -x
273
274             # get the dependencies - temporary fix for RC0
275             [[ -d $WORKSPACE/$INSTALLER/build ]] || mkdir -p $WORKSPACE/$INSTALLER/build
276             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/$INSTALLER/build/
277
278             # below lines perhaps need to be enabled in order to fetch images from internet
279             # as we are having disk space issues on ericsson-build slave
280             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
281             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
282             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
283
284             # do the build
285             cd $WORKSPACE/$INSTALLER/ci
286             ./build.sh $BUILD_DIRECTORY
287
288             # list the build artifacts
289             ls -al $BUILD_DIRECTORY
290
291             # remove the BUILD_DIRECTORY to reclaim some space
292             /bin/rm -rf $BUILD_DIRECTORY
293
294 - builder:
295     name: 'merge'
296     builders:
297         - shell: |
298             #!/bin/bash
299             set -o errexit
300             set -o nounset
301             set -o pipefail
302             set -x
303
304             # get the dependencies - temporary fix for RC0
305             [[ -d $WORKSPACE/$INSTALLER/build ]] || mkdir -p $WORKSPACE/$INSTALLER/build
306             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/$INSTALLER/build/
307
308             # below lines perhaps need to be enabled in order to fetch images from internet
309             # as we are having disk space issues on ericsson-build slave
310             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
311             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
312             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
313
314             # do the build
315             cd $WORKSPACE/$INSTALLER/ci
316             ./build.sh $BUILD_DIRECTORY
317
318             # list the build artifacts
319             ls -al $BUILD_DIRECTORY
320
321             # remove the BUILD_DIRECTORY to reclaim some space
322             /bin/rm -rf $BUILD_DIRECTORY
323
324 - builder:
325     name: 'daily-master'
326     builders:
327         - shell: |
328             #!/bin/bash
329             set -o errexit
330             set -o nounset
331             set -o pipefail
332             set -x
333
334             # get the dependencies - temporary fix for RC0
335             [[ -d $WORKSPACE/$INSTALLER/build ]] || mkdir -p $WORKSPACE/$INSTALLER/build
336             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/$INSTALLER/build/
337
338             # below lines perhaps need to be enabled in order to fetch images from internet
339             # as we are having disk space issues on ericsson-build slave
340             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
341             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
342             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
343
344             # do the build
345             cd $WORKSPACE/$INSTALLER/ci
346             ./build.sh -v $BUILD_ID $BUILD_DIRECTORY
347
348         - shell: |
349             #!/bin/bash
350             set -o errexit
351             set -o nounset
352             set -o pipefail
353             set -x
354
355             # list the build artifacts
356             ls -al $BUILD_DIRECTORY
357
358             cd $BUILD_DIRECTORY
359
360             # save information regarding artifact into file
361             (
362                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
363                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
364                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$BUILD_ID.iso"
365                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum opnfv-$ARTIFACT_VERSION.iso | cut -d' ' -f1)"
366                 echo "OPNFV_BUILD_URL=$BUILD_URL"
367                 echo "OPNFV_BUILD=OK"
368             ) > opnfv-$BUILD_ID.properties
369
370             # copy artifact property file as latest.properties
371             # so we can directly get info regarding latest artifact
372             /bin/cp -f opnfv-$BUILD_ID.properties latest.properties
373
374             # upload artifact and additional files to google storage
375             gsutil cp OPNFV-CentOS-7-x86_64-$BUILD_ID.iso gs://$GS_URL/opnfv-$BUILD_ID.iso
376             gsutil cp opnfv-$BUILD_ID.properties gs://$GS_URL/opnfv-$BUILD_ID.properties
377             gsutil cp latest.properties gs://$GS_URL/latest.properties
378
379         - shell: |
380             #!/bin/bash
381             set -o errexit
382             set -o nounset
383             set -o pipefail
384             set -x
385
386             # get the latest.properties file in order to get info regarding latest artifact
387             gsutil cp gs://$GS_URL/latest.properties latest.properties
388
389             # check if we got the file
390             [[ -f latest.properties ]] || exit 1
391
392             # source the file so we get OPNFV vars
393             source latest.properties
394
395             # download the file
396             gsutil cp gs://$OPNFV_ARTIFACT_URL $WORKSPACE/opnfv.iso
397
398             # list the file
399             ls -al $WORKSPACE/opnfv.iso
400
401             # remove the BUILD_DIRECTORY and downlaoded artifact to reclaim some space
402             /bin/rm -rf $BUILD_DIRECTORY
403             /bin/rm -rf $WORKSPACE/opnfv.iso
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             set -x
414
415             cd $WORKSPACE
416
417             # cleanup first
418             sudo $WORKSPACE/$INSTALLER/ci/clean.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
419
420             # and then initiate deployment
421             sudo $WORKSPACE/$INSTALLER/ci/deploy.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml