GitHub - appleboy/drone-scp: Copy files and artifacts via SSH using a binary, docker or Drone CI. (original) (raw)

drone-scp

繁體中文 | 簡體中文

GoDoc Lint and Testing codecov Go Report Card Docker Pulls

Securely transfer files and artifacts via SSH using a standalone binary, Docker container, or Drone CI integration.

Features

+--------+ +----------+ +-----------+ | Laptop | <--> | Jumphost | <--> | FooServer | +--------+ +----------+ +-----------+

               OR

+--------+ +----------+ +-----------+ | Laptop | <--> | Firewall | <--> | FooServer | +--------+ +----------+ +-----------+ 192.168.1.5 121.1.2.3 10.10.29.68

Breaking changes

v1.5.0: change command timeout flag to Duration. See the following setting:

Build or Download a binary

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

With Go installed

export GO111MODULE=on go get -u -v github.com/appleboy/drone-scp

or build the binary with the following command:

export GOOS=linux export GOARCH=amd64 export CGO_ENABLED=0 export GO111MODULE=on

go test -cover ./...

go build -v -a -tags netgo -o release/linux/amd64/drone-scp .

Docker

Build the docker image with the following commands:

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 \

Using ssh-agent

Start your local ssh agent:

Import your local public key ~/.ssh/id_rsa

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 \

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):(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 \

Using ssh-agent, start your local ssh agent:

Import your local public key ~/.ssh/id_rsa

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):(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):(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_SOURCE=SOURCE_FILE_LIST
-e PLUGIN_TARGET=TARGET_FOLDER_PATH
-e PLUGIN_RM=false
-e PLUGIN_DEBUG=true
-v (pwd):(pwd):(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: