Go to file
Bo-Yi Wu 496e23a7e9 feat: improve coverage for easyssh (#42)
* feat: improve coverage for easyssh
2017-02-14 15:23:41 +08:00
easyssh feat: improve coverage for easyssh (#42) 2017-02-14 15:23:41 +08:00
tests feat: improve coverage for easyssh (#42) 2017-02-14 15:23:41 +08:00
vendor refactor: add vendor folder. (#34) 2017-02-12 17:51:17 +08:00
.drone.yml refactor: remove glide from drone config (#36) 2017-02-13 10:29:42 +08:00
.drone.yml.sig refactor: remove glide from drone config (#36) 2017-02-13 10:29:42 +08:00
.editorconfig initial projects. 2016-10-18 10:04:15 +08:00
.gitignore refactor: add vendor folder. (#34) 2017-02-12 17:51:17 +08:00
DOCS.md docs: [ci skip] update docs 2017-02-13 11:17:05 +08:00
Dockerfile update scp plugin. 2016-10-19 16:10:14 +08:00
Dockerfile.armhf rename sftp to scp. 2016-10-19 14:02:49 +08:00
LICENSE Initial commit 2016-10-16 21:35:56 +08:00
Makefile feat: improve coverage for easyssh (#42) 2017-02-14 15:23:41 +08:00
README.md docs: fix diff format. 2017-02-13 12:00:35 +08:00
logo.svg docs: [ci skip] update document. 2017-01-06 14:02:28 +08:00
main.go fix: duplicate of -t flag 2017-01-30 16:31:38 +08:00
path.go test: support windows testing. (#21) 2017-01-03 16:59:00 +08:00
path_windows.go test: support windows testing. (#21) 2017-01-03 16:59:00 +08:00
path_windows_test.go fix: golint error: missing ',' before newline 2017-01-07 11:33:51 +08:00
plugin.go feat: support wildcard file list. (#37) 2017-02-13 11:09:14 +08:00
plugin_test.go feat: support wildcard file list. (#37) 2017-02-13 11:09:14 +08:00

README.md

drone-scp

GoDoc Build Status codecov Go Report Card Docker Pulls

Copy files and artifacts via SSH using a binary, docker or Drone CI.

Feature

  • Support routines.
  • Support wildcard pattern on source list.
  • Support send files to multiple host.
  • Support send files to multiple target folder on host.
  • Support load ssh key from absolute path or raw body.

Build or Download a binary

The pre-compiled binaries can be downloaded from release page. Support the following OS type.

  • Windows amd64/386
  • Linux amd64/386
  • Darwin amd64/386

With Go installed

$ go get -u -v github.com/appleboy/drone-scp

or build the binary with the following command:

$ make build

Docker

Build the docker image with the following commands:

$ make docker

Please note incorrectly building the image for the correct x64 linux and with CGO disabled will result in an error when running the Docker image:

docker: Error response from daemon: Container command
'/bin/drone-scp' not found or does not exist..

Usage

There are three ways to send notification.

Usage from binary

Using public key

drone-scp --host example.com \
  --port 22 \
  --username appleboy \
  --key-path "${HOME}/.ssh/id_rsa" \
  --target /home/appleboy/test \
  --source your_local_folder_path

Using password

drone-scp --host example.com \
  --port 22 \
  --username appleboy \
+ --password xxxxxxx \
  --target /home/appleboy/test \
  --source your_local_folder_path

Using ssh-agent

Start your local ssh agent:

eval `ssh-agent -s`

Import your local public key ~/.ssh/id_rsa

$ ssh-add

You don't need to add --password or --key-path arguments.

drone-scp --host example.com \
  --port 22 \
  --username appleboy \
  --target /home/appleboy/test \
  --source your_local_folder_path

Send multiple source or target folder and hosts

drone-scp --host example1.com \
+ --host example2.com \
  --port 22 \
  --username appleboy \
  --password  xxxxxxx
  --target /home/appleboy/test1 \
+ --target /home/appleboy/test2 \
  --source your_local_folder_path_1
+ --source your_local_folder_path_2

Usage from docker

Using public key

docker run --rm \
  -e SCP_HOST example.com \
  -e SCP_USERNAME xxxxxxx \
  -e SCP_PORT 22 \
  -e SCP_KEY_PATH "${HOME}/.ssh/id_rsa"
  -e SCP_SOURCE SOURCE_FILE_LIST \
  -e SCP_TARGET TARGET_FOLDER_PATH \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  appleboy/drone-scp

Using password

docker run --rm \
  -e SCP_HOST example.com \
  -e SCP_USERNAME xxxxxxx \
  -e SCP_PORT 22 \
+ -e SCP_PASSWORD "xxxxxxx"
  -e SCP_SOURCE SOURCE_FILE_LIST \
  -e SCP_TARGET TARGET_FOLDER_PATH \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  appleboy/drone-scp

Using ssh-agent

Start your local ssh agent:

eval `ssh-agent -s`

Import your local public key ~/.ssh/id_rsa

$ ssh-add

You don't need to add SCP_PASSWORD or SCP_KEY_PATH arguments.

docker run --rm \
  -e SCP_HOST example.com \
  -e SCP_USERNAME xxxxxxx \
  -e SCP_PORT 22 \
  -e SCP_SOURCE SOURCE_FILE_LIST \
  -e SCP_TARGET TARGET_FOLDER_PATH \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  appleboy/drone-scp

Send multiple source or target folder and hosts

docker run --rm \
  -e SCP_HOST example1.com,example2.com \
  -e SCP_USERNAME xxxxxxx \
  -e SCP_PASSWORD xxxxxxx \
  -e SCP_PORT 22 \
  -e SCP_SOURCE SOURCE_FILE_LIST_1,SOURCE_FILE_LIST_2 \
  -e SCP_TARGET TARGET_FOLDER_PATH_1,TARGET_FOLDER_PATH_2 \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  appleboy/drone-scp

Usage from drone ci

Execute from the working directory:

docker run --rm \
  -e PLUGIN_HOST example.com \
  -e PLUGIN_USERNAME xxxxxxx \
  -e PLUGIN_PASSWORD xxxxxxx \
  -e PLUGIN_PORT xxxxxxx \
  -e PLUGIN_KEY "$(cat ${HOME}/.ssh/id_rsa)"
  -e PLUGIN_SOURCE SOURCE_FILE_LIST \
  -e PLUGIN_TARGET TARGET_FOLDER_PATH \
  -e PLUGIN_RM false \
  -e PLUGIN_DEBUG false \
  -e DRONE_REPO_OWNER appleboy \
  -e DRONE_REPO_NAME go-hello \
  -e DRONE_COMMIT_SHA e5e82b5eb3737205c25955dcc3dcacc839b7be52 \
  -e DRONE_COMMIT_BRANCH master \
  -e DRONE_COMMIT_AUTHOR appleboy \
  -e DRONE_BUILD_NUMBER 1 \
  -e DRONE_BUILD_STATUS success \
  -e DRONE_BUILD_LINK http://github.com/appleboy/go-hello \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  appleboy/drone-scp

You can get more information about how to use scp in drone.

Testing

Test the package with the following command:

$ make test