diff --git a/README.md b/README.md index 37b2ebe..72b0c8f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ This is meant to be used as a [Drone plugin](http://plugins.drone.io/). - **stack**: Name of the stack to be deployed - **compose** (default: `compose.yml`): compose file to use for deploying -- **host**: SSH-based docker daemon context to deploy against +- **host**: SSH-based docker daemon context to deploy against (don't include `ssh://`) +- **port** (default: `22`): SSH port to connect to - **deploy_key**: SSH private key part for ssh public key authentication ## Example @@ -24,7 +25,8 @@ steps: image: decentral1se/stack-ssh-deploy:0.0.1 settings: stack: mystack - host: "ssh://drone@swarm.autonomic.zone:222" + host: "drone@swarm.autonomic.zone" + port: 222 deploy_key: from_secret: drone_deploy_key ``` diff --git a/plugin.sh b/plugin.sh index b504645..de2d899 100755 --- a/plugin.sh +++ b/plugin.sh @@ -1,22 +1,24 @@ #!/bin/sh +PLUGIN_PORT=${PLUGIN_PORT:-22} +PLUGIN_COMPOSE=${PLUGIN_COMPOSE:-compose.yml} load_deploy_key() { mkdir -p "$HOME/.ssh/" - ssh-keyscan "$PLUGIN_HOST" > "$HOME/.ssh/known_hosts" + ssh-keyscan -p "$PLUGIN_PORT" "$PLUGIN_HOST" > "$HOME/.ssh/known_hosts" eval `ssh-agent` echo "$PLUGIN_DEPLOY_KEY" | ssh-add - } run_stack_deploy() { - PLUGIN_COMPOSE=${PLUGIN_COMPOSE:-compose.yml} - echo "--- start docker info ---" docker version echo "--- end docker info ---" - docker -H "$PLUGIN_HOST" stack deploy -c "$PLUGIN_COMPOSE" "$PLUGIN_STACK" + docker \ + -H "ssh://$PLUGIN_HOST:$PLUGIN_PORT" \ + stack deploy -c "$PLUGIN_COMPOSE" "$PLUGIN_STACK" } run_plugin() {