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