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