mirror of
https://github.com/appleboy/drone-scp.git
synced 2026-06-16 14:49:20 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 66579b6dae | |||
| 06609f35cf | |||
| c9771cce78 | |||
| 6088f7da5a | |||
| 6de8f74170 | |||
| bb63d55f89 | |||
| da44b071c4 | |||
| a7eddc4b11 | |||
| 813faf56be | |||
| 4117d2ca30 |
@@ -157,15 +157,37 @@ pipeline:
|
||||
- example1.com
|
||||
- example2.com
|
||||
user: ubuntu
|
||||
password:
|
||||
from_secret: ssh_password
|
||||
port: 22
|
||||
- command_timeout: 120
|
||||
+ command_timeout: 2m
|
||||
from_secret: ssh_password
|
||||
target: /home/deploy/web
|
||||
source:
|
||||
- release/*.tar.gz
|
||||
```
|
||||
|
||||
Example configuration for ignore list:
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
scp:
|
||||
image: appleboy/drone-scp
|
||||
settings:
|
||||
host:
|
||||
- example1.com
|
||||
- example2.com
|
||||
user: ubuntu
|
||||
password:
|
||||
from_secret: ssh_password
|
||||
port: 22
|
||||
command_timeout: 2m
|
||||
target: /home/deploy/web
|
||||
source:
|
||||
+ - !release/README.md
|
||||
- release/*
|
||||
```
|
||||
|
||||
# Parameter Reference
|
||||
|
||||
host
|
||||
|
||||
@@ -43,11 +43,12 @@ pipeline:
|
||||
host:
|
||||
- example1.com
|
||||
- example2.com
|
||||
user: ubuntu
|
||||
username: ubuntu
|
||||
password:
|
||||
from_secret: ssh_password
|
||||
port: 22
|
||||
- command_timeout: 120
|
||||
+ command_timeout: 2m
|
||||
from_secret: ssh_password
|
||||
target: /home/deploy/web
|
||||
source:
|
||||
- release/*.tar.gz
|
||||
@@ -88,14 +89,6 @@ 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.
|
||||
|
||||
@@ -13,16 +13,15 @@ import (
|
||||
|
||||
// Version set at compile-time
|
||||
var (
|
||||
Version string
|
||||
BuildNum string
|
||||
Version string
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
app := cli.NewApp()
|
||||
app.Name = "Drone SCP"
|
||||
app.Usage = "Copy files and artifacts via SSH."
|
||||
app.Copyright = "Copyright (c) 2017 Bo-Yi Wu"
|
||||
app.Copyright = "Copyright (c) 2019 Bo-Yi Wu"
|
||||
app.Version = Version
|
||||
app.Authors = []cli.Author{
|
||||
{
|
||||
Name: "Bo-Yi Wu",
|
||||
@@ -35,23 +34,23 @@ func main() {
|
||||
cli.StringSliceFlag{
|
||||
Name: "host, H",
|
||||
Usage: "Server host",
|
||||
EnvVar: "PLUGIN_HOST,SCP_HOST,SSH_HOST",
|
||||
EnvVar: "PLUGIN_HOST,SCP_HOST,SSH_HOST,HOST",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "port, P",
|
||||
Value: "22",
|
||||
Usage: "Server port, default to 22",
|
||||
EnvVar: "PLUGIN_PORT,SCP_PORT,SSH_PORT",
|
||||
EnvVar: "PLUGIN_PORT,SCP_PORT,SSH_PORT,PORT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "username, u",
|
||||
Usage: "Server username",
|
||||
EnvVar: "PLUGIN_USERNAME,PLUGIN_USER,SCP_USERNAME,SSH_USERNAME",
|
||||
EnvVar: "PLUGIN_USERNAME,PLUGIN_USER,SCP_USERNAME,SSH_USERNAME,USERNAME",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "password, p",
|
||||
Usage: "Password for password-based authentication",
|
||||
EnvVar: "PLUGIN_PASSWORD,SCP_PASSWORD,SSH_PASSWORD",
|
||||
EnvVar: "PLUGIN_PASSWORD,SCP_PASSWORD,SSH_PASSWORD,PASSWORD",
|
||||
},
|
||||
cli.DurationFlag{
|
||||
Name: "timeout",
|
||||
@@ -67,7 +66,7 @@ func main() {
|
||||
cli.StringFlag{
|
||||
Name: "key, k",
|
||||
Usage: "ssh private key",
|
||||
EnvVar: "PLUGIN_KEY,SCP_KEY,SSH_KEY",
|
||||
EnvVar: "PLUGIN_KEY,SCP_KEY,SSH_KEY,KEY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "key-path, i",
|
||||
@@ -77,17 +76,17 @@ func main() {
|
||||
cli.StringSliceFlag{
|
||||
Name: "target, t",
|
||||
Usage: "Target path on the server",
|
||||
EnvVar: "PLUGIN_TARGET,SCP_TARGET",
|
||||
EnvVar: "PLUGIN_TARGET,SCP_TARGET,TARGET",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "source, s",
|
||||
Usage: "scp file list",
|
||||
EnvVar: "PLUGIN_SOURCE,SCP_SOURCE",
|
||||
EnvVar: "PLUGIN_SOURCE,SCP_SOURCE,SOURCE",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "rm, r",
|
||||
Usage: "remove target folder before upload data",
|
||||
EnvVar: "PLUGIN_RM,SCP_RM",
|
||||
EnvVar: "PLUGIN_RM,SCP_RM,RM",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "repo.owner",
|
||||
@@ -149,7 +148,7 @@ func main() {
|
||||
cli.StringFlag{
|
||||
Name: "proxy.ssh-key",
|
||||
Usage: "private ssh key of proxy",
|
||||
EnvVar: "PLUGIN_PROXY_SSH_KEY,PLUGIN_PROXY_KEY,PROXY_SSH_KEY",
|
||||
EnvVar: "PLUGIN_PROXY_SSH_KEY,PLUGIN_PROXY_KEY,PROXY_SSH_KEY,PROXY_KEY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "proxy.key-path",
|
||||
@@ -159,23 +158,23 @@ func main() {
|
||||
cli.StringFlag{
|
||||
Name: "proxy.username",
|
||||
Usage: "connect as user of proxy",
|
||||
EnvVar: "PLUGIN_PROXY_USERNAME,PLUGIN_PROXY_USER,PROXY_SSH_USERNAME",
|
||||
EnvVar: "PLUGIN_PROXY_USERNAME,PLUGIN_PROXY_USER,PROXY_SSH_USERNAME,PROXY_USERNAME",
|
||||
Value: "root",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "proxy.password",
|
||||
Usage: "user password of proxy",
|
||||
EnvVar: "PLUGIN_PROXY_PASSWORD,PROXY_SSH_PASSWORD",
|
||||
EnvVar: "PLUGIN_PROXY_PASSWORD,PROXY_SSH_PASSWORD,PROXY_PASSWORD",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "proxy.host",
|
||||
Usage: "connect to host of proxy",
|
||||
EnvVar: "PLUGIN_PROXY_HOST,PROXY_SSH_HOST",
|
||||
EnvVar: "PLUGIN_PROXY_HOST,PROXY_SSH_HOST,PROXY_HOST",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "proxy.port",
|
||||
Usage: "connect to port of proxy",
|
||||
EnvVar: "PLUGIN_PROXY_PORT,PROXY_SSH_PORT",
|
||||
EnvVar: "PLUGIN_PROXY_PORT,PROXY_SSH_PORT,PROXY_PORT",
|
||||
Value: "22",
|
||||
},
|
||||
cli.DurationFlag{
|
||||
@@ -233,14 +232,9 @@ VERSION:
|
||||
REPOSITORY:
|
||||
Github: https://github.com/appleboy/drone-scp
|
||||
`
|
||||
app.Version = Version
|
||||
|
||||
if BuildNum != "" {
|
||||
app.Version = app.Version + "+" + BuildNum
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
log.Println(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
// +build !windows
|
||||
|
||||
package main
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetRealPath(t *testing.T) {
|
||||
type args struct {
|
||||
|
||||
@@ -237,8 +237,8 @@ func (p *Plugin) Exec() error {
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(len(p.Config.Host))
|
||||
errChannel := make(chan error, 1)
|
||||
finished := make(chan bool, 1)
|
||||
errChannel := make(chan error)
|
||||
finished := make(chan struct{})
|
||||
for _, host := range p.Config.Host {
|
||||
go func(host string) {
|
||||
// Create MakeConfig instance with remote username, server address and path to private key.
|
||||
|
||||
Reference in New Issue
Block a user