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