Adds lab reconfig to JJB for Foreman
[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         - 'fuel-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     triggers:
168         - 'foreman-{stream}'
169
170     parameters:
171         - project-parameter:
172             project: '{project}'
173         - foreman-parameter:
174             installer: '{installer}'
175             gs-pathname: '{gs-pathname}'
176     scm:
177         - git-scm:
178             credentials-id: '{ssh-credentials}'
179             refspec: ''
180             branch: '{branch}'
181
182     logrotate:
183         daysToKeep: 30
184         numToKeep: 10
185         artifactDaysToKeep: -1
186         artifactNumToKeep: -1
187
188     builders:
189         - trigger-builds:
190           - project: 'genesis-foreman-build-{stream}'
191             git-revision: true
192             block: true
193         - trigger-builds:
194           - project: 'genesis-foreman-deploy-{stream}'
195             git-revision: true
196             block: true
197         - trigger-builds:
198           - project: 'functest-opnfv-jump-2'
199             block: true
200         - trigger-builds:
201           - project: 'yardstick-opnfv-jump-2'
202             block: true
203
204 - job-template:
205     name: 'genesis-foreman-build-{stream}'
206
207     project-type: freestyle
208
209     node: ericsson-build
210
211     logrotate:
212         daysToKeep: 30
213         numToKeep: 10
214         artifactDaysToKeep: -1
215         artifactNumToKeep: -1
216
217     parameters:
218         - project-parameter:
219             project: '{project}'
220         - foreman-parameter:
221             installer: '{installer}'
222             gs-pathname: '{gs-pathname}'
223     scm:
224         - git-scm:
225             credentials-id: '{ssh-credentials}'
226             refspec: ''
227             branch: '{branch}'
228
229     builders:
230         - 'foreman-build'
231         - 'foreman-upload-artifact'
232         - 'fuel-workspace-cleanup'
233
234 - job-template:
235     name: 'genesis-foreman-deploy-{stream}'
236
237     project-type: freestyle
238
239     disabled: false
240
241     node: opnfv-jump-2
242
243     logrotate:
244         daysToKeep: 30
245         numToKeep: 10
246         artifactDaysToKeep: -1
247         artifactNumToKeep: -1
248
249     parameters:
250         - project-parameter:
251             project: '{project}'
252         - foreman-parameter:
253             installer: '{installer}'
254             gs-pathname: '{gs-pathname}'
255         - string:
256             name: GIT_BASE
257             default: ssh://gerrit.opnfv.org:29418/$PROJECT
258             description: "Used for overriding the GIT URL coming from parameters macro."
259
260     scm:
261         - git-scm:
262             credentials-id: '{ssh-credentials}'
263             refspec: ''
264             branch: '{branch}'
265
266     builders:
267         - 'foreman-lab-reconfig'
268         - 'foreman-deploy'
269
270 ########################
271 # parameter macros
272 ########################
273 - parameter:
274     name: foreman-parameter
275     parameters:
276         - string:
277             name: INSTALLER
278             default: '{installer}'
279             description: "Installer to use."
280         - string:
281             name: BUILD_DIRECTORY
282             default: $WORKSPACE/build_output
283             description: "Directory where the build artifact will be located upon the completion of the build."
284         - string:
285             name: CACHE_DIRECTORY
286             default: $HOME/opnfv/cache/genesis-$INSTALLER{gs-pathname}
287             description: "Directory where the cache to be used during the build is located."
288         - string:
289             name: GIT_BASE
290             default: https://gerrit.opnfv.org/gerrit/$PROJECT
291             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
292         - string:
293             name: GS_URL
294             default: artifacts.opnfv.org/$PROJECT/$INSTALLER{gs-pathname}
295             description: "URL to Google Storage."
296
297 ########################
298 # builder macros
299 ########################
300 - builder:
301     name: 'foreman-lab-reconfig'
302     builders:
303         - shell: |
304             #!/bin/bash
305             set -o errexit
306             set -o nounset
307             set -o pipefail
308
309             # check to see if ucs login info file exists
310             if [ -e /home/jenkins-ci/.ssh/ucs_creds ];then
311               source /home/jenkins-ci/.ssh/ucs_creds
312             else
313               echo "Unable to find UCS credentials for LF lab reconfiguration...Exiting"
314               exit 1
315             fi
316
317             # clone releng
318             echo "Cloning releng repo..."
319             if ! GIT_SSL_NO_VERIFY=true git clone https://gerrit.opnfv.org/gerrit/releng; then
320               echo "Unable to clone releng repo...Exiting"
321               exit 1
322             fi
323
324             # log info to console
325             echo "Starting the lab reconfiguration for $INSTALLER..."
326             echo "--------------------------------------------------------"
327             echo
328
329             # create venv
330             sudo $WORKSPACE/releng/utils/lab-reconfiguration/create_venv.sh
331
332             # enter venv
333             source ./venv/bin/activate
334             sudo python $WORKSPACE/releng/utils/lab-reconfiguration/reconfigUcsNet.py $ucs_host -u $ucs_user -p $ucs_password -f $WORKSPACE/releng/utils/lab-reconfiguration/foreman.yaml
335
336             echo
337             echo "--------------------------------------------------------"
338             echo "Done!"
339
340 - builder:
341     name: 'foreman-build'
342     builders:
343         - shell: |
344             #!/bin/bash
345             set -o errexit
346             set -o nounset
347             set -o pipefail
348
349             # log info to console
350             echo "Starting the build of $INSTALLER. This could take some time..."
351             echo "--------------------------------------------------------"
352             echo
353
354             # create the cache directory if it doesn't exist
355             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
356
357             # set OPNFV_ARTIFACT_VERSION
358             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
359
360             # start the build
361             cd $WORKSPACE/$INSTALLER/ci
362             ./build.sh -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
363
364             # list the contents of BUILD_OUTPUT directory
365             ls -al $BUILD_DIRECTORY
366
367             # save information regarding artifact into file
368             (
369                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
370                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
371                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
372                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
373                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
374                 echo "OPNFV_BUILD_URL=$BUILD_URL"
375             ) > $WORKSPACE/opnfv.properties
376
377             echo
378             echo "--------------------------------------------------------"
379             echo "Done!"
380
381 - builder:
382     name: 'foreman-deploy'
383     builders:
384         - shell: |
385             #!/bin/bash
386             set -o errexit
387             set -o nounset
388             set -o pipefail
389
390             # log info to console
391             echo "Starting the deployment using $INSTALLER. This could take some time..."
392             echo "--------------------------------------------------------"
393             echo
394
395             # cleanup first
396             sudo $WORKSPACE/$INSTALLER/ci/clean.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
397
398             # and then initiate deployment
399             sudo $WORKSPACE/$INSTALLER/ci/deploy.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
400
401             echo
402             echo "--------------------------------------------------------"
403             echo "Done!"
404
405 - builder:
406     name: 'foreman-upload-artifact'
407     builders:
408         - shell: |
409             #!/bin/bash
410             set -o errexit
411             set -o nounset
412             set -o pipefail
413
414             # log info to console
415             echo "Uploading the $INSTALLER artifact. This could take some time..."
416             echo "--------------------------------------------------------"
417             echo
418
419             # source the opnfv.properties to get ARTIFACT_VERSION
420             source $WORKSPACE/opnfv.properties
421
422             # upload artifact and additional files to google storage
423             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
424             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
425             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
426
427             echo
428             echo "--------------------------------------------------------"
429             echo "Done!"
430             echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
431
432 - builder:
433     name: 'foreman-workspace-cleanup'
434     builders:
435         - shell: |
436             #!/bin/bash
437             set -o errexit
438             set -o nounset
439             set -o pipefail
440
441             # delete everything that is in $WORKSPACE
442             /bin/rm -rf $WORKSPACE
443
444 ########################
445 # trigger macros
446 ########################
447 - trigger:
448     name: 'foreman-master'
449     triggers:
450         - pollscm: '0 21 * * *'
451
452 - trigger:
453     name: 'foreman-stable-arno'
454     triggers:
455         - pollscm: '0 3 * * *'