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