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