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