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