Fixes permissions issue with lab-reconfig
[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             $WORKSPACE/releng/utils/lab-reconfiguration/create_venv.sh
331
332             # disable nounset because 'activate' script contains unbound variable(s)
333             set +o nounset
334             # enter venv
335             source $WORKSPACE/releng/utils/lab-reconfiguration/venv/bin/activate
336             # set nounset back again
337             set -o nounset
338             python $WORKSPACE/releng/utils/lab-reconfiguration/reconfigUcsNet.py -i $ucs_host -u $ucs_user -p $ucs_password -f $WORKSPACE/releng/utils/lab-reconfiguration/foreman.yaml
339
340             echo
341             echo "--------------------------------------------------------"
342             echo "Done!"
343
344 - builder:
345     name: 'foreman-build'
346     builders:
347         - shell: |
348             #!/bin/bash
349             set -o errexit
350             set -o nounset
351             set -o pipefail
352
353             # log info to console
354             echo "Starting the build of $INSTALLER. This could take some time..."
355             echo "--------------------------------------------------------"
356             echo
357
358             # create the cache directory if it doesn't exist
359             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
360
361             # set OPNFV_ARTIFACT_VERSION
362             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
363
364             # start the build
365             cd $WORKSPACE/$INSTALLER/ci
366             ./build.sh -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
367
368             # list the contents of BUILD_OUTPUT directory
369             ls -al $BUILD_DIRECTORY
370
371             # save information regarding artifact into file
372             (
373                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
374                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
375                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
376                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
377                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
378                 echo "OPNFV_BUILD_URL=$BUILD_URL"
379             ) > $WORKSPACE/opnfv.properties
380
381             echo
382             echo "--------------------------------------------------------"
383             echo "Done!"
384
385 - builder:
386     name: 'foreman-deploy'
387     builders:
388         - shell: |
389             #!/bin/bash
390             set -o errexit
391             set -o nounset
392             set -o pipefail
393
394             # log info to console
395             echo "Starting the deployment using $INSTALLER. This could take some time..."
396             echo "--------------------------------------------------------"
397             echo
398
399             # cleanup first
400             sudo $WORKSPACE/$INSTALLER/ci/clean.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
401
402             # and then initiate deployment
403             sudo $WORKSPACE/$INSTALLER/ci/deploy.sh -base_config $WORKSPACE/$INSTALLER/ci/inventory/lf_pod2_ksgen_settings.yml
404
405             echo
406             echo "--------------------------------------------------------"
407             echo "Done!"
408
409 - builder:
410     name: 'foreman-upload-artifact'
411     builders:
412         - shell: |
413             #!/bin/bash
414             set -o errexit
415             set -o nounset
416             set -o pipefail
417
418             # log info to console
419             echo "Uploading the $INSTALLER artifact. This could take some time..."
420             echo "--------------------------------------------------------"
421             echo
422
423             # source the opnfv.properties to get ARTIFACT_VERSION
424             source $WORKSPACE/opnfv.properties
425
426             # upload artifact and additional files to google storage
427             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
428             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
429             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
430
431             echo
432             echo "--------------------------------------------------------"
433             echo "Done!"
434             echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
435
436 - builder:
437     name: 'foreman-workspace-cleanup'
438     builders:
439         - shell: |
440             #!/bin/bash
441             set -o errexit
442             set -o nounset
443             set -o pipefail
444
445             # delete everything that is in $WORKSPACE
446             /bin/rm -rf $WORKSPACE
447
448 ########################
449 # trigger macros
450 ########################
451 - trigger:
452     name: 'foreman-master'
453     triggers:
454         - pollscm: '0 21 * * *'
455
456 - trigger:
457     name: 'foreman-stable-arno'
458     triggers:
459         - pollscm: '0 3 * * *'