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