online bottlenecks soak throughtputs
[releng.git] / utils / upload-artifact.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Orange 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 -e
11 set -o pipefail
12
13 export PATH=$PATH:/usr/local/bin/
14
15 # 2 paramters
16 # - $1: the source directory where the files to be uploaded are located
17 # - $2: the target on artifact http://artifact.opnfv.org/<project>/$2
18 #   if not set, default value is <project>/docs
19 project=$PROJECT
20 if [ -z "$2" ]
21   then
22       artifact_dir="$project/docs"
23   else
24       artifact_dir="$project/$2"
25 fi
26 DIRECTORY="$1"
27
28
29 # check that the API doc directory does exist before pushing it to artifact
30 if [ ! -d "$DIRECTORY" ]; then
31     echo "Directory to be uploaded "$DIRECTORY" does not exist"
32     exit 1
33 fi
34 set +e
35 gsutil&>/dev/null
36 if [ $? != 0 ]; then
37     echo "Not possible to push results to artifact: gsutil not installed"
38     exit 1
39 else
40     gsutil ls gs://artifacts.opnfv.org/"$project"/ &>/dev/null
41     if [ $? != 0 ]; then
42         echo "Not possible to push results to artifact: gsutil not installed."
43         exit 1
44     else
45         echo "Uploading file(s) to artifact $artifact_dir"
46         gsutil -m cp -r "$DIRECTORY"/* gs://artifacts.opnfv.org/"$artifact_dir"/ >/dev/null 2>&1
47     fi
48 fi