2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2017 Ericsson AB, Mirantis Inc., Enea Software AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
15 if [[ "$BRANCH" =~ 'danube' ]]; then
16 # source the file so we get OPNFV vars
17 # shellcheck disable=SC1091
18 source latest.properties
20 # echo the info about artifact that is used during the deployment
21 echo "Using ${OPNFV_ARTIFACT_URL/*\/} for deployment"
23 # for Danube deployments (no artifact for current master or newer branches)
24 # checkout the commit that was used for building the downloaded artifact
25 # to make sure the ISO and deployment mechanism uses same versions
26 echo "Checking out ${OPNFV_GIT_SHA1}"
27 git checkout "${OPNFV_GIT_SHA1}" --quiet
29 # releng wants us to use nothing else but opnfv.iso for now. We comply.
30 ISO_FILE_ARG="-i file://${WORKSPACE}/opnfv.iso"
33 # shellcheck disable=SC2153
34 if [[ "${JOB_NAME}" =~ 'verify' ]]; then
35 # set simplest scenario for virtual deploys to run for verify
36 DEPLOY_SCENARIO="os-nosdn-nofeature-noha"
39 # set deployment parameters
40 export TMPDIR=${HOME}/tmpdir
41 BRIDGE=${BRIDGE:-pxebr}
42 # shellcheck disable=SC2153
43 LAB_NAME=${NODE_NAME/-*}
44 # shellcheck disable=SC2153
45 POD_NAME=${NODE_NAME/*-}
46 # Armband might override LAB_CONFIG_URL, all others use the default
47 LAB_CONFIG_URL=${LAB_CONFIG_URL:-'ssh://jenkins-ericsson@gerrit.opnfv.org:29418/securedlab'}
49 # Fuel requires deploy script to be ran with sudo, Armband does not
51 if [ "${PROJECT}" = 'fuel' ]; then
52 # Fuel does not use any POD-specific configuration for virtual deploys
53 if [[ "${NODE_NAME}" =~ "virtual" ]]; then
54 POD_NAME="virtual_kvm"
56 # Fuel currently supports ericsson, intel, lf and zte labs
57 if [[ ! "${LAB_NAME}" =~ (ericsson|intel|lf|zte) ]]; then
58 echo "Unsupported/unidentified lab ${LAB_NAME}. Cannot continue!"
63 # Armband currently supports arm, enea labs
64 if [[ ! "${LAB_NAME}" =~ (arm|enea) ]]; then
65 echo "Unsupported/unidentified lab ${LAB_NAME}. Cannot continue!"
70 echo "Using configuration for ${LAB_NAME}"
72 # create TMPDIR if it doesn't exist, change permissions
74 chmod a+x "${HOME}" "${TMPDIR}"
76 cd "${WORKSPACE}" || exit 1
77 if [[ "${LAB_CONFIG_URL}" =~ ^(git|ssh):// ]]; then
78 echo "Cloning securedlab repo ${BRANCH}"
79 LOCAL_CFG="${TMPDIR}/securedlab"
81 git clone --quiet --branch "${BRANCH}" "${LAB_CONFIG_URL}" "${LOCAL_CFG}"
82 LAB_CONFIG_URL="file://${LOCAL_CFG}"
86 FUEL_LOG_FILENAME="${JOB_NAME}_${BUILD_NUMBER}.log.tar.gz"
88 # construct the command
89 DEPLOY_COMMAND="${SUDO} ${WORKSPACE}/ci/deploy.sh -b ${LAB_CONFIG_URL} \
90 -l ${LAB_NAME} -p ${POD_NAME} -s ${DEPLOY_SCENARIO} ${ISO_FILE_ARG:-} \
91 -B ${DEFAULT_BRIDGE:-${BRIDGE}} -S ${TMPDIR} \
92 -L ${WORKSPACE}/${FUEL_LOG_FILENAME}"
95 echo "Deployment parameters"
96 echo "--------------------------------------------------------"
97 echo "Scenario: ${DEPLOY_SCENARIO}"
98 echo "Lab: ${LAB_NAME}"
99 echo "POD: ${POD_NAME}"
100 [[ "${BRANCH}" =~ 'danube' ]] && echo "ISO: ${OPNFV_ARTIFACT_URL/*\/}"
102 echo "Starting the deployment using ${INSTALLER_TYPE}. This could take some time..."
103 echo "--------------------------------------------------------"
106 # start the deployment
107 echo "Issuing command"
108 echo "${DEPLOY_COMMAND}"
115 echo "--------------------------------------------------------"
116 echo "Deployment is done!"
118 # upload logs for baremetal deployments
119 # work with virtual deployments is still going on, so skip that for now
120 if [[ "${JOB_NAME}" =~ (baremetal-daily|baremetal-weekly) ]]; then
121 echo "Uploading deployment logs"
122 gsutil cp "${WORKSPACE}/${FUEL_LOG_FILENAME}" \
123 "gs://${GS_URL}/logs/${FUEL_LOG_FILENAME}" > /dev/null 2>&1
124 echo "Logs are available at http://${GS_URL}/logs/${FUEL_LOG_FILENAME}"
127 if [[ "${exit_code}" -ne 0 ]]; then
128 echo "Deployment failed!"
132 echo "Deployment is successful!"