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