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