mirror of
https://github.com/ViViDboarder/drone-webdav.git
synced 2024-06-02 15:32:24 +00:00
First changes.
This commit is contained in:
parent
8a22e80d99
commit
f078e71b37
12
Readme.md
12
Readme.md
|
@ -1,7 +1,7 @@
|
|||
# drone-webdav
|
||||
*A WebDAV plugin for the drone.io project*
|
||||
A WebDAV plugin, for the drone.io project, which allows you to push build artifacts to any WebDAV server, including Nextcloud or ownCloud.
|
||||
|
||||
The WebDAV plugin will allow pushing build artifacts to any WebDAV server, including Nextcloud or ownCloud.
|
||||
## Examples
|
||||
|
||||
An example configuration would be as follows:
|
||||
|
||||
|
@ -29,3 +29,11 @@ pipeline:
|
|||
- source: WEBDAV_PASSWORD
|
||||
target: PLUGIN_PASSWORD
|
||||
```
|
||||
|
||||
## Customization
|
||||
|
||||
The following environment variables can be used for further cutomization:
|
||||
|
||||
``PLUGIN_PROXY_URL`` - May be used to specify a proxy (e.g. ``socks5://{ip_adress}:{port}``)<br>
|
||||
``PLUGIN_TIMEOUT`` - Defines a timeout (in seconds) to stop the upload after a certain time. The default value is 30 minutes.<br>
|
||||
``PLUGIN_ATTEMPTS`` - Defines how often a failed upload should be retried. Normally there is only one upload attempt.
|
62
push.sh
62
push.sh
|
@ -1,16 +1,72 @@
|
|||
#! /bin/sh
|
||||
|
||||
# Use WEBDAV_USERNAME or WEBDAV_PASSWORD as default, if provided
|
||||
# Use WEBDAV_USERNAME as default, if provided.
|
||||
if [ -z "$PLUGIN_USERNAME" ] && [ ! -z "$WEBDAV_USERNAME" ]; then
|
||||
|
||||
PLUGIN_USERNAME="$WEBDAV_USERNAME"
|
||||
fi
|
||||
|
||||
# Use WEBDAV_PASSWORD as default, if provided.
|
||||
if [ -z "$PLUGIN_PASSWORD" ] && [ ! -z "$WEBDAV_PASSWORD" ]; then
|
||||
|
||||
PLUGIN_PASSWORD="$WEBDAV_PASSWORD"
|
||||
fi
|
||||
|
||||
# If username and password are provided, add auth
|
||||
if [ ! -z "$PLUGIN_USERNAME" ] && [ ! -z "$PLUGIN_PASSWORD" ]; then
|
||||
AUTH="-u ${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}"
|
||||
|
||||
AUTH="--user ${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}"
|
||||
fi
|
||||
|
||||
curl -T $PLUGIN_FILE $AUTH $PLUGIN_DESTINATION
|
||||
# Use a proxy, if one is specified
|
||||
if [ ! -z "$PLUGIN_PROXY_URL" ]; then
|
||||
|
||||
PLUGIN_PROXY_URL="--proxy ${PLUGIN_PROXY_URL}"
|
||||
fi
|
||||
|
||||
# If a timeout is specified, make use of it. If none is defined, use a default value (30 seconds).
|
||||
if [ ! -z "$PLUGIN_TIMEOUT" ]; then
|
||||
|
||||
PLUGIN_TIMEOUT="--max-time ${PLUGIN_TIMEOUT}"
|
||||
else
|
||||
|
||||
PLUGIN_TIMEOUT="--max-time 1800"
|
||||
fi
|
||||
|
||||
# Set PLUGIN_ATTEMPTS to one if nothing else is specified
|
||||
if [ -z "$PLUGIN_ATTEMPTS" ]; then
|
||||
|
||||
PLUGIN_ATTEMPTS=1
|
||||
fi
|
||||
|
||||
# Repeat the upload as long as specified.
|
||||
while [ $PLUGIN_ATTEMPTS -gt 0 ]; do
|
||||
|
||||
# Uploading the file
|
||||
curl $PLUGIN_PROXY_URL --upload-file $PLUGIN_FILE $AUTH $PLUGIN_DESTINATION --progress-bar $PLUGIN_TIMEOUT
|
||||
|
||||
# Terminate the script as soon as the upload is successful
|
||||
if [ $? -eq 0 ]; then
|
||||
|
||||
echo "[INFO] Upload was successful."
|
||||
exit 0
|
||||
|
||||
else
|
||||
|
||||
# Show messages in case uploads have failed
|
||||
if [ $PLUGIN_ATTEMPTS -gt 1 ]; then
|
||||
|
||||
echo "[INFO] Upload failed. Attempting a new upload, if possible."
|
||||
else
|
||||
|
||||
echo "[INFO] All upload attempts have failed."
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
PLUGIN_ATTEMPTS=$((PLUGIN_ATTEMPTS-1))
|
||||
|
||||
done
|
||||
|
||||
# Returns an error because the upload was not successful
|
||||
exit 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user