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 | |
|---|---|---|---|
| 28824dfd1a | |||
| 22b6f8b9b4 | |||
| 1d806cc9ed | |||
| dd049e69b9 | |||
| 61940b4c0e | |||
| f20fc0b114 | |||
| ed00c6ef85 | |||
| cc822cd578 | |||
| 77dbb22aed | |||
| b69d758088 |
@@ -0,0 +1,186 @@
|
||||
---
|
||||
date: 2017-01-06T00:00:00+00:00
|
||||
title: SCP
|
||||
author: appleboy
|
||||
tags: [ publish, ssh, scp ]
|
||||
repo: appleboy/drone-scp
|
||||
logo: term.svg
|
||||
image: appleboy/drone-scp
|
||||
---
|
||||
|
||||
The SCP plugin copy files and artifacts to target host machine via SSH. The below pipeline configuration demonstrates simple usage:
|
||||
|
||||
```yaml
|
||||
pipeline:
|
||||
scp:
|
||||
image: appleboy/drone-scp
|
||||
host: example.com
|
||||
target: /home/deploy/web
|
||||
source: release.tar.gz
|
||||
```
|
||||
|
||||
Example configuration with custom username, password and port:
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
scp:
|
||||
image: appleboy/drone-scp
|
||||
host: example.com
|
||||
+ username: appleboy
|
||||
+ password: 12345678
|
||||
+ port: 4430
|
||||
target: /home/deploy/web
|
||||
source: release.tar.gz
|
||||
```
|
||||
|
||||
Example configuration with multiple source and target folder:
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
scp:
|
||||
image: appleboy/drone-scp
|
||||
host: example.com
|
||||
target:
|
||||
+ - /home/deploy/web1
|
||||
+ - /home/deploy/web2
|
||||
source:
|
||||
+ - release_1.tar.gz
|
||||
+ - release_2.tar.gz
|
||||
```
|
||||
|
||||
Example configuration with multiple host:
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
scp:
|
||||
image: appleboy/drone-scp
|
||||
- host: example.com
|
||||
+ host:
|
||||
+ - example1.com
|
||||
+ - example2.com
|
||||
target: /home/deploy/web
|
||||
source: release.tar.gz
|
||||
```
|
||||
|
||||
Remove target folder before copy files and artifacts to target:
|
||||
|
||||
```diff
|
||||
scp:
|
||||
image: appleboy/drone-scp
|
||||
host: example.com
|
||||
target: /home/deploy/web
|
||||
source: release.tar.gz
|
||||
+ rm: true
|
||||
```
|
||||
|
||||
Example configuration for success build:
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
scp:
|
||||
image: appleboy/drone-scp
|
||||
host: example.com
|
||||
target: /home/deploy/web
|
||||
source: release.tar.gz
|
||||
+ when:
|
||||
+ status: success
|
||||
```
|
||||
|
||||
Example configuration for tag event:
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
scp:
|
||||
image: appleboy/drone-scp
|
||||
host: example.com
|
||||
target: /home/deploy/web
|
||||
source: release.tar.gz
|
||||
+ when:
|
||||
+ status: success
|
||||
+ event: tag
|
||||
```
|
||||
|
||||
# Secrets
|
||||
|
||||
The SCP plugin supports reading credentials from the Drone secret store. This is strongly recommended instead of storing credentials in the pipeline configuration in plain text.
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
scp:
|
||||
image: appleboy/drone-scp
|
||||
host: example.com
|
||||
username: appleboy
|
||||
- password: 12345678
|
||||
port: 4430
|
||||
target: /home/deploy/web
|
||||
source: release.tar.gz
|
||||
```
|
||||
|
||||
The `password` or `key` attributes can be replaced with the below secret environment variables. Please see the Drone documentation to learn more about secrets.
|
||||
|
||||
SCP_PASSWORD
|
||||
: password of target host user
|
||||
|
||||
SCP_KEY
|
||||
: plain text of user private key
|
||||
|
||||
# Parameter Reference
|
||||
|
||||
host
|
||||
: target hostname or IP
|
||||
|
||||
port
|
||||
: ssh port of target host
|
||||
|
||||
username
|
||||
: account for target host user
|
||||
|
||||
password
|
||||
: password for target host user
|
||||
|
||||
key
|
||||
: plain text of user private key
|
||||
|
||||
target
|
||||
: folder path of target host
|
||||
|
||||
source
|
||||
: source lists you want to copy
|
||||
|
||||
rm
|
||||
: remove target folder before copy files and artifacts
|
||||
|
||||
# Template Reference
|
||||
|
||||
repo.owner
|
||||
: repository owner
|
||||
|
||||
repo.name
|
||||
: repository name
|
||||
|
||||
build.status
|
||||
: build status type enumeration, either `success` or `failure`
|
||||
|
||||
build.event
|
||||
: build event type enumeration, one of `push`, `pull_request`, `tag`, `deployment`
|
||||
|
||||
build.number
|
||||
: build number
|
||||
|
||||
build.commit
|
||||
: git sha for current commit
|
||||
|
||||
build.branch
|
||||
: git branch for current commit
|
||||
|
||||
build.tag
|
||||
: git tag for current commit
|
||||
|
||||
build.ref
|
||||
: git ref for current commit
|
||||
|
||||
build.author
|
||||
: git author for current commit
|
||||
|
||||
build.link
|
||||
: link the the build results in drone
|
||||
@@ -7,7 +7,7 @@ EXECUTABLE := drone-scp
|
||||
DEPLOY_ACCOUNT := appleboy
|
||||
DEPLOY_IMAGE := $(EXECUTABLE)
|
||||
|
||||
TARGETS ?= linux darwin
|
||||
TARGETS ?= linux darwin windows
|
||||
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
|
||||
SOURCES ?= $(shell find . -name "*.go" -type f)
|
||||
TAGS ?=
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://godoc.org/github.com/appleboy/drone-scp) [](http://drone.wu-boy.com/appleboy/drone-scp) [](https://codecov.io/gh/appleboy/drone-scp) [](https://goreportcard.com/report/github.com/appleboy/drone-scp) [](https://hub.docker.com/r/appleboy/drone-scp/) [](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.
|
||||
Copy files and artifacts via SSH using a binary, docker or [Drone CI](http://readme.drone.io/0.5/).
|
||||
|
||||
## Feature
|
||||
|
||||
@@ -61,23 +61,23 @@ There are three ways to send notification.
|
||||
#### 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
|
||||
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
|
||||
drone-scp --host example.com \
|
||||
--port 22 \
|
||||
--username appleboy \
|
||||
+ --password xxxxxxx \
|
||||
--target /home/appleboy/test \
|
||||
--source your_local_folder_path
|
||||
```
|
||||
|
||||
#### Using ssh-agent
|
||||
@@ -97,25 +97,25 @@ $ 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
|
||||
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
|
||||
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>
|
||||
@@ -125,12 +125,12 @@ drone-scp --host=example1.com \
|
||||
|
||||
```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 \
|
||||
-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
|
||||
@@ -140,12 +140,12 @@ docker run --rm \
|
||||
|
||||
```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 \
|
||||
-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
|
||||
@@ -169,11 +169,11 @@ 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 \
|
||||
-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
|
||||
@@ -183,12 +183,12 @@ docker run --rm \
|
||||
|
||||
```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 \
|
||||
-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
|
||||
@@ -201,32 +201,34 @@ Execute from the working directory:
|
||||
|
||||
```bash
|
||||
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 \
|
||||
-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](DOCS.md) about how to use scp in drone.
|
||||
|
||||
## Testing
|
||||
|
||||
Test the package with the following command:
|
||||
|
||||
```
|
||||
$ make test
|
||||
```
|
||||
```
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="256px" height="210px" viewBox="0 0 256 210" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
||||
<g>
|
||||
<rect fill="#000000" x="0" y="0" width="256" height="209.342334" rx="5"></rect>
|
||||
<path d="M28.2414658,21.7735776 C27.3856638,20.9177756 26.3529412,20.4898746 25.143298,20.4898746 C23.9336548,20.4898746 22.8968177,20.9218901 22.0327869,21.7859209 C21.1810993,22.6376085 20.7490839,23.6744455 20.7490839,24.8840887 C20.7490839,26.0937319 21.1810993,27.1305689 22.0327869,27.9822565 L35.4746384,41.424108 L22.0451302,54.8536162 C21.1810993,55.7176471 20.7490839,56.7544841 20.7367406,57.9641273 C20.7490839,59.1737705 21.1810993,60.2106075 22.0327869,61.0622951 C22.8968177,61.9139826 23.9336548,62.3459981 25.1309547,62.3583414 C26.3529412,62.3583414 27.3897782,61.9263259 28.2538091,61.0622951 L43.1891996,46.1145612 C46.3243973,42.9917068 46.3243973,39.8565092 43.1891996,36.7213115 L28.2414658,21.7735776 L28.2414658,21.7735776 Z M86.7857281,54.8783028 C85.9216972,54.0142719 84.8725169,53.5822565 83.6505304,53.5822565 L83.6505304,53.5760849 L54.8165863,53.5760849 L54.8165863,53.5822565 C53.5945998,53.5822565 52.5577628,54.0142719 51.6937319,54.8783028 C50.8297011,55.7423337 50.3976856,56.7791707 50.3976856,58.0011572 C50.3976856,59.2231437 50.8297011,60.272324 51.6937319,61.1363549 C52.5577628,62.0003857 53.5945998,62.4324012 54.8165863,62.4324012 L54.8165863,62.4262295 L83.6505304,62.4262295 L83.6505304,62.4324012 C84.8725169,62.4324012 85.9216972,62.0003857 86.7857281,61.1363549 C87.6497589,60.272324 88.0817743,59.2231437 88.0817743,58.0011572 C88.0817743,56.7791707 87.6497589,55.7423337 86.7857281,54.8783028 L86.7857281,54.8783028 L86.7857281,54.8783028 Z" fill="#FFFFFF"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
@@ -12,60 +11,64 @@ import (
|
||||
// Version set at compile-time
|
||||
var Version = "v1.0.0-dev"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
app := cli.NewApp()
|
||||
app.Name = "scp plugin"
|
||||
app.Usage = "scp plugin"
|
||||
app.Name = "Drone SCP"
|
||||
app.Usage = "Copy files and artifacts via SSH."
|
||||
app.Copyright = "Copyright (c) 2017 Bo-Yi Wu"
|
||||
app.Authors = []cli.Author{
|
||||
{
|
||||
Name: "Bo-Yi Wu",
|
||||
Email: "appleboy.tw@gmail.com",
|
||||
},
|
||||
}
|
||||
app.Action = run
|
||||
app.Version = Version
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringSliceFlag{
|
||||
Name: "host",
|
||||
Name: "host, H",
|
||||
Usage: "Server host",
|
||||
EnvVar: "PLUGIN_HOST,SCP_HOST",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "port",
|
||||
Name: "port, P",
|
||||
Value: "22",
|
||||
Usage: "Server port, default to 22",
|
||||
EnvVar: "PLUGIN_PORT,SCP_PORT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "username",
|
||||
Name: "username, u",
|
||||
Usage: "Server username",
|
||||
EnvVar: "PLUGIN_USERNAME,SCP_USERNAME",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "password",
|
||||
Name: "password, p",
|
||||
Usage: "Password for password-based authentication",
|
||||
EnvVar: "PLUGIN_PASSWORD,SCP_PASSWORD",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "key",
|
||||
Name: "key, k",
|
||||
Usage: "ssh private key",
|
||||
EnvVar: "PLUGIN_KEY,SCP_KEY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "key-path",
|
||||
Name: "key-path, i",
|
||||
Usage: "ssh private key path",
|
||||
EnvVar: "PLUGIN_KEY_PATH,SCP_KEY_PATH",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "target",
|
||||
Name: "target, t",
|
||||
Usage: "Target path on the server",
|
||||
EnvVar: "PLUGIN_TARGET,SCP_TARGET",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "source",
|
||||
Name: "source, s",
|
||||
Usage: "scp file list",
|
||||
EnvVar: "PLUGIN_SOURCE,SCP_SOURCE",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "rm",
|
||||
Name: "rm, r",
|
||||
Usage: "remove target folder before upload data",
|
||||
EnvVar: "PLUGIN_RM,SCP_RM",
|
||||
},
|
||||
@@ -127,6 +130,39 @@ func main() {
|
||||
Usage: "source env file",
|
||||
},
|
||||
}
|
||||
|
||||
// Override a template
|
||||
cli.AppHelpTemplate = `
|
||||
________ ____________________________
|
||||
\______ \_______ ____ ____ ____ / _____/\_ ___ \______ \
|
||||
| | \_ __ \/ _ \ / \_/ __ \ ______ \_____ \ / \ \/| ___/
|
||||
| | \ | \( <_> ) | \ ___/ /_____/ / \\ \___| |
|
||||
/_______ /__| \____/|___| /\___ > /_______ / \______ /____|
|
||||
\/ \/ \/ \/ \/
|
||||
version: {{.Version}}
|
||||
NAME:
|
||||
{{.Name}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
|
||||
{{if len .Authors}}
|
||||
AUTHOR:
|
||||
{{range .Authors}}{{ . }}{{end}}
|
||||
{{end}}{{if .Commands}}
|
||||
COMMANDS:
|
||||
{{range .Commands}}{{if not .HideHelp}} {{join .Names ", "}}{{ "\t"}}{{.Usage}}{{ "\n" }}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
|
||||
GLOBAL OPTIONS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}{{end}}{{if .Copyright }}
|
||||
COPYRIGHT:
|
||||
{{.Copyright}}
|
||||
{{end}}{{if .Version}}
|
||||
VERSION:
|
||||
{{.Version}}
|
||||
{{end}}
|
||||
REPOSITORY:
|
||||
Github: https://github.com/appleboy/drone-scp
|
||||
`
|
||||
app.Run(os.Args)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package main
|
||||
|
||||
func getRealPath(path string) string {
|
||||
return path
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// +build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func getRealPath(path string) string {
|
||||
return "/" + strings.Replace(strings.Replace(path, ":", "", -1), "\\", "/", -1)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetRealPath(t *testing.T) {
|
||||
type args struct {
|
||||
path string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{
|
||||
"Test Windows Path",
|
||||
"C:\\Users\\appleboy\\test.txt",
|
||||
"/C/Users/appleboy/test.txt",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := getRealPath(tt.args.path); got != tt.want {
|
||||
t.Errorf("%q. getRealPath() = %v, want %v", tt.name, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,8 @@ func (p Plugin) Exec() error {
|
||||
|
||||
// run archive command
|
||||
log.Println("tar all files into " + tar)
|
||||
args := append(append([]string{}, "-cf", tar), files...)
|
||||
args := append(append([]string{}, "-cf", getRealPath(tar)), files...)
|
||||
|
||||
cmd := exec.Command("tar", args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
Reference in New Issue
Block a user