[fuel] Turn off upload action & checkout
[releng.git] / jjb / fuel / fuel-deploy.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Ericsson 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 set -o pipefail
12
13 export TERM="vt220"
14
15 # source the file so we get OPNFV vars
16 source latest.properties
17
18 # echo the info about artifact that is used during the deployment
19 echo "Using ${OPNFV_ARTIFACT_URL/*\/} for deployment"
20
21 if [[ "$JOB_NAME" =~ "merge" ]]; then
22     # set simplest scenario for virtual deploys to run for merges
23     DEPLOY_SCENARIO="os-nosdn-nofeature-ha"
24 elif [[ "$BRANCH" != 'master' ]]; then
25     # for none-merge deployments
26     # checkout the commit that was used for building the downloaded artifact
27     # to make sure the ISO and deployment mechanism uses same versions
28     echo "Checking out $OPNFV_GIT_SHA1"
29     git checkout $OPNFV_GIT_SHA1 --quiet
30 fi
31
32 # set deployment parameters
33 export TMPDIR=$HOME/tmpdir
34 BRIDGE=${BRIDGE:-pxebr}
35 LAB_NAME=${NODE_NAME/-*}
36 POD_NAME=${NODE_NAME/*-}
37
38 if [[ "$NODE_NAME" =~ "virtual" ]]; then
39     POD_NAME="virtual_kvm"
40 fi
41
42 # we currently support ericsson, intel, lf and zte labs
43 if [[ ! "$LAB_NAME" =~ (ericsson|intel|lf|zte) ]]; then
44     echo "Unsupported/unidentified lab $LAB_NAME. Cannot continue!"
45     exit 1
46 else
47     echo "Using configuration for $LAB_NAME"
48 fi
49
50 # create TMPDIR if it doesn't exist
51 export TMPDIR=$HOME/tmpdir
52 mkdir -p $TMPDIR
53
54 # change permissions down to TMPDIR
55 chmod a+x $HOME
56 chmod a+x $TMPDIR
57
58 # clone the securedlab repo
59 cd $WORKSPACE
60 echo "Cloning securedlab repo $BRANCH"
61 git clone ssh://jenkins-ericsson@gerrit.opnfv.org:29418/securedlab --quiet \
62     --branch $BRANCH
63
64 # log file name
65 FUEL_LOG_FILENAME="${JOB_NAME}_${BUILD_NUMBER}.log.tar.gz"
66
67 # construct the command
68 DEPLOY_COMMAND="sudo $WORKSPACE/ci/deploy.sh -b file://$WORKSPACE/securedlab \
69     -l $LAB_NAME -p $POD_NAME -s $DEPLOY_SCENARIO -i file://$WORKSPACE/opnfv.iso \
70     -H -B $BRIDGE -S $TMPDIR -L $WORKSPACE/$FUEL_LOG_FILENAME"
71
72 # log info to console
73 echo "Deployment parameters"
74 echo "--------------------------------------------------------"
75 echo "Scenario: $DEPLOY_SCENARIO"
76 echo "Lab: $LAB_NAME"
77 echo "POD: $POD_NAME"
78 echo "ISO: ${OPNFV_ARTIFACT_URL/*\/}"
79 echo
80 echo "Starting the deployment using $INSTALLER_TYPE. This could take some time..."
81 echo "--------------------------------------------------------"
82 echo
83
84 # start the deployment
85 echo "Issuing command"
86 echo "$DEPLOY_COMMAND"
87 echo
88
89 $DEPLOY_COMMAND
90 exit_code=$?
91
92 echo
93 echo "--------------------------------------------------------"
94 echo "Deployment is done!"
95
96 # upload logs for baremetal deployments
97 # work with virtual deployments is still going on so we skip that for the timebeing
98 if [[ "$JOB_NAME" =~ (baremetal-daily|baremetal-weekly) ]]; then
99     echo "Uploading deployment logs"
100     gsutil cp $WORKSPACE/$FUEL_LOG_FILENAME gs://$GS_URL/logs/$FUEL_LOG_FILENAME > /dev/null 2>&1
101     echo "Logs are available as http://$GS_URL/logs/$FUEL_LOG_FILENAME"
102 fi
103
104 if [[ $exit_code -ne 0 ]]; then
105     echo "Deployment failed!"
106     exit $exit_code
107 else
108     echo "Deployment is successful!"
109     exit 0
110 fi