90418dbb32f12ce3b4fdf4491e9710b3f8a926e5
[releng.git] / jjb / apex / apex.yml
1 - project:
2     name: apex
3     jobs:
4         - 'apex-verify-{stream}'
5         - 'apex-merge-{stream}'
6         - 'apex-build-{stream}'
7         - 'apex-deploy-virtual-{stream}'
8         - 'apex-deploy-baremetal-{stream}'
9         - 'apex-daily-{stream}'
10
11     # stream:    branch with - in place of / (eg. stable-arno)
12     # branch:    branch (eg. stable/arno)
13     stream:
14         - master:
15             branch: 'master'
16             gs-pathname: ''
17             flags: '-fM'
18             disabled: false
19
20     project: 'apex'
21
22 - job-template:
23     name: 'apex-verify-{stream}'
24
25     node: opnfv-jump-1
26
27     parameters:
28         - apex-parameter:
29             gs-pathname: '{gs-pathname}'
30             flags: '{flags}'
31         - project-parameter:
32             project: '{project}'
33         - gerrit-parameter:
34             branch: '{branch}'
35         - string:
36             name: GIT_BASE
37             default: ssh://gerrit.opnfv.org:29418/$PROJECT
38             description: "Used for overriding the GIT URL coming from parameters macro."
39
40     scm:
41         - gerrit-trigger-scm:
42             credentials-id: '{ssh-credentials}'
43             refspec: '$GERRIT_REFSPEC'
44             choosing-strategy: 'gerrit'
45
46     triggers:
47         - gerrit:
48             trigger-on:
49                 - patchset-created-event:
50                     exclude-drafts: 'false'
51                     exclude-trivial-rebase: 'false'
52                     exclude-no-code-change: 'false'
53                 - draft-published-event
54                 - comment-added-contains-event:
55                     comment-contains-value: 'recheck'
56                 - comment-added-contains-event:
57                     comment-contains-value: 'reverify'
58             projects:
59               - project-compare-type: 'ANT'
60                 project-pattern: 'apex'
61                 branches:
62                   - branch-compare-type: 'ANT'
63                     branch-pattern: '**/master'
64                 forbidden-file-paths:
65                   - compare-type: ANT
66                     pattern: 'docs/**'
67
68     properties:
69         - build-blocker:
70             use-build-blocker: true
71             blocking-jobs:
72                 - "apex-daily.*"
73
74     builders:
75         - 'apex-build'
76         - 'apex-deploy-virtual'
77         - 'apex-workspace-cleanup'
78
79 - job-template:
80     name: 'apex-merge-{stream}'
81
82     # builder-merge job to run JJB update
83     #
84     # This job's purpose is to update all the JJB
85
86     node: opnfv-jump-1
87
88     disabled: true
89
90     parameters:
91         - apex-parameter:
92             gs-pathname: '{gs-pathname}'
93             flags: '{flags}'
94         - project-parameter:
95             project: '{project}'
96         - gerrit-parameter:
97             branch: '{branch}'
98         - string:
99             name: GIT_BASE
100             default: ssh://gerrit.opnfv.org:29418/$PROJECT
101             description: "Used for overriding the GIT URL coming from parameters macro."
102
103     scm:
104         - gerrit-trigger-scm:
105             credentials-id: '{ssh-credentials}'
106             refspec: ''
107             choosing-strategy: 'default'
108
109     triggers:
110         - gerrit:
111             trigger-on:
112                 - change-merged-event
113                 - comment-added-contains-event:
114                     comment-contains-value: 'remerge'
115             projects:
116               - project-compare-type: 'ANT'
117                 project-pattern: 'apex'
118                 branches:
119                     - branch-compare-type: 'ANT'
120                       branch-pattern: '**/master'
121                 forbidden-file-paths:
122                   - compare-type: ANT
123                     pattern: 'docs/**'
124
125     builders:
126         - 'apex-build'
127         - 'apex-deploy-virtual'
128         - 'apex-workspace-cleanup'
129
130 - job-template:
131     name: 'apex-build-{stream}'
132
133     # Job template for builds
134     #
135     # Required Variables:
136     #     stream:    branch with - in place of / (eg. stable)
137     #     branch:    branch (eg. stable)
138     node: opnfv-jump-1
139
140     disabled: false
141
142     parameters:
143         - project-parameter:
144             project: '{project}'
145         - apex-parameter:
146             gs-pathname: '{gs-pathname}'
147             flags: '{flags}'
148         - gerrit-parameter:
149             branch: '{branch}'
150         - string:
151             name: GIT_BASE
152             default: ssh://gerrit.opnfv.org:29418/$PROJECT
153             description: "Used for overriding the GIT URL coming from parameters macro."
154
155     scm:
156         - git-scm:
157             credentials-id: '{ssh-credentials}'
158             refspec: ''
159             branch: '{branch}'
160
161     builders:
162         - 'apex-build'
163         - 'apex-deploy-virtual'
164         - 'apex-upload-artifact'
165         - 'apex-workspace-cleanup'
166
167 - job-template:
168     name: 'apex-deploy-virtual-{stream}'
169
170     # Job template for virtual deployment
171     #
172     # Required Variables:
173     #     stream:    branch with - in place of / (eg. stable)
174     #     branch:    branch (eg. stable)
175     node: opnfv-jump-1
176
177     disabled: false
178
179     scm:
180         - git-scm:
181             credentials-id: '{ssh-credentials}'
182             refspec: ''
183             branch: '{branch}'
184
185     parameters:
186         - project-parameter:
187             project: '{project}'
188         - apex-parameter:
189             gs-pathname: '{gs-pathname}'
190             flags: '{flags}'
191
192     builders:
193         - 'apex-deploy-virtual'
194         - 'apex-workspace-cleanup'
195
196 - job-template:
197     name: 'apex-deploy-baremetal-{stream}'
198
199     # Job template for baremetal deployment
200     #
201     # Required Variables:
202     #     stream:    branch with - in place of / (eg. stable)
203     #     branch:    branch (eg. stable)
204     node: opnfv-jump-1
205
206     disabled: true
207
208     scm:
209         - git-scm:
210             credentials-id: '{ssh-credentials}'
211             refspec: ''
212             branch: '{branch}'
213
214     parameters:
215         - project-parameter:
216             project: '{project}'
217         - apex-parameter:
218             gs-pathname: '{gs-pathname}'
219             flags: '{flags}'
220
221     builders:
222         - 'apex-workspace-cleanup'
223
224 - job-template:
225     name: 'apex-daily-{stream}'
226
227     # Job template for daily build
228     #
229     # Required Variables:
230     #     stream:    branch with - in place of / (eg. stable)
231     #     branch:    branch (eg. stable)
232     node: opnfv-jump-1
233
234     disabled: false
235
236     scm:
237         - git-scm:
238             credentials-id: '{ssh-credentials}'
239             refspec: ''
240             branch: '{branch}'
241
242     parameters:
243         - project-parameter:
244             project: '{project}'
245         - apex-parameter:
246             gs-pathname: '{gs-pathname}'
247             flags: '{flags}'
248
249     properties:
250         - build-blocker:
251             use-build-blocker: true
252             blocking-jobs:
253                 - "apex-daily.*"
254
255     triggers:
256         - 'apex-{stream}'
257
258     builders:
259         - trigger-builds:
260           - project: 'apex-build-{stream}'
261             git-revision: true
262             block: true
263         - trigger-builds:
264           - project: 'apex-deploy-virtual-{stream}'
265             git-revision: true
266             block: true
267         - trigger-builds:
268           - project: 'apex-deploy-baremetal-{stream}'
269         - trigger-builds:
270           - project: 'functest-apex-opnfv-jump-1-daily-{stream}'
271             block: true
272             block-thresholds:
273                 build-step-failure-threshold: 'never'
274                 failure-threshold: 'never'
275                 unstable-threshold: 'FAILURE'
276
277 ########################
278 # parameter macros
279 ########################
280 - parameter:
281     name: apex-parameter
282     parameters:
283         - string:
284             name: ARTIFACT_NAME
285             default: 'latest'
286             description: "RPM Artifact name that will be appended to GS_URL to deploy a specific artifact"
287         - string:
288             name: BUILD_DIRECTORY
289             default: $WORKSPACE/build_output
290             description: "Directory where the build artifact will be located upon the completion of the build."
291         - string:
292             name: CACHE_DIRECTORY
293             default: $HOME/opnfv/cache/{gs-pathname}
294             description: "Directory where the cache to be used during the build is located."
295         - string:
296             name: GIT_BASE
297             default: https://gerrit.opnfv.org/gerrit/$PROJECT
298             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
299         - string:
300             name: GS_URL
301             default: artifacts.opnfv.org/$PROJECT/{gs-pathname}
302             description: "URL to Google Storage."
303         - string:
304             name: FLAGS
305             default: '{flags}'
306             description: "Build Flags"
307
308 ########################
309 # builder macros
310 ########################
311 - builder:
312     name: 'apex-build'
313     builders:
314         - shell: |
315             #!/bin/bash
316             set -o errexit
317             set -o nounset
318             set -o pipefail
319             # log info to console
320             echo "Starting the build of Apex using OpenStack Master packages. This will take some time..."
321             echo "---------------------------------------------------------------------------------------"
322             echo "Build flags for this build are ${FLAGS}"
323             echo "---------------------------------------------------------------------------------------"
324             echo
325             # create the cache directory if it doesn't exist
326             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
327             # set OPNFV_ARTIFACT_VERSION
328             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
329             # start the build
330             cd $WORKSPACE/ci
331             ./build.sh $FLAGS -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
332             RPM_VERSION=$(grep Version $BUILD_DIRECTORY/../build/opnfv-apex.spec | awk '{ print $2 }')-$(echo $OPNFV_ARTIFACT_VERSION | tr -d '_-')
333             # list the contents of BUILD_OUTPUT directory
334             ls -al $BUILD_DIRECTORY
335             # save information regarding artifact into file
336             (
337                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
338                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
339                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
340                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
341                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
342                 echo "OPNFV_SRPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.src.rpm"
343                 echo "OPNFV_RPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.noarch.rpm"
344                 echo "OPNFV_RPM_MD5SUM=$(md5sum $BUILD_DIRECTORY/opnfv-apex-$RPM_VERSION.noarch.rpm | cut -d' ' -f1)"
345                 echo "OPNFV_BUILD_URL=$BUILD_URL"
346             ) > $WORKSPACE/opnfv.properties
347             echo
348             echo "--------------------------------------------------------"
349
350 - builder:
351     name: 'apex-workspace-cleanup'
352     builders:
353         - shell: |
354             #!/bin/bash
355             set -o errexit
356             set -o nounset
357             set -o pipefail
358
359             # delete everything that is in $WORKSPACE
360             /bin/rm -rf $WORKSPACE
361
362 - builder:
363     name: 'apex-upload-artifact'
364     builders:
365         - shell: |
366             #!/bin/bash
367             set -o errexit
368             set -o nounset
369             set -o pipefail
370
371             # log info to console
372             echo "Uploading the Apex artifact. This could take some time..."
373             echo "--------------------------------------------------------"
374             echo
375
376             # source the opnfv.properties to get ARTIFACT_VERSION
377             source $WORKSPACE/opnfv.properties
378
379             # upload artifact and additional files to google storage
380             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
381             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_RPM_URL) gs://$GS_URL/$(basename $OPNFV_RPM_URL) > gsutil.iso.log 2>&1
382             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_SRPM_URL) gs://$GS_URL/$(basename $OPNFV_SRPM_URL) > gsutil.iso.log 2>&1
383             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
384             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
385
386             echo
387             echo "--------------------------------------------------------"
388             echo "Done!"
389             echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
390             echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"
391
392 - builder:
393     name: 'apex-deploy-virtual'
394     builders:
395         - shell: |
396             #!/bin/bash
397             set -o errexit
398             set -o nounset
399             set -o pipefail
400
401             # log info to console
402             echo "Starting the Apex virtual deployment."
403             echo "--------------------------------------------------------"
404             echo
405
406             if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
407                 # if artifact name is passed the pull a
408                 # specific artifact from artifacts.opnfv.org
409                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
410             else
411                 if [[ -f opnfv.properties ]]; then
412                     # if opnfv.properties exists then use the
413                     # local build. Source the file so we get local OPNFV vars
414                     source opnfv.properties
415                     RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
416                 else
417                     # no opnfv.properties means use the latest from artifacts.opnfv.org
418                     # get the latest.properties to get the link to the latest artifact
419                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
420                     [[ -f opnfv.properties ]] || exit 1
421                     # source the file so we get OPNFV vars
422                     source opnfv.properties
423                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
424                 fi
425             fi
426
427             source opnfv.properties
428             RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
429
430             # update / install the new rpm
431             if rpm -q opnfv-apex > /dev/null; then
432                if sudo yum update -y $RPM_INSTALL_PATH | grep "does not update installed package"; then
433                    sudo yum downgrade -y $RPM_INSTALL_PATH;
434                fi
435             else
436                sudo yum install -y $RPM_INSTALL_PATH;
437             fi
438
439             # cleanup virtual machines before we start
440             sudo opnfv-clean
441             # initiate virtual deployment
442             sudo opnfv-deploy -v
443
444             echo
445             echo "--------------------------------------------------------"
446             echo "Done!"
447
448 #######################
449 # trigger macros
450 ########################
451 - trigger:
452     name: 'apex-master'
453     triggers:
454         - timed: '0 3 * * *'