8cc552e8d86a731d0d08c0f2c6a525d60aa3c9b3
[releng.git] / jjb / fuel / fuel-download-artifact.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 errexit
11 set -o pipefail
12
13 # use proxy url to replace the nomral URL, for googleusercontent.com will be blocked randomly
14 [[ "$NODE_NAME" =~ (zte) ]] && GS_URL=${GS_BASE_PROXY%%/*}/$GS_URL
15
16 if [[ "$JOB_NAME" =~ "merge" ]]; then
17     echo "Downloading http://$GS_URL/opnfv-gerrit-$GERRIT_CHANGE_NUMBER.properties"
18     # get the properties file for the Fuel ISO built for a merged change
19     curl -L -s -o $WORKSPACE/latest.properties http://$GS_URL/opnfv-gerrit-$GERRIT_CHANGE_NUMBER.properties
20 else
21     # get the latest.properties file in order to get info regarding latest artifact
22     echo "Downloading http://$GS_URL/latest.properties"
23     curl -L -s -o $WORKSPACE/latest.properties http://$GS_URL/latest.properties
24 fi
25
26 # check if we got the file
27 [[ -f $WORKSPACE/latest.properties ]] || exit 1
28
29 # source the file so we get artifact metadata
30 source $WORKSPACE/latest.properties
31
32 # echo the info about artifact that is used during the deployment
33 OPNFV_ARTIFACT=${OPNFV_ARTIFACT_URL/*\/}
34 echo "Using $OPNFV_ARTIFACT for deployment"
35
36 # using ISOs for verify & merge jobs from local storage will be enabled later
37 if [[ ! "$JOB_NAME" =~ (verify|merge) ]]; then
38     # check if we already have the ISO to avoid redownload
39     ISOSTORE="/iso_mount/opnfv_ci/${BRANCH##*/}"
40     if [[ -f "$ISOSTORE/$OPNFV_ARTIFACT" ]]; then
41         echo "ISO exists locally. Skipping the download and using the file from ISO store"
42         ln -s $ISOSTORE/$OPNFV_ARTIFACT $WORKSPACE/opnfv.iso
43         echo "--------------------------------------------------------"
44         echo
45         ls -al $WORKSPACE/opnfv.iso
46         echo
47         echo "--------------------------------------------------------"
48         echo "Done!"
49         exit 0
50     fi
51 fi
52
53 [[ "$NODE_NAME" =~ (zte) ]] && OPNFV_ARTIFACT_URL=${GS_BASE_PROXY%%/*}/$OPNFV_ARTIFACT_URL
54
55 # log info to console
56 echo "Downloading the $INSTALLER_TYPE artifact using URL http://$OPNFV_ARTIFACT_URL"
57 echo "This could take some time..."
58 echo "--------------------------------------------------------"
59 echo
60
61 # download the file
62 curl -L -s -o $WORKSPACE/opnfv.iso http://$OPNFV_ARTIFACT_URL > gsutil.iso.log 2>&1
63
64 # list the file
65 ls -al $WORKSPACE/opnfv.iso
66
67 echo
68 echo "--------------------------------------------------------"
69 echo "Done!"