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 [[ "$BRANCH" =~ (danube|euphrates) ]]; then
78 if [[ "${LAB_CONFIG_URL}" =~ ^(git|ssh):// ]]; then
79 echo "Cloning securedlab repo ${BRANCH}"
80 LOCAL_CFG="${TMPDIR}/securedlab"
82 git clone --quiet --branch "${BRANCH}" "${LAB_CONFIG_URL}" "${LOCAL_CFG}"
83 LAB_CONFIG_ARG="-b file://${LOCAL_CFG}"
85 LAB_CONFIG_ARG="-b ${LAB_CONFIG_URL}"
90 FUEL_LOG_FILENAME="${JOB_NAME}_${BUILD_NUMBER}.log.tar.gz"
92 # construct the command
93 DEPLOY_COMMAND="${SUDO} ${WORKSPACE}/ci/deploy.sh ${LAB_CONFIG_ARG:-} \
94 -l ${LAB_NAME} -p ${POD_NAME} -s ${DEPLOY_SCENARIO} ${ISO_FILE_ARG:-} \
95 -B ${DEFAULT_BRIDGE:-${BRIDGE}} -S ${TMPDIR} \
96 -L ${WORKSPACE}/${FUEL_LOG_FILENAME}"
99 echo "Deployment parameters"
100 echo "--------------------------------------------------------"
101 echo "Scenario: ${DEPLOY_SCENARIO}"
102 echo "Lab: ${LAB_NAME}"
103 echo "POD: ${POD_NAME}"
104 [[ "${BRANCH}" =~ 'danube' ]] && echo "ISO: ${OPNFV_ARTIFACT_URL/*\/}"
106 echo "Starting the deployment using ${INSTALLER_TYPE}. This could take some time..."
107 echo "--------------------------------------------------------"
110 # start the deployment
111 echo "Issuing command"
112 echo "${DEPLOY_COMMAND}"
119 echo "--------------------------------------------------------"
120 echo "Deployment is done!"
122 # upload logs for baremetal deployments
123 # work with virtual deployments is still going on, so skip that for now
124 if [[ "${JOB_NAME}" =~ (baremetal-daily|baremetal-weekly) ]]; then
125 echo "Uploading deployment logs"
126 gsutil cp "${WORKSPACE}/${FUEL_LOG_FILENAME}" \
127 "gs://${GS_URL}/logs/${FUEL_LOG_FILENAME}" > /dev/null 2>&1
128 echo "Logs are available at http://${GS_URL}/logs/${FUEL_LOG_FILENAME}"
131 if [[ "${exit_code}" -ne 0 ]]; then
132 echo "Deployment failed!"
136 echo "Deployment is successful!"