Merge "Create Releng Job for Generating Artifact JSON API"
[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: 'opnfv-jump-1'
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             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         - string:
266             name: OPNFV_CLEAN
267             default: 'no'
268             description: "Use yes in lower case to invoke clean. Indicates if the deploy environment should be cleaned before deployment"
269
270     properties:
271         - build-blocker:
272             use-build-blocker: true
273             blocking-jobs:
274                 - "apex-deploy.*"
275
276     builders:
277         - 'apex-deploy-virtual'
278         - 'apex-workspace-cleanup'
279
280 - job-template:
281     name: 'apex-deploy-baremetal-{scenario}-{stream}'
282
283     # Job template for baremetal deployment
284     #
285     # Required Variables:
286     #     stream:    branch with - in place of / (eg. stable)
287     #     branch:    branch (eg. stable)
288     node: opnfv-jump-1
289
290     disabled: false
291
292     scm:
293         - git-scm:
294             credentials-id: '{ssh-credentials}'
295             refspec: ''
296             branch: '{branch}'
297
298     parameters:
299         - project-parameter:
300             project: '{project}'
301         - apex-parameter:
302             gs-pathname: '{gs-pathname}'
303         - string:
304             name: DEPLOY_SCENARIO
305             default: '{scenario}'
306             description: "Scenario to deploy with."
307
308     properties:
309         - build-blocker:
310             use-build-blocker: true
311             blocking-jobs:
312                 - "apex-verify.*"
313                 - "apex-deploy.*"
314                 - "apex-build.*"
315
316
317     builders:
318         - 'apex-deploy-baremetal'
319         - 'apex-workspace-cleanup'
320
321 - job-template:
322     name: 'apex-daily-{stream}'
323
324     # Job template for daily build
325     #
326     # Required Variables:
327     #     stream:    branch with - in place of / (eg. stable)
328     #     branch:    branch (eg. stable)
329     node: opnfv-jump-1
330
331     disabled: false
332
333     scm:
334         - git-scm:
335             credentials-id: '{ssh-credentials}'
336             refspec: ''
337             branch: '{branch}'
338
339     parameters:
340         - project-parameter:
341             project: '{project}'
342         - apex-parameter:
343             gs-pathname: '{gs-pathname}'
344
345     properties:
346         - build-blocker:
347             use-build-blocker: true
348             blocking-jobs:
349                 - "apex-verify.*"
350                 - "apex-deploy.*"
351                 - "apex-build.*"
352                 - "apex-runner.*"
353
354     triggers:
355         - 'apex-{stream}'
356
357     builders:
358         - trigger-builds:
359           - project: 'apex-build-{stream}'
360             git-revision: true
361             current-parameters: true
362             block: true
363         - trigger-builds:
364           - project: 'apex-deploy-baremetal-os-odl_l2-nofeature-ha-{stream}'
365             predefined-parameters: |
366               BUILD_DIRECTORY=apex-build-{stream}/build_output
367               OPNFV_CLEAN=yes
368             git-revision: true
369             block: true
370         - trigger-builds:
371           - project: 'functest-apex-opnfv-jump-1-daily-{stream}'
372             predefined-parameters:
373               DEPLOY_SCENARIO=os-odl_l2-nofeature-ha
374             block: true
375             block-thresholds:
376                 build-step-failure-threshold: 'never'
377                 failure-threshold: 'never'
378                 unstable-threshold: 'FAILURE'
379         - trigger-builds:
380           - project: 'yardstick-apex-opnfv-jump-1-daily-{stream}'
381             predefined-parameters:
382               DEPLOY_SCENARIO=os-odl_l2-nofeature-ha
383             block: true
384             block-thresholds:
385                 build-step-failure-threshold: 'never'
386                 failure-threshold: 'never'
387                 unstable-threshold: 'FAILURE'
388         - trigger-builds:
389           - project: 'apex-deploy-baremetal-os-onos-nofeature-ha-{stream}'
390             predefined-parameters:
391               BUILD_DIRECTORY=apex-build-{stream}/build_output
392             git-revision: true
393             block: true
394         - trigger-builds:
395           - project: 'functest-apex-opnfv-jump-1-daily-{stream}'
396             predefined-parameters:
397               DEPLOY_SCENARIO=os-onos-nofeature-ha
398             block: true
399             block-thresholds:
400                 build-step-failure-threshold: 'never'
401                 failure-threshold: 'never'
402                 unstable-threshold: 'FAILURE'
403         - trigger-builds:
404           - project: 'yardstick-apex-opnfv-jump-1-daily-{stream}'
405             predefined-parameters:
406               DEPLOY_SCENARIO=os-onos-nofeature-ha
407             block: true
408             block-thresholds:
409                 build-step-failure-threshold: 'never'
410                 failure-threshold: 'never'
411                 unstable-threshold: 'FAILURE'
412         - trigger-builds:
413           - project: 'apex-deploy-baremetal-os-odl_l3-nofeature-ha-{stream}'
414             predefined-parameters:
415               BUILD_DIRECTORY=apex-build-{stream}/build_output
416             git-revision: true
417             block: true
418         - trigger-builds:
419           - project: 'functest-apex-opnfv-jump-1-daily-{stream}'
420             predefined-parameters:
421               DEPLOY_SCENARIO=os-odl_l3-nofeature-ha
422             block: true
423             block-thresholds:
424                 build-step-failure-threshold: 'never'
425                 failure-threshold: 'never'
426                 unstable-threshold: 'FAILURE'
427         - trigger-builds:
428           - project: 'yardstick-apex-opnfv-jump-1-daily-{stream}'
429             predefined-parameters:
430               DEPLOY_SCENARIO=os-odl_l3-nofeature-ha
431             block: true
432             block-thresholds:
433                 build-step-failure-threshold: 'never'
434                 failure-threshold: 'never'
435                 unstable-threshold: 'FAILURE'
436
437 ########################
438 # parameter macros
439 ########################
440 - parameter:
441     name: apex-parameter
442     parameters:
443         - string:
444             name: ARTIFACT_NAME
445             default: 'latest'
446             description: "RPM Artifact name that will be appended to GS_URL to deploy a specific artifact"
447         - string:
448             name: ARTIFACT_VERSION
449             default: 'daily'
450             description: "Artifact version type"
451         - string:
452             name: BUILD_DIRECTORY
453             default: $WORKSPACE/build_output
454             description: "Directory where the build artifact will be located upon the completion of the build."
455         - string:
456             name: CACHE_DIRECTORY
457             default: $HOME/opnfv/cache{gs-pathname}
458             description: "Directory where the cache to be used during the build is located."
459         - string:
460             name: GIT_BASE
461             default: https://gerrit.opnfv.org/gerrit/$PROJECT
462             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
463         - string:
464             name: GS_URL
465             default: artifacts.opnfv.org/$PROJECT{gs-pathname}
466             description: "URL to Google Storage."
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="-v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY"
490               else
491                 export OPNFV_ARTIFACT_VERSION=dev${BUILD_NUMBER}
492                 export BUILD_ARGS="-r $OPNFV_ARTIFACT_VERSION -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="-v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY"
498               else
499                 export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d")
500                 export BUILD_ARGS="-r $OPNFV_ARTIFACT_VERSION -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 [[ $BUILD_DIRECTORY == *verify-master* ]]; then
594                 cd $WORKSPACE/../${BUILD_DIRECTORY/build_output/}
595                 WORKSPACE=$(pwd)
596                 echo "WORKSPACE modified to $WORKSPACE"
597                 cd $WORKSPACE/ci
598             elif [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
599                 # if artifact name is passed the pull a
600                 # specific artifact from artifacts.opnfv.org
601                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
602             else
603                 if [[ $BUILD_DIRECTORY == *verify* ]]; then
604                   BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
605                   echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
606                 elif [[ $BUILD_DIRECTORY == *apex-build* ]]; then
607                   BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
608                   echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
609                 fi
610
611                 if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
612                     # if opnfv.properties exists then use the
613                     # local build. Source the file so we get local OPNFV vars
614                     source ${BUILD_DIRECTORY}/../opnfv.properties
615                     RPM_INSTALL_PATH=${BUILD_DIRECTORY}/$(basename $OPNFV_RPM_URL)
616                 else
617                     if [[ $BUILD_DIRECTORY == *verify* ]]; then
618                       echo "BUILD_DIRECTORY is from a verify job, so will not use latest from URL"
619                       echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
620                       exit 1
621                     elif [[ $BUILD_DIRECTORY == *apex-build* ]]; then
622                       echo "BUILD_DIRECTORY is from a daily job, so will not use latest from URL"
623                       echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
624                       exit 1
625                     fi
626                     # no opnfv.properties means use the latest from artifacts.opnfv.org
627                     # get the latest.properties to get the link to the latest artifact
628                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
629                     [[ -f opnfv.properties ]] || exit 1
630                     # source the file so we get OPNFV vars
631                     source opnfv.properties
632                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
633                 fi
634             fi
635
636             if [ -z "$DEPLOY_SCENARIO" ]; then
637               echo "Deploy scenario not set!"
638               exit 1
639             fi
640
641             # use local build for verify
642             if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
643                 if [ ! -e "${WORKSPACE}/build/lib" ]; then ln -s ${WORKSPACE}/lib ${WORKSPACE}/build/lib; fi
644                 DEPLOY_CMD="./deploy.sh -c ${WORKSPACE}/build -r ${WORKSPACE}/build/images/"
645                 DEPLOY_FILE="${WORKSPACE}/config/deploy/${DEPLOY_SCENARIO}.yaml"
646                 NETWORK_FILE="${WORKSPACE}/config/network/network_settings.yaml"
647             else
648                 RPM_LIST=$RPM_INSTALL_PATH
649                 for pkg in common undercloud opendaylight-sfc; do
650                     RPM_LIST+=" ${RPM_INSTALL_PATH/opnfv-apex/opnfv-apex-${pkg}}"
651                 done
652
653                 # update / install the new rpm
654                 if rpm -q opnfv-apex > /dev/null; then
655                    if [ $(basename $OPNFV_RPM_URL) == $(rpm -q opnfv-apex).rpm ]; then
656                      echo "RPM is already installed"
657                    elif sudo yum update -y $RPM_LIST | grep "does not update installed package"; then
658                        if ! sudo yum downgrade -y $RPM_LIST; then
659                          sudo yum remove -y opnfv-undercloud opnfv-common
660                          sudo yum downgrade -y $RPM_INSTALL_PATH
661                        fi
662                    fi
663                 else
664                    sudo yum install -y $RPM_LIST;
665                 fi
666                 DEPLOY_CMD=opnfv-deploy
667                 DEPLOY_FILE="/etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
668                 NETWORK_FILE="/etc/opnfv-apex/network_settings.yaml"
669             fi
670
671             if [ "$OPNFV_CLEAN" == 'yes' ]; then
672                 if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
673                     sudo ./clean.sh
674                 else
675                     sudo opnfv-clean
676                 fi
677             fi
678             # initiate virtual deployment
679             echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
680             if [ -e $DEPLOY_FILE ]; then
681               sudo $DEPLOY_CMD -v -d ${DEPLOY_FILE} -n $NETWORK_FILE --debug
682             else
683               echo "File does not exist /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
684               exit 1
685             fi
686             echo
687             echo "--------------------------------------------------------"
688             echo "Done!"
689
690 - builder:
691     name: 'apex-deploy-baremetal'
692     builders:
693         - shell: |
694             #!/bin/bash
695             set -o errexit
696             set -o nounset
697             set -o pipefail
698
699             # log info to console
700             echo "Starting the Apex baremetal deployment."
701             echo "--------------------------------------------------------"
702             echo
703
704             if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
705                 # if artifact name is passed the pull a
706                 # specific artifact from artifacts.opnfv.org
707                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
708             else
709                 if [[ $BUILD_DIRECTORY == *apex-build* ]]; then
710                   BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
711                   echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
712                 fi
713                 if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
714                     # if opnfv.properties exists then use the
715                     # local build. Source the file so we get local OPNFV vars
716                     source ${BUILD_DIRECTORY}/../opnfv.properties
717                     RPM_INSTALL_PATH=${BUILD_DIRECTORY}/$(basename $OPNFV_RPM_URL)
718                 else
719                     # no opnfv.properties means use the latest from artifacts.opnfv.org
720                     # get the latest.properties to get the link to the latest artifact
721                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
722                     [[ -f opnfv.properties ]] || exit 1
723                     # source the file so we get OPNFV vars
724                     source opnfv.properties
725                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
726                 fi
727             fi
728
729             if [ ! -e "$RPM_INSTALL_PATH" ]; then
730                RPM_INSTALL_PATH=http://${OPNFV_RPM_URL}
731             fi
732
733             RPM_LIST=$RPM_INSTALL_PATH
734             for pkg in common undercloud; do
735                 RPM_LIST+=" ${RPM_INSTALL_PATH/opnfv-apex/opnfv-apex-${pkg}}"
736             done
737
738             # update / install the new rpm
739             if rpm -q opnfv-apex > /dev/null; then
740                if [ $(basename $OPNFV_RPM_URL) == $(rpm -q opnfv-apex).rpm ]; then
741                  echo "RPM is already installed"
742                elif sudo yum update -y $RPM_LIST | grep "does not update installed package"; then
743                    if ! sudo yum downgrade -y $RPM_LIST; then
744                      sudo yum remove -y opnfv-undercloud opnfv-common
745                      sudo yum downgrade -y $RPM_INSTALL_PATH
746                    fi
747                fi
748             else
749                sudo yum install -y $RPM_LIST;
750             fi
751
752             # cleanup environment before we start
753             sudo opnfv-clean
754             # initiate baremetal deployment
755             if [ -e /etc/opnfv-apex/network_settings.yaml ]; then
756               if [ -n "$DEPLOY_SCENARIO" ]; then
757                 echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
758                 if [ -e /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml ]; then
759                   sudo opnfv-deploy -i  /root/inventory/pod_settings.yaml \
760                   -d /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml \
761                   -n /root/network/network_settings.yaml --debug
762                 else
763                   echo "File does not exist /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
764                   exit 1
765                 fi
766               else
767                 echo "Deploy scenario not set!"
768                 exit 1
769               fi
770             else
771               echo "File /etc/opnfv-apex/network_settings.yaml does not exist!"
772               exit 1
773             fi
774
775             echo
776             echo "--------------------------------------------------------"
777             echo "Done!"
778
779 #######################
780 # trigger macros
781 ########################
782 - trigger:
783     name: 'apex-master'
784     triggers:
785         - timed: '0 3 * 12 *'
786 - trigger:
787     name: 'apex-brahmaputra'
788     triggers:
789         - timed: '0 3 * * *'