mirror of
https://github.com/ViViDboarder/drone-webdav.git
synced 2025-01-06 12:37:33 +00:00
Fix arg quoting
This commit is contained in:
parent
21ad3e9eeb
commit
d5004efddf
@ -1,7 +1,7 @@
|
|||||||
FROM alpine
|
FROM alpine
|
||||||
MAINTAINER ViViDboarder <ViViDboarder@gmail.com>
|
MAINTAINER ViViDboarder <ViViDboarder@gmail.com>
|
||||||
|
|
||||||
RUN apk -Uuv add curl ca-certificates
|
RUN apk -Uuv add bash curl ca-certificates
|
||||||
COPY push.sh /bin/
|
COPY push.sh /bin/
|
||||||
RUN chmod +x /bin/push.sh
|
RUN chmod +x /bin/push.sh
|
||||||
|
|
||||||
|
2
Makefile
2
Makefile
@ -6,6 +6,8 @@ default: test
|
|||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
docker-compose -f ./tests/docker-compose-private.yml up \
|
docker-compose -f ./tests/docker-compose-private.yml up \
|
||||||
|
--build --force-recreate \
|
||||||
--abort-on-container-exit --exit-code-from plugin
|
--abort-on-container-exit --exit-code-from plugin
|
||||||
docker-compose -f ./tests/docker-compose-public.yml up \
|
docker-compose -f ./tests/docker-compose-public.yml up \
|
||||||
|
--build --force-recreate \
|
||||||
--abort-on-container-exit --exit-code-from plugin
|
--abort-on-container-exit --exit-code-from plugin
|
||||||
|
40
push.sh
40
push.sh
@ -1,62 +1,56 @@
|
|||||||
#! /bin/sh
|
#! /bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
ARGS=()
|
||||||
|
|
||||||
# Use WEBDAV_USERNAME as default, if provided.
|
# Use WEBDAV_USERNAME as default, if provided.
|
||||||
if [ -z "$PLUGIN_USERNAME" ] && [ -n "$WEBDAV_USERNAME" ]; then
|
if [ -z "$PLUGIN_USERNAME" ] && [ -n "$WEBDAV_USERNAME" ]; then
|
||||||
|
PLUGIN_USERNAME="$WEBDAV_USERNAME"
|
||||||
PLUGIN_USERNAME="$WEBDAV_USERNAME"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use WEBDAV_PASSWORD as default, if provided.
|
# Use WEBDAV_PASSWORD as default, if provided.
|
||||||
if [ -z "$PLUGIN_PASSWORD" ] && [ -n "$WEBDAV_PASSWORD" ]; then
|
if [ -z "$PLUGIN_PASSWORD" ] && [ -n "$WEBDAV_PASSWORD" ]; then
|
||||||
|
PLUGIN_PASSWORD="$WEBDAV_PASSWORD"
|
||||||
PLUGIN_PASSWORD="$WEBDAV_PASSWORD"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If username and password are provided, add auth
|
# If username and password are provided, add auth
|
||||||
if [ -n "$PLUGIN_USERNAME" ] && [ -n "$PLUGIN_PASSWORD" ]; then
|
if [ -n "$PLUGIN_USERNAME" ] && [ -n "$PLUGIN_PASSWORD" ]; then
|
||||||
|
ARGS+=(--user "${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}")
|
||||||
AUTH="--user '${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}'"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use a proxy, if one is specified
|
# Use a proxy, if one is specified
|
||||||
if [ -n "$PLUGIN_PROXY_URL" ]; then
|
if [ -n "$PLUGIN_PROXY_URL" ]; then
|
||||||
|
ARGS+=(--proxy "${PLUGIN_PROXY_URL}")
|
||||||
PLUGIN_PROXY_URL="--proxy '${PLUGIN_PROXY_URL}'"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If a timeout is specified, make use of it.
|
# If a timeout is specified, make use of it.
|
||||||
if [ -n "$PLUGIN_TIMEOUT" ]; then
|
if [ -n "$PLUGIN_TIMEOUT" ]; then
|
||||||
|
ARGS+=(--max-time "${PLUGIN_TIMEOUT}")
|
||||||
PLUGIN_TIMEOUT="--max-time '${PLUGIN_TIMEOUT}'"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set PLUGIN_ATTEMPTS to one if nothing else is specified
|
# Set PLUGIN_ATTEMPTS to one if nothing else is specified
|
||||||
if [ -z "$PLUGIN_ATTEMPTS" ]; then
|
if [ -z "$PLUGIN_ATTEMPTS" ]; then
|
||||||
|
PLUGIN_ATTEMPTS=1
|
||||||
PLUGIN_ATTEMPTS=1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Repeat the upload as long as specified.
|
# Repeat the upload as long as specified.
|
||||||
while [ "${PLUGIN_ATTEMPTS}" -gt 0 ]; do
|
while [ "${PLUGIN_ATTEMPTS}" -gt 0 ]; do
|
||||||
|
|
||||||
# Uploading the file
|
# Uploading the file
|
||||||
curl $PLUGIN_PROXY_URL $PLUGIN_TIMEOUT $PLUGIN_CUSTOM_ARGUMENTS --upload-file $PLUGIN_FILE $AUTH $PLUGIN_DESTINATION && {
|
curl "${ARGS[@]}" --upload-file "$PLUGIN_FILE" "$PLUGIN_DESTINATION" && {
|
||||||
|
|
||||||
# Terminate the script as soon as the upload is successful
|
# Terminate the script as soon as the upload is successful
|
||||||
echo "[INFO] Upload was successful."
|
echo "[INFO] Upload was successful."
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Show messages in case uploads have failed
|
# Show messages in case uploads have failed
|
||||||
[ "$PLUGIN_ATTEMPTS" -gt 1 ] && {
|
[ "$PLUGIN_ATTEMPTS" -gt 1 ] && {
|
||||||
|
echo "[INFO] Upload failed. Attempting a new upload, if possible."
|
||||||
echo "[INFO] Upload failed. Attempting a new upload, if possible."
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
PLUGIN_ATTEMPTS=$((PLUGIN_ATTEMPTS-1))
|
PLUGIN_ATTEMPTS=$((PLUGIN_ATTEMPTS-1))
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -18,4 +18,5 @@ services:
|
|||||||
PLUGIN_DESTINATION: 'http://webdav/'
|
PLUGIN_DESTINATION: 'http://webdav/'
|
||||||
PLUGIN_USERNAME: jdoe
|
PLUGIN_USERNAME: jdoe
|
||||||
PLUGIN_PASSWORD: hunter2
|
PLUGIN_PASSWORD: hunter2
|
||||||
|
PLUGIN_TIMEOUT: 10
|
||||||
PLUGIN_ATTEMPTS: 4
|
PLUGIN_ATTEMPTS: 4
|
||||||
|
@ -13,4 +13,5 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
PLUGIN_FILE: '/test.txt'
|
PLUGIN_FILE: '/test.txt'
|
||||||
PLUGIN_DESTINATION: 'http://webdav/'
|
PLUGIN_DESTINATION: 'http://webdav/'
|
||||||
|
PLUGIN_TIMEOUT: 10
|
||||||
PLUGIN_ATTEMPTS: 4
|
PLUGIN_ATTEMPTS: 4
|
||||||
|
Loading…
Reference in New Issue
Block a user