diff options
author | Chase Qi <chase.qi@linaro.org> | 2017-02-17 21:12:52 +0800 |
---|---|---|
committer | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2017-02-17 13:24:22 +0000 |
commit | fb5d9f84daecc4a43d1939d52ac22e0123fa1d85 (patch) | |
tree | c1f79662b2798c6736389c513f7be7963fbe4d87 /automated | |
parent | 215b4447886ae4f13674ece020ebd09ce339c433 (diff) |
automated: utils: add upload-to-artifactorial.sh
Change-Id: I969b285e1b3e092acbee0ca425f5bb1f81a97354
Signed-off-by: Chase Qi <chase.qi@linaro.org>
Diffstat (limited to 'automated')
-rwxr-xr-x | automated/utils/upload-to-artifactorial.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/automated/utils/upload-to-artifactorial.sh b/automated/utils/upload-to-artifactorial.sh new file mode 100755 index 0000000..be307bf --- /dev/null +++ b/automated/utils/upload-to-artifactorial.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +ATTACHMENT="" +URL="" +TOKEN="" +RESULT_FILE="$(pwd)/output/result.txt" + +usage() { + echo "Usage: $0 [-a <attachment>] [-u <url>] [-t <token>]" 1>&2 + exit 1 +} + +while getopts ":a:u:t:" opt; do + case "${opt}" in + a) ATTACHMENT="${OPTARG}" ;; + u) URL="${OPTARG}" ;; + t) TOKEN="${OPTARG}" ;; + *) usage ;; + esac +done + +if [ -z "${URL}" ]; then + echo "test-attachment skip" | tee -a "${RESULT_FILE}" + exit 0 +fi + +if [ -z "${TOKEN}" ]; then + return=$(curl -F "path=@${ATTACHMENT}" "${URL}") +else + return=$(curl -F "path=@${ATTACHMENT}" -F "token=${TOKEN}" "${URL}") +fi + +if echo "${return}" | grep "${ATTACHMENT}"; then + if which lava-test-reference; then + lava-test-reference "test-attachment" --result "pass" --reference "https://archive.validation.linaro.org/artifacts/${return}" + else + echo "test-attachment skip" | tee -a "${RESULT_FILE}" + fi +else + echo "test-attachment fail" | tee -a "${RESULT_FILE}" +fi |