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