Modified suoders, Defaults !requiretty
[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         - string:
217             name: BUILD_DIRECTORY
218             default: $WORKSPACE/build_output
219         - string:
220             name: GIT_BASE
221             default: https://github.com/trozet/bgs_vagrant.git
222             description: "This is a temporary location to clone the needed scripts. Will be replaced with OPNFV Git URL."
223         - string:
224             name: GERRIT_BRANCH
225             default: origin/master
226             description: "Branch to build, deploy and test."
227         - string:
228             name: GERRIT_REFSPEC
229             default: refs/heads/master
230             description: "Refspec to retrieve."
231
232     scm:
233         - git:
234             skip-tag: true
235             url: $GIT_BASE
236             branches:
237                 - $GERRIT_BRANCH
238             refspec: $GERRIT_REFSPEC
239
240     wrappers:
241         - ssh-agent-credentials:
242             user: '{ssh-credentials}'
243
244     builders:
245         - 'foreman-deploy'
246
247 ########################
248 # builder macros
249 ########################
250 - builder:
251     name: foreman-verify
252     builders:
253         - shell: |
254             #!/bin/bash
255             set -o errexit
256             set -o nounset
257             set -o pipefail
258             set -x
259
260             # get the dependencies - temporary fix for RC0
261             [[ -d $WORKSPACE/foreman/build ]] || mkdir -p $WORKSPACE/foreman/build
262             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/foreman/build/
263
264             # below lines perhaps need to be enabled in order to fetch images from internet
265             # as we are having disk space issues on ericsson-build slave
266             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
267             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
268             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
269
270             # do the build
271             cd $WORKSPACE/foreman/ci
272             ./build.sh $BUILD_DIRECTORY
273
274             # list the build artifacts
275             ls -al $BUILD_DIRECTORY
276
277             # remove the BUILD_DIRECTORY to reclaim some space
278             /bin/rm -rf $BUILD_DIRECTORY
279
280 - builder:
281     name: foreman-merge
282     builders:
283         - shell: |
284             #!/bin/bash
285             set -o errexit
286             set -o nounset
287             set -o pipefail
288             set -x
289
290             # get the dependencies - temporary fix for RC0
291             [[ -d $WORKSPACE/foreman/build ]] || mkdir -p $WORKSPACE/foreman/build
292             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/foreman/build/
293
294             # below lines perhaps need to be enabled in order to fetch images from internet
295             # as we are having disk space issues on ericsson-build slave
296             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
297             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
298             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
299
300             # do the build
301             cd $WORKSPACE/foreman/ci
302             ./build.sh $BUILD_DIRECTORY
303
304             # list the build artifacts
305             ls -al $BUILD_DIRECTORY
306
307             # remove the BUILD_DIRECTORY to reclaim some space
308             /bin/rm -rf $BUILD_DIRECTORY
309
310 - builder:
311     name: foreman-daily-master
312     builders:
313         - shell: |
314             #!/bin/bash
315             set -o errexit
316             set -o nounset
317             set -o pipefail
318             set -x
319
320             # get the dependencies - temporary fix for RC0
321             [[ -d $WORKSPACE/foreman/build ]] || mkdir -p $WORKSPACE/foreman/build
322             cp /home/jenkins/Downloads/opnfv_iso/* $WORKSPACE/foreman/build/
323
324             # below lines perhaps need to be enabled in order to fetch images from internet
325             # as we are having disk space issues on ericsson-build slave
326             #wget http://ftp.riken.jp/Linux/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
327             #wget http://download.virtualbox.org/virtualbox/rpm/fedora/20/x86_64/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
328             #wget http://repos.duss-janser.ch/vagrant/vagrant_1.7.2_x86_64.rpm
329
330             # do the build
331             cd $WORKSPACE/foreman/ci
332             ./build.sh -v $BUILD_ID $BUILD_DIRECTORY
333
334         - shell: |
335             #!/bin/bash
336             set -o errexit
337             set -o nounset
338             set -o pipefail
339             set -x
340
341             # list the build artifacts
342             ls -al $BUILD_DIRECTORY
343
344             cd $BUILD_DIRECTORY
345
346             # save information regarding artifact into file
347             (
348                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
349                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
350                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$BUILD_ID.iso"
351                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum opnfv-$ARTIFACT_VERSION.iso | cut -d' ' -f1)"
352                 echo "OPNFV_BUILD_URL=$BUILD_URL"
353                 echo "OPNFV_BUILD=OK"
354             ) > opnfv-$BUILD_ID.properties
355
356             # copy artifact property file as latest.properties
357             # so we can directly get info regarding latest artifact
358             /bin/cp -f opnfv-$BUILD_ID.properties latest.properties
359
360             # upload artifact and additional files to google storage
361             gsutil cp OPNFV-CentOS-7-x86_64-$BUILD_ID.iso gs://$GS_URL/opnfv-$BUILD_ID.iso
362             gsutil cp opnfv-$BUILD_ID.properties gs://$GS_URL/opnfv-$BUILD_ID.properties
363             gsutil cp latest.properties gs://$GS_URL/latest.properties
364
365         - shell: |
366             #!/bin/bash
367             set -o errexit
368             set -o nounset
369             set -o pipefail
370             set -x
371
372             # get the latest.properties file in order to get info regarding latest artifact
373             gsutil cp gs://$GS_URL/latest.properties latest.properties
374
375             # check if we got the file
376             [[ -f latest.properties ]] || exit 1
377
378             # source the file so we get OPNFV vars
379             source latest.properties
380
381             # download the file
382             gsutil cp gs://$OPNFV_ARTIFACT_URL $WORKSPACE/opnfv.iso
383
384             # list the file
385             ls -al $WORKSPACE/opnfv.iso
386
387             # remove the BUILD_DIRECTORY and downlaoded artifact to reclaim some space
388             /bin/rm -rf $BUILD_DIRECTORY
389             /bin/rm -rf $WORKSPACE/opnfv.iso
390
391 - builder:
392     name: foreman-deploy
393     builders:
394         - shell: |
395             #!/bin/bash
396             set -o errexit
397             set -o nounset
398             set -o pipefail
399             set -x
400
401             cd $WORKSPACE
402
403             # fix PATH
404             export PATH=/usr/sbin:$PATH
405             echo $PATH
406
407             # messy workaround
408             git clone https://gist.github.com/4f2eb87d8c9937ee19f0.git lf_settings
409             ls -al $WORKSPACE/lf_settings
410
411             # cleanup first
412             sudo $WORKSPACE/clean.sh -base_config $WORKSPACE/lf_settings/lf_pod2_ksgen_settings.yml
413
414             # and then initiate deployment
415             sudo $WORKSPACE/deploy.sh -base_config $WORKSPACE/lf_settings/lf_pod2_ksgen_settings.yml