@@ -59,6 +59,10 @@ pipeline:
|
|||||||
- "app.tar.gz.md5"
|
- "app.tar.gz.md5"
|
||||||
exclude:
|
exclude:
|
||||||
- "**.*"
|
- "**.*"
|
||||||
|
prescript:
|
||||||
|
- cd ~/packages
|
||||||
|
- md5sum -c app.tar.gz.md5
|
||||||
|
- tar -xf app.tar.gz -C ~/app
|
||||||
script:
|
script:
|
||||||
- cd ~/packages
|
- cd ~/packages
|
||||||
- md5sum -c app.tar.gz.md5
|
- md5sum -c app.tar.gz.md5
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ The following parameters are used to configure the plugin:
|
|||||||
- **exclude** - rsync exclude filter
|
- **exclude** - rsync exclude filter
|
||||||
- **recursive** - recursively synchronize, defaults to `false`
|
- **recursive** - recursively synchronize, defaults to `false`
|
||||||
- **delete** - delete target folder contents, defaults to `false`
|
- **delete** - delete target folder contents, defaults to `false`
|
||||||
- **script** - list of commands to execute on remote machines
|
- **prescript** - list of commands to execute on remote machines before rsync occurs
|
||||||
|
- **postscript** - list of commands to execute on remote machines after rsync occurs
|
||||||
|
|
||||||
## Secrets
|
## Secrets
|
||||||
The following secrets can be used to secure the sensitive parts of your configuration:
|
The following secrets can be used to secure the sensitive parts of your configuration:
|
||||||
@@ -73,7 +74,11 @@ steps:
|
|||||||
- "app.tar.gz.md5"
|
- "app.tar.gz.md5"
|
||||||
exclude:
|
exclude:
|
||||||
- "**.*"
|
- "**.*"
|
||||||
script:
|
prescript:
|
||||||
|
- cd ~/packages
|
||||||
|
- md5sum -c app.tar.gz.md5
|
||||||
|
- tar -xf app.tar.gz -C ~/app
|
||||||
|
script:
|
||||||
- cd ~/packages
|
- cd ~/packages
|
||||||
- md5sum -c app.tar.gz.md5
|
- md5sum -c app.tar.gz.md5
|
||||||
- tar -xf app.tar.gz -C ~/app
|
- tar -xf app.tar.gz -C ~/app
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ docker run --rm \
|
|||||||
-e PLUGIN_HOSTS="127.0.0.1, 127.0.0.2, 127.0.0.3" \
|
-e PLUGIN_HOSTS="127.0.0.1, 127.0.0.2, 127.0.0.3" \
|
||||||
-e PLUGIN_PORTS="22, 23, 24" \
|
-e PLUGIN_PORTS="22, 23, 24" \
|
||||||
-e PLUGIN_TARGET="./" \
|
-e PLUGIN_TARGET="./" \
|
||||||
-e PLUGIN_SCRIPT="echo \"Done!\"" \
|
-e PLUGIN_PRESCRIPT="echo \"Prescript Done!\"" \
|
||||||
|
-e PLUGIN_SCRIPT="echo \"Postscript Done!\"" \
|
||||||
-e PLUGIN_ARGS="--blocking-io" \
|
-e PLUGIN_ARGS="--blocking-io" \
|
||||||
-v $(pwd):$(pwd) \
|
-v $(pwd):$(pwd) \
|
||||||
-w $(pwd) \
|
-w $(pwd) \
|
||||||
|
|||||||
21
upload.sh
21
upload.sh
@@ -8,6 +8,7 @@ if [ -z "$PLUGIN_TARGET" ]; then
|
|||||||
echo "Specify a target!"
|
echo "Specify a target!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DEFAULT_PORT=$PLUGIN_PORT
|
DEFAULT_PORT=$PLUGIN_PORT
|
||||||
if [ -z "$PLUGIN_PORT" ]; then
|
if [ -z "$PLUGIN_PORT" ]; then
|
||||||
echo "Port not specified, using default port 22!"
|
echo "Port not specified, using default port 22!"
|
||||||
@@ -100,10 +101,14 @@ fi
|
|||||||
echo "$SSH_KEY" > $keyfile
|
echo "$SSH_KEY" > $keyfile
|
||||||
chmod 0600 $keyfile
|
chmod 0600 $keyfile
|
||||||
|
|
||||||
# Parse SSH commands
|
|
||||||
function join_with { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
|
function join_with { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; }
|
||||||
|
|
||||||
|
# Parse SSH precommands
|
||||||
|
IFS=','; read -ra COMMANDS <<< "$PLUGIN_PRESCRIPT"
|
||||||
|
prescript=$(join_with ' && ' "${COMMANDS[@]}")
|
||||||
|
# Parse SSH postcommands
|
||||||
IFS=','; read -ra COMMANDS <<< "$PLUGIN_SCRIPT"
|
IFS=','; read -ra COMMANDS <<< "$PLUGIN_SCRIPT"
|
||||||
script=$(join_with ' && ' "${COMMANDS[@]}")
|
postscript=$(join_with ' && ' "${COMMANDS[@]}")
|
||||||
|
|
||||||
# Run rsync
|
# Run rsync
|
||||||
IFS=','; read -ra HOSTS <<< "$PLUGIN_HOSTS"
|
IFS=','; read -ra HOSTS <<< "$PLUGIN_HOSTS"
|
||||||
@@ -119,13 +124,21 @@ do
|
|||||||
PORT=$DEFAULT_PORT
|
PORT=$DEFAULT_PORT
|
||||||
fi
|
fi
|
||||||
echo $(printf "%s" "$ $(printf "$expr" "$PORT") $USER@$HOST:$PLUGIN_TARGET ...")
|
echo $(printf "%s" "$ $(printf "$expr" "$PORT") $USER@$HOST:$PLUGIN_TARGET ...")
|
||||||
|
if [ -n "$PLUGIN_PRESCRIPT" ]; then
|
||||||
|
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST ...")
|
||||||
|
echo $(printf "%s" " > $prescript ...")
|
||||||
|
eval "ssh -p $PORT $USER@$HOST '$prescript'"
|
||||||
|
result=$(($result+$?))
|
||||||
|
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST result: $?")
|
||||||
|
if [ "$result" -gt "0" ]; then exit $result; fi
|
||||||
|
fi
|
||||||
eval "$(printf "$expr" "$PORT") $USER@$HOST:$PLUGIN_TARGET"
|
eval "$(printf "$expr" "$PORT") $USER@$HOST:$PLUGIN_TARGET"
|
||||||
result=$(($result+$?))
|
result=$(($result+$?))
|
||||||
if [ "$result" -gt "0" ]; then exit $result; fi
|
if [ "$result" -gt "0" ]; then exit $result; fi
|
||||||
if [ -n "$PLUGIN_SCRIPT" ]; then
|
if [ -n "$PLUGIN_SCRIPT" ]; then
|
||||||
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST ...")
|
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST ...")
|
||||||
echo $(printf "%s" " > $script ...")
|
echo $(printf "%s" " > $postscript ...")
|
||||||
eval "ssh -p $PORT $USER@$HOST '$script'"
|
eval "ssh -p $PORT $USER@$HOST '$postscript'"
|
||||||
result=$(($result+$?))
|
result=$(($result+$?))
|
||||||
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST result: $?")
|
echo $(printf "%s" "$ ssh -p $PORT $USER@$HOST result: $?")
|
||||||
if [ "$result" -gt "0" ]; then exit $result; fi
|
if [ "$result" -gt "0" ]; then exit $result; fi
|
||||||
|
|||||||
Reference in New Issue
Block a user