summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2017-04-13 20:57:03 +0800
committerChase Qi <chase.qi@linaro.org>2017-04-13 21:03:29 +0800
commit39e4f01b1b4ccad887de6a71c41a06f069aa17ba (patch)
tree34be68aa4b9f6376d649d51e51048f13f83c133e
parent6c0718c2a8b06603429b44df2380aca30aa82133 (diff)
downloadtest-definitions-pipe-39e4f01b1b4ccad887de6a71c41a06f069aa17ba.tar.gz
utils: add support for LAVA's secrets feature
* Use token from LAVA's secrets file if defined. * Renamed URL and TOKEN variables with ARTIFACTORIAL_ as prefix to make them more meaningful. Change-Id: I80775d0bf7492275a3f2ca73d54640ea488f4a35 Signed-off-by: Chase Qi <chase.qi@linaro.org>
-rwxr-xr-xautomated/utils/upload-to-artifactorial.sh26
1 files changed, 17 insertions, 9 deletions
diff --git a/automated/utils/upload-to-artifactorial.sh b/automated/utils/upload-to-artifactorial.sh
index a992b27..af501bb 100755
--- a/automated/utils/upload-to-artifactorial.sh
+++ b/automated/utils/upload-to-artifactorial.sh
@@ -1,34 +1,42 @@
#!/bin/sh
ATTACHMENT=""
-URL=""
-TOKEN=""
+ARTIFACTORIAL_URL=""
+ARTIFACTORIAL_TOKEN=""
RESULT_FILE="$(pwd)/output/result.txt"
usage() {
- echo "Usage: $0 [-a <attachment>] [-u <url>] [-t <token>]" 1>&2
+ echo "Usage: $0 [-a <attachment>] [-u <artifactorial_url>] [-t <artifactorial_token>]" 1>&2
exit 1
}
while getopts ":a:u:t:" opt; do
case "${opt}" in
a) ATTACHMENT="${OPTARG}" ;;
- u) URL="${OPTARG}" ;;
- t) TOKEN="${OPTARG}" ;;
+ u) ARTIFACTORIAL_URL="${OPTARG}" ;;
+ t) ARTIFACTORIAL_TOKEN="${OPTARG}" ;;
*) usage ;;
esac
done
-if [ -z "${URL}" ]; then
+if [ -z "${ARTIFACTORIAL_URL}" ]; then
echo "test-attachment skip" | tee -a "${RESULT_FILE}"
exit 0
fi
if which lava-test-reference; then
- if [ -z "${TOKEN}" ]; then
- return=$(curl -F "path=@${ATTACHMENT}" "${URL}")
+ # If 'ARTIFACTORIAL_TOKEN' defined in 'secrects' dictionary defined in job
+ # definition file, it will be used.
+ lava_test_dir="$(find /lava-* -maxdepth 0 -type d 2>/dev/null | sort | tail -1)"
+ if test -f "${lava_test_dir}/secrets" && grep -q "ARTIFACTORIAL_TOKEN" "${lava_test_dir}/secrets"; then
+ # shellcheck disable=SC1090
+ . "${lava_test_dir}/secrets"
+ fi
+
+ if [ -z "${ARTIFACTORIAL_TOKEN}" ]; then
+ return=$(curl -F "path=@${ATTACHMENT}" "${ARTIFACTORIAL_URL}")
else
- return=$(curl -F "path=@${ATTACHMENT}" -F "token=${TOKEN}" "${URL}")
+ return=$(curl -F "path=@${ATTACHMENT}" -F "token=${ARTIFACTORIAL_TOKEN}" "${ARTIFACTORIAL_URL}")
fi
if echo "${return}" | grep "$(basename "${ATTACHMENT}")"; then