Convert execute shell parts to macros and unify parameters
[releng.git] / jjb / genesis / genesis-fuel.yml
1 # this is the job configuration for bgs
2 - project:
3
4     name: genesis-fuel
5
6     installer:
7         - fuel
8     jobs:
9         - 'genesis-fuel-verify'
10         - 'genesis-fuel-merge'
11         - 'genesis-fuel-daily-{stream}'
12
13     # stream:    branch with - in place of / (eg. stable-helium)
14     # branch:    branch (eg. stable/helium)
15     stream:
16         - master:
17             branch: 'master'
18
19     project: 'genesis'
20
21 ########################
22 # job templates
23 ########################
24
25 - job-template:
26     name: 'genesis-fuel-verify'
27
28     project-type: freestyle
29
30     node: ericsson-build
31
32     logrotate:
33         daysToKeep: 30
34         numToKeep: 10
35         artifactDaysToKeep: -1
36         artifactNumToKeep: -1
37
38     parameters:
39         - string:
40             name: GIT_BASE
41             default: https://gerrit.opnfv.org/gerrit/genesis
42             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
43         - string:
44             name: GS_URL
45             default: 'artifacts.opnfv.org/genesis/fuel'
46             description: "URL to Google Storage."
47         - string:
48             name: BUILD_DIRECTORY
49             default: $WORKSPACE/build_output
50             description: "Directory where the build artifact will be located upon the completion of the build."
51         - string:
52             name: CACHE_DIRECTORY
53             default: $HOME/opnfv/cache/genesis-fuel
54             description: "Cache location that is where the cache is populated and used during builds to reduce the build time."
55         - string:
56             name: ARTIFACT_VERSION
57             default: $BUILD_ID
58             description: "Version number to append to resulting ISO."
59         - gerrit-parameter:
60             branch: 'master'
61
62     scm:
63         - gerrit-trigger-scm:
64             credentials-id: '{ssh-credentials}'
65             refspec: '$GERRIT_REFSPEC'
66             choosing-strategy: 'gerrit'
67
68     wrappers:
69         - ssh-agent-credentials:
70             user: '{ssh-credentials}'
71
72     triggers:
73         - gerrit:
74             trigger-on:
75                 - patchset-created-event:
76                     exclude-drafts: 'false'
77                     exclude-trivial-rebase: 'false'
78                     exclude-no-code-change: 'false'
79                 - draft-published-event
80                 - comment-added-contains-event:
81                     comment-contains-value: 'recheck'
82                 - comment-added-contains-event:
83                     comment-contains-value: 'reverify'
84             projects:
85               - project-compare-type: 'ANT'
86                 project-pattern: 'genesis'
87                 branches:
88                   - branch-compare-type: 'ANT'
89                     branch-pattern: '**/master'
90                 file-paths:
91                   - compare-type: ANT
92                     pattern: 'common/**'
93                   - compare-type: ANT
94                     pattern: 'fuel/**'
95
96
97     builders:
98         - 'installer-build'
99         - 'installer-cleanup'
100
101 - job-template:
102     name: 'genesis-fuel-merge'
103
104     # builder-merge job to run JJB update
105     #
106     # This job's purpose is to update all the JJB
107
108     project-type: freestyle
109
110     node: ericsson-build
111
112     logrotate:
113         daysToKeep: 30
114         numToKeep: 40
115         artifactDaysToKeep: -1
116         artifactNumToKeep: 5
117
118     parameters:
119         - string:
120             name: GIT_BASE
121             default: https://gerrit.opnfv.org/gerrit/genesis
122             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
123         - string:
124             name: GS_URL
125             default: 'artifacts.opnfv.org/genesis/fuel'
126             description: "URL to Google Storage."
127         - string:
128             name: BUILD_DIRECTORY
129             default: $WORKSPACE/build_output
130             description: "Directory where the build artifact will be located upon the completion of the build."
131         - string:
132             name: CACHE_DIRECTORY
133             default: $HOME/opnfv/cache/genesis-fuel
134             description: "Cache location that is where the cache is populated and used during builds to reduce the build time."
135         - string:
136             name: ARTIFACT_VERSION
137             default: $BUILD_ID
138             description: "Version number to append to resulting ISO."
139         - gerrit-parameter:
140             branch: 'master'
141
142     scm:
143         - gerrit-trigger-scm:
144             credentials-id: '{ssh-credentials}'
145             refspec: ''
146             choosing-strategy: 'default'
147
148     wrappers:
149         - ssh-agent-credentials:
150             user: '{ssh-credentials}'
151
152     triggers:
153         - gerrit:
154             trigger-on:
155                 - change-merged-event
156                 - comment-added-contains-event:
157                     comment-contains-value: 'remerge'
158             projects:
159               - project-compare-type: 'ANT'
160                 project-pattern: 'genesis'
161                 branches:
162                     - branch-compare-type: 'ANT'
163                       branch-pattern: '**/master'
164                 file-paths:
165                   - compare-type: ANT
166                     pattern: 'common/**'
167                   - compare-type: ANT
168                     pattern: 'fuel/**'
169
170     builders:
171         - 'installer-build'
172         - 'installer-cleanup'
173
174 - job-template:
175     name: 'genesis-fuel-daily-{stream}'
176
177     project-type: freestyle
178
179     node: ericsson-build
180
181     parameters:
182         - string:
183             name: GIT_BASE
184             default: https://gerrit.opnfv.org/gerrit/genesis
185             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
186         - string:
187             name: GS_URL
188             default: 'artifacts.opnfv.org/genesis/fuel'
189             description: "URL to Google Storage."
190         - string:
191             name: BUILD_DIRECTORY
192             default: $WORKSPACE/build_output
193             description: "Directory where the build artifact will be located upon the completion of the build."
194         - string:
195             name: CACHE_DIRECTORY
196             default: $HOME/opnfv/cache/genesis-fuel
197             description: "Cache location that is where the cache is populated and used during builds to reduce the build time."
198         - string:
199             name: ARTIFACT_VERSION
200             default: $BUILD_ID
201             description: "Version number to append to resulting ISO."
202
203     scm:
204         - git:
205             skip-tag: true
206             url: $GIT_BASE
207             branches:
208                 - $GERRIT_BRANCH
209             refspec: $GERRIT_REFSPEC
210
211     triggers:
212         - pollscm: '@midnight'
213
214     logrotate:
215         daysToKeep: 30
216         numToKeep: 10
217         artifactDaysToKeep: -1
218         artifactNumToKeep: -1
219
220     builders:
221         - 'installer-build'
222         - 'installer-upload-artifact'
223         - 'installer-download-artifact'
224         - 'installer-deploy'
225         - 'installer-test'
226         - 'installer-cleanup'
227
228
229 - builder:
230     name: installer-build
231     builders:
232         - shell: |
233             #!/bin/bash
234             set -o errexit
235             set -o nounset
236             set -o pipefail
237             set -x
238
239             # set/create the cache location
240             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
241
242             # do the build
243             cd $WORKSPACE/fuel/ci
244             ./build.sh -v $ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
245
246             # list the build artifacts
247             ls -al $BUILD_DIRECTORY
248
249 - builder:
250     name: installer-deploy
251     builders:
252         - shell: |
253             #!/bin/bash
254             set -o errexit
255             set -o nounset
256             set -o pipefail
257             set -x
258
259             # we should have the artifact itself downloaded by now
260             # look if it is there
261             if [ -f $WORKSPACE/opnfv.iso ]; then
262                 echo "Artifact fetched!"
263                 ls -al $WORKSPACE/opnfv.iso
264             else
265                 echo "Artifact does not exist!"
266                 exit 1
267             fi
268
269             # we should have the artifact properties file downloaded by now
270             # look if it is there
271             if [ -f $WORKSPACE/latest.properties ]; then
272                 echo "Artifact properties file fetched!"
273                 ls -al $WORKSPACE/latest.properties
274             else
275                 echo "Artifact properties file does not exist!"
276                 exit 1
277             fi
278
279             # source the file so we get OPNFV vars
280             source $WORKSPACE/latest.properties
281
282             # log the info
283             echo "Proceeding with deployment using ISO downloaded from below URL"
284             echo "$OPNFV_ARTIFACT_URL"
285             echo "This artifact was built using $OPNFV_GIT_SHA1 version of repo $OPNFV_GIT_URL"
286
287             # execute deploy.sh
288             echo "Here is where we are supposed to issue deploy.sh"
289
290 - builder:
291     name: installer-test
292     builders:
293         - shell: |
294             #!/bin/bash
295             set -o errexit
296             set -o nounset
297             set -o pipefail
298             set -x
299
300             # run FuncTest
301             echo "Here is where we are supposed to run FuncTest"
302
303 - builder:
304     name: installer-upload-artifact
305     builders:
306         - shell: |
307             #!/bin/bash
308             set -o errexit
309             set -o nounset
310             set -o pipefail
311             set -x
312
313             # change the build directory where ISO is created
314             cd $BUILD_DIRECTORY
315
316             # save information regarding artifact into file
317             (
318                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
319                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
320                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$ARTIFACT_VERSION.iso"
321                 echo "OPNFV_BUILD_URL=$BUILD_URL"
322                 echo "OPNFV_BUILD=OK"
323             ) > opnfv-$ARTIFACT_VERSION.properties
324
325             # copy artifact property file as latest.properties
326             # so we can directly get info regarding latest artifact
327             /bin/cp -f opnfv-$ARTIFACT_VERSION.properties latest.properties
328
329             # upload artifact and additional files to google storage
330             gsutil cp opnfv-$ARTIFACT_VERSION.iso gs://$GS_URL/opnfv-$ARTIFACT_VERSION.iso
331             gsutil cp opnfv-$ARTIFACT_VERSION.properties gs://$GS_URL/opnfv-$ARTIFACT_VERSION.properties
332             gsutil cp latest.properties gs://$GS_URL/latest.properties
333
334 - builder:
335     name: installer-download-artifact
336     builders:
337         - shell: |
338             #!/bin/bash
339             set -o errexit
340             set -o nounset
341             set -o pipefail
342             set -x
343
344             # get the latest.properties file in order to get info regarding latest artifact
345             gsutil cp gs://$GS_URL/latest.properties $WORKSPACE/latest.properties
346
347             # check if we got the file
348             [[ -f latest.properties ]] || exit 1
349
350             # source the file so we get OPNFV vars
351             source latest.properties
352
353             # download the file
354             gsutil cp gs://$OPNFV_ARTIFACT_URL $WORKSPACE/opnfv.iso
355
356             # list the file
357             ls -al $WORKSPACE/opnfv.iso
358
359 - builder:
360     name: installer-cleanup
361     builders:
362         - shell: |
363             #!/bin/bash
364             set -o errexit
365             set -o nounset
366             set -o pipefail
367             set -x
368
369             # delete everything that is in $WORKSPACE
370             /bin/rm -rf $WORKSPACE