8522644612f35ba2b9afe2272ebb847744f950e1
[releng.git] / jjb / genesis / genesis-foreman.yml
1 ########################
2 # Job configuration for genesis/foreman
3 ########################
4 - project:
5
6     name: genesis-foreman
7
8     project: 'genesis'
9
10     installer: 'foreman'
11
12     jobs:
13         - 'genesis-foreman-verify'
14         - 'genesis-foreman-merge'
15         - 'genesis-foreman-daily-{stream}'
16         - 'genesis-foreman-build'
17         - 'genesis-foreman-deploy'
18
19     stream:
20         - master:
21             branch: 'master'
22
23 ########################
24 # job templates
25 ########################
26
27 - job-template:
28     name: 'genesis-foreman-verify'
29
30     project-type: freestyle
31
32     node: ericsson-build
33
34     concurrent: true
35
36     properties:
37         - throttle:
38             enabled: true
39             max-total: 2
40
41     logrotate:
42         daysToKeep: 30
43         numToKeep: 10
44         artifactDaysToKeep: -1
45         artifactNumToKeep: -1
46
47     parameters:
48         - project-parameter:
49             project: '{project}'
50         - foreman-parameters:
51             installer: '{installer}'
52         - gerrit-parameter:
53             branch: 'master'
54
55     scm:
56         - gerrit-trigger-scm:
57             credentials-id: '{ssh-credentials}'
58             refspec: '$GERRIT_REFSPEC'
59             choosing-strategy: 'gerrit'
60
61     wrappers:
62         - ssh-agent-credentials:
63             user: '{ssh-credentials}'
64
65     triggers:
66         - gerrit:
67             trigger-on:
68                 - patchset-created-event:
69                     exclude-drafts: 'false'
70                     exclude-trivial-rebase: 'false'
71                     exclude-no-code-change: 'false'
72                 - draft-published-event
73                 - comment-added-contains-event:
74                     comment-contains-value: 'recheck'
75                 - comment-added-contains-event:
76                     comment-contains-value: 'reverify'
77             projects:
78               - project-compare-type: 'ANT'
79                 project-pattern: 'genesis'
80                 branches:
81                   - branch-compare-type: 'ANT'
82                     branch-pattern: '**/master'
83                 file-paths:
84                   - compare-type: ANT
85                     pattern: 'common/**'
86                   - compare-type: ANT
87                     pattern: '{installer}/**'
88
89     builders:
90         - 'foreman-build'
91
92 - job-template:
93     name: 'genesis-foreman-merge'
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         - project-parameter:
107             project: '{project}'
108         - foreman-parameters:
109             installer: '{installer}'
110         - gerrit-parameter:
111             branch: 'master'
112
113     scm:
114         - gerrit-trigger-scm:
115             credentials-id: '{ssh-credentials}'
116             refspec: ''
117             choosing-strategy: 'default'
118
119     wrappers:
120         - ssh-agent-credentials:
121             user: '{ssh-credentials}'
122
123     triggers:
124         - gerrit:
125             trigger-on:
126                 - change-merged-event
127                 - comment-added-contains-event:
128                     comment-contains-value: 'remerge'
129             projects:
130               - project-compare-type: 'ANT'
131                 project-pattern: 'genesis'
132                 branches:
133                     - branch-compare-type: 'ANT'
134                       branch-pattern: '**/master'
135                 file-paths:
136                   - compare-type: ANT
137                     pattern: 'common/**'
138                   - compare-type: ANT
139                     pattern: '{installer}/**'
140
141     builders:
142         - 'foreman-build'
143
144 - job-template:
145     name: 'genesis-foreman-daily-{stream}'
146
147     project-type: freestyle
148
149     node: ericsson-build
150
151     disabled: false
152
153     parameters:
154         - project-parameter:
155             project: '{project}'
156         - foreman-parameters:
157             installer: '{installer}'
158
159     scm:
160         - git:
161             skip-tag: true
162             url: $GIT_BASE
163             branches:
164                 - $GERRIT_BRANCH
165             refspec: $GERRIT_REFSPEC
166
167     triggers:
168         - pollscm: '@midnight'
169
170     logrotate:
171         daysToKeep: 30
172         numToKeep: 10
173         artifactDaysToKeep: -1
174         artifactNumToKeep: -1
175
176     builders:
177         - trigger-builds:
178           - project: 'genesis-foreman-build'
179             git-revision: true
180             block: true
181         - trigger-builds:
182           - project: 'genesis-foreman-deploy'
183             git-revision: true
184             block: true
185         - trigger-builds:
186           - project: 'functest-opnfv-jump-2'
187             block: true
188
189 - job-template:
190     name: 'genesis-foreman-build'
191
192     project-type: freestyle
193
194     node: ericsson-build
195
196     logrotate:
197         daysToKeep: 30
198         numToKeep: 10
199         artifactDaysToKeep: -1
200         artifactNumToKeep: -1
201
202     parameters:
203         - project-parameter:
204             project: '{project}'
205         - foreman-parameters:
206             installer: '{installer}'
207
208     scm:
209         - git:
210             skip-tag: true
211             url: $GIT_BASE
212             branches:
213                 - $GERRIT_BRANCH
214             refspec: $GERRIT_REFSPEC
215
216     builders:
217         - 'foreman-build'
218         - 'foreman-upload-artifact'
219
220 - job-template:
221     name: 'genesis-foreman-deploy'
222
223     project-type: freestyle
224
225     disabled: false
226
227     node: opnfv-jump-2
228
229     logrotate:
230         daysToKeep: 30
231         numToKeep: 10
232         artifactDaysToKeep: -1
233         artifactNumToKeep: -1
234
235     parameters:
236         - project-parameter:
237             project: '{project}'
238         - foreman-parameters:
239             installer: '{installer}'
240
241     scm:
242         - git:
243             skip-tag: true
244             url: $GIT_BASE
245             branches:
246                 - $GERRIT_BRANCH
247             refspec: $GERRIT_REFSPEC
248
249     builders:
250         - 'foreman-deploy'
251
252 ########################
253 # parameter macros
254 ########################
255 - parameter:
256     name: foreman-parameters
257     parameters:
258         - string:
259             name: INSTALLER
260             default: '{installer}'
261             description: "Installer to use."
262         - string:
263             name: BUILD_DIRECTORY
264             default: $WORKSPACE/build_output
265             description: "Directory where the build artifact will be located upon the completion of the build."
266         - string:
267             name: CACHE_DIRECTORY
268             default: $HOME/opnfv/cache/genesis-$INSTALLER
269             description: "Directory where the cache to be used during the build is located."
270         - string:
271             name: GIT_BASE
272             default: https://gerrit.opnfv.org/gerrit/$PROJECT
273             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
274         - string:
275             name: GERRIT_BRANCH
276             default: origin/master
277             description: "Branch to build, deploy and test."
278         - string:
279             name: GERRIT_REFSPEC
280             default: refs/heads/master
281             description: "Refspec to retrieve."
282         - string:
283             name: GS_URL
284             default: artifacts.opnfv.org/$PROJECT/$INSTALLER
285             description: "URL to Google Storage."
286
287 ########################
288 # builder macros
289 ########################
290 - builder:
291     name: 'foreman-build'
292     builders:
293         - shell: |
294             #!/bin/bash
295             set -o errexit
296             set -o nounset
297             set -o pipefail
298
299             # log info to console
300             echo "Starting the build of $INSTALLER. This could take some time..."
301             echo "--------------------------------------------------------"
302             echo
303
304             # create the cache directory if it doesn't exist
305             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
306
307             # set OPNFV_ARTIFACT_VERSION
308             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
309
310             # start the build
311             cd $WORKSPACE/$INSTALLER/ci
312             ./build.sh -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
313
314             # list the contents of BUILD_OUTPUT directory
315             ls -al $BUILD_DIRECTORY
316
317             # save information regarding artifact into file
318             (
319                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
320                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
321                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
322                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
323                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
324                 echo "OPNFV_BUILD_URL=$BUILD_URL"
325             ) > $WORKSPACE/opnfv.properties
326
327             echo
328             echo "--------------------------------------------------------"
329             echo "Done!"
330
331 - builder:
332     name: 'foreman-deploy'
333     builders:
334         - shell: |
335             #!/bin/bash
336             set -o errexit
337             set -o nounset
338             set -o pipefail
339
340             # log info to console
341             echo "Starting the deployment using $INSTALLER. This could take some time..."
342             echo "--------------------------------------------------------"
343             echo
344
345             # cleanup first
346             sudo $WORKSPACE/$INSTALLER/ci/clean.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
347
348             # and then initiate deployment
349             sudo $WORKSPACE/$INSTALLER/ci/deploy.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
350
351             echo
352             echo "--------------------------------------------------------"
353             echo "Done!"
354
355 - builder:
356     name: 'foreman-upload-artifact'
357     builders:
358         - shell: |
359             #!/bin/bash
360             set -o errexit
361             set -o nounset
362             set -o pipefail
363
364             # log info to console
365             echo "Uploading the $INSTALLER artifact. This could take some time..."
366             echo "--------------------------------------------------------"
367             echo
368
369             # source the opnfv.properties to get ARTIFACT_VERSION
370             source $WORKSPACE/opnfv.properties
371
372             # upload artifact and additional files to google storage
373             gsutil cp $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
374             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
375             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
376
377             echo
378             echo "--------------------------------------------------------"
379             echo "Done!"