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