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