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