Revert "CI: Rename global-settings to mvn-glob..."
[ci-management.git] / jjb / iec / iec-fuel-deploy.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2019 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 ##############################################################################
10 set -o nounset
11
12 export TERM="vt220"
13
14 # set deployment parameters
15 export TMPDIR=${HOME}/tmpdir
16 if [ "$(uname -m)" = 'aarch64' ]; then
17     LAB_NAME='arm'
18     # shellcheck disable=SC2153
19     POD_NAME=${NODE_NAME/*ubuntu1804-dev-48c-256g-/virtual}
20     if [[ ! "$POD_NAME" =~ virtual ]]; then
21         POD_NAME=${NODE_NAME/*ubuntu1804-dev-96c-256g-/baremetal}
22     fi
23     if [[ ! "$POD_NAME" =~ (virtual|baremetal) ]]; then
24         POD_NAME=${NODE_NAME/*ubuntu1804-dev-32c-128g-/baremetal}
25         LAB_NAME='unh'
26     fi
27 fi
28 if [[ ! "$POD_NAME" =~ (virtual|baremetal) ]]; then
29     echo "Unavailable hardware. Cannot continue!"
30     exit 1
31 fi
32
33 echo "Using configuration for ${LAB_NAME}"
34
35 # create TMPDIR if it doesn't exist, change permissions
36 mkdir -p "${TMPDIR}"
37 sudo chmod a+x "${HOME}" "${TMPDIR}"
38
39 cd "${WORKSPACE}" || exit 1
40
41 # log file name
42 # shellcheck disable=SC2153
43 FUEL_LOG_FILENAME="${JOB_NAME}_${BUILD_NUMBER}.log.tar.gz"
44
45 # turn on DEBUG mode
46 [ "${CI_DEBUG,,}" == 'true' ] && EXTRA_ARGS="-D ${EXTRA_ARGS:-}"
47
48 # construct the command
49 git clone https://github.com/opnfv/fuel.git
50
51 DEPLOY_COMMAND="fuel/ci/deploy.sh \
52     -l ${LAB_NAME} -p ${POD_NAME} -s ${DEPLOY_SCENARIO} \
53     -S ${TMPDIR} ${EXTRA_ARGS:-} \
54     -b file://${WORKSPACE}/ci
55     -L ${WORKSPACE}/${FUEL_LOG_FILENAME}"
56
57 # log info to console
58 echo "Deployment parameters"
59 echo "--------------------------------------------------------"
60 echo "Scenario: ${DEPLOY_SCENARIO}"
61 echo "Lab: ${LAB_NAME}"
62 echo "POD: ${POD_NAME}"
63 echo
64 echo "Starting the deployment using Fuel. This could take some time..."
65 echo "--------------------------------------------------------"
66 echo
67
68 # start the deployment
69 echo "Issuing command"
70 echo "${DEPLOY_COMMAND}"
71
72 ${DEPLOY_COMMAND}
73 exit_code=$?
74
75 echo
76 echo "--------------------------------------------------------"
77 echo "Deployment is done!"
78
79 if [ "${exit_code}" -ne 0 ]; then
80     echo "Deployment failed!"
81     exit "${exit_code}"
82 fi
83
84 echo "Deployment is successful!"
85 exit 0