update readme.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2017-01-02 21:26:26 +08:00
parent df18b64cb4
commit 65e19227c4
+170 -21
View File
@@ -1,6 +1,6 @@
# drone-scp
[![GoDoc](https://godoc.org/github.com/appleboy/drone-scp?status.svg)](https://godoc.org/github.com/appleboy/drone-scp) [![Build Status](http://drone.wu-boy.com/api/badges/appleboy/drone-scp/status.svg)](http://drone.wu-boy.com/appleboy/drone-scp) [![codecov](https://codecov.io/gh/appleboy/drone-scp/branch/master/graph/badge.svg)](https://codecov.io/gh/appleboy/drone-scp) [![Go Report Card](https://goreportcard.com/badge/github.com/appleboy/drone-scp)](https://goreportcard.com/report/github.com/appleboy/drone-scp) [![Docker Pulls](https://img.shields.io/docker/pulls/appleboy/drone-scp.svg)](https://hub.docker.com/r/appleboy/drone-scp/)
[![GoDoc](https://godoc.org/github.com/appleboy/drone-scp?status.svg)](https://godoc.org/github.com/appleboy/drone-scp) [![Build Status](http://drone.wu-boy.com/api/badges/appleboy/drone-scp/status.svg)](http://drone.wu-boy.com/appleboy/drone-scp) [![codecov](https://codecov.io/gh/appleboy/drone-scp/branch/master/graph/badge.svg)](https://codecov.io/gh/appleboy/drone-scp) [![Go Report Card](https://goreportcard.com/badge/github.com/appleboy/drone-scp)](https://goreportcard.com/report/github.com/appleboy/drone-scp) [![Docker Pulls](https://img.shields.io/docker/pulls/appleboy/drone-scp.svg)](https://hub.docker.com/r/appleboy/drone-scp/) [![](https://images.microbadger.com/badges/image/appleboy/drone-scp.svg)](https://microbadger.com/images/appleboy/drone-scp "Get your own image badge on microbadger.com")
[Drone](https://github.com/drone/drone) plugin to copy files and artifacts via SSH.
@@ -11,22 +11,26 @@
* [x] Support send files to multiple target folder on host.
* [x] Support load ssh key from absolute path or raw body.
## Build
## Build or Download a binary
Build the binary with the following commands:
The pre-compiled binaries can be downloaded from [release page](https://github.com/appleboy/drone-scp/releases). 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
```
## Testing
Test the package with the following command:
```
$ make test
```
## Docker
Build the docker image with the following commands:
@@ -36,7 +40,7 @@ $ make docker
```
Please note incorrectly building the image for the correct x64 linux and with
GCO disabled will result in an error when running the Docker image:
CGO disabled will result in an error when running the Docker image:
```
docker: Error response from daemon: Container command
@@ -45,11 +49,159 @@ docker: Error response from daemon: Container command
## Usage
There are three ways to send notification.
* [usage from binary](#usage-from-binary)
* [usage from docker](#usage-from-docker)
* [usage from drone ci](#usage-from-drone-ci)
<a name="usage-from-binary"></a>
### Usage from binary
#### Using public key
```bash
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
```diff
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:
```bash
eval `ssh-agent -s`
```
Import your local public key `~/.ssh/id_rsa`
```bash
$ ssh-add
```
You don't need to add `--password` or `--key-path` arguments.
```bash
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
```diff
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
```
<a name="usage-from-docker"></a>
### Usage from docker
#### Using public key
```bash
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
```diff
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:
```bash
eval `ssh-agent -s`
```
Import your local public key `~/.ssh/id_rsa`
```bash
$ ssh-add
```
You don't need to add `SCP_PASSWORD` or `SCP_KEY_PATH ` arguments.
```bash
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
```bash
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
```
<a name="usage-from-drone-ci"></a>
### Usage from drone ci
Execute from the working directory:
```bash
docker run --rm \
-e PLUGIN_HOST=http://example.com \
-e PLUGIN_HOST=example.com \
-e PLUGIN_USERNAME=xxxxxxx \
-e PLUGIN_PASSWORD=xxxxxxx \
-e PLUGIN_PORT=xxxxxxx \
@@ -71,13 +223,10 @@ docker run --rm \
appleboy/drone-scp
```
Load all environments from file.
## Testing
Test the package with the following command:
```bash
docker run --rm \
-e ENV_FILE=your_env_file_path \
-e PLUGIN_KEY="$(cat ${HOME}/.ssh/id_rsa)" \
-v $(pwd):$(pwd) \
-w $(pwd) \
appleboy/drone-scp
```
$ make test
```