Compare commits

...

20 Commits

Author SHA1 Message Date
Bo-Yi Wu bad565d475 update success message format.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-02-27 09:53:36 +08:00
Bo-Yi Wu 8216bd8fb8 update to go 1.14
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-02-27 09:51:12 +08:00
Daniel Bingham 3d36432240 Fix typo in EnvVars for ssh-passphrase (#109) 2020-02-27 08:58:49 +08:00
Bo-Yi Wu 2fcaffcac8 docs: update passphrase variable
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-02-07 13:27:23 +08:00
Bo-Yi Wu c1e3242f53 update module
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-02-07 13:24:23 +08:00
Bo-Yi Wu 8e4a3f5e0c chore(makefile): remove GOPACKAGE variable 2020-02-01 00:41:34 +08:00
Bo-Yi Wu fe231a1c43 docs: add passphrase 2020-01-20 22:37:45 +08:00
Bo-Yi Wu 177625c6e7 chore: support passphrase (#107)
* chore: support passphrase
2020-01-20 22:34:16 +08:00
Bo-Yi Wu bb6466e8d9 chore: upgrade easyssh-proxy to v1.3.0 2020-01-19 23:40:00 +08:00
Bo-Yi Wu e5eae442c3 chore: update urfave/cli to v2 2020-01-19 23:38:47 +08:00
Bo-Yi Wu b73ec894ab chore: update default timeout to 10 minutes 2019-11-30 23:08:26 +08:00
Bo-Yi Wu 05eba8f809 docs(install): Add export GO111MODULE=on 2019-11-12 10:34:51 +08:00
Bo-Yi Wu a2493062f7 upgrade go module
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-11-12 10:11:21 +08:00
Bo-Yi Wu b2b346a0ca update example
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-11-04 14:11:57 +08:00
Bo-Yi Wu 9d8f5ac419 update
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-11-04 13:43:54 +08:00
Bo-Yi Wu 5d93e7b8ab docs: update diff format 2019-10-18 22:40:46 +08:00
Bo-Yi Wu bf812f8e29 update docs
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-10-14 23:34:52 +08:00
Bo-Yi Wu 8814cfe72c docs: update drone 2019-10-14 23:33:18 +08:00
Bo-Yi Wu 954e0069e6 docs: update readme 2019-10-10 01:25:32 +08:00
Bo-Yi Wu 03524ed8bd docs: update to drone 1.0 format. 2019-09-29 02:01:24 +08:00
12 changed files with 409 additions and 294 deletions
+29 -29
View File
@@ -9,7 +9,7 @@ platform:
steps: steps:
- name: vet - name: vet
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- make vet - make vet
volumes: volumes:
@@ -18,7 +18,7 @@ steps:
- name: lint - name: lint
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- make lint - make lint
volumes: volumes:
@@ -27,7 +27,7 @@ steps:
- name: misspell - name: misspell
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- make misspell-check - make misspell-check
volumes: volumes:
@@ -36,7 +36,7 @@ steps:
- name: test - name: test
pull: always pull: always
image: golang:1.13-alpine image: golang:1.14-alpine
commands: commands:
- apk add git make curl perl bash build-base zlib-dev ucl-dev - apk add git make curl perl bash build-base zlib-dev ucl-dev
- make ssh-server - make ssh-server
@@ -68,9 +68,9 @@ platform:
steps: steps:
- name: build-push - name: build-push
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-scp - "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-scp"
environment: environment:
CGO_ENABLED: 0 CGO_ENABLED: 0
when: when:
@@ -80,9 +80,9 @@ steps:
- name: build-tag - name: build-tag
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-scp - "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-scp"
environment: environment:
CGO_ENABLED: 0 CGO_ENABLED: 0
when: when:
@@ -91,7 +91,7 @@ steps:
- name: executable - name: executable
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- ./release/linux/amd64/drone-scp --help - ./release/linux/amd64/drone-scp --help
@@ -130,8 +130,8 @@ steps:
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- refs/pull/** - "refs/pull/**"
- refs/tags/** - "refs/tags/**"
depends_on: depends_on:
- testing - testing
@@ -147,9 +147,9 @@ platform:
steps: steps:
- name: build-push - name: build-push
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-scp - "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-scp"
environment: environment:
CGO_ENABLED: 0 CGO_ENABLED: 0
when: when:
@@ -159,9 +159,9 @@ steps:
- name: build-tag - name: build-tag
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-scp - "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-scp"
environment: environment:
CGO_ENABLED: 0 CGO_ENABLED: 0
when: when:
@@ -170,7 +170,7 @@ steps:
- name: executable - name: executable
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- ./release/linux/arm64/drone-scp --help - ./release/linux/arm64/drone-scp --help
@@ -209,8 +209,8 @@ steps:
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- refs/pull/** - "refs/pull/**"
- refs/tags/** - "refs/tags/**"
depends_on: depends_on:
- testing - testing
@@ -226,9 +226,9 @@ platform:
steps: steps:
- name: build-push - name: build-push
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-scp - "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-scp"
environment: environment:
CGO_ENABLED: 0 CGO_ENABLED: 0
when: when:
@@ -238,9 +238,9 @@ steps:
- name: build-tag - name: build-tag
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-scp - "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-scp"
environment: environment:
CGO_ENABLED: 0 CGO_ENABLED: 0
when: when:
@@ -249,7 +249,7 @@ steps:
- name: executable - name: executable
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- ./release/linux/arm/drone-scp --help - ./release/linux/arm/drone-scp --help
@@ -288,8 +288,8 @@ steps:
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- refs/pull/** - "refs/pull/**"
- refs/tags/** - "refs/tags/**"
depends_on: depends_on:
- testing - testing
@@ -305,7 +305,7 @@ platform:
steps: steps:
- name: build-all-binary - name: build-all-binary
pull: always pull: always
image: golang:1.13 image: golang:1.14
commands: commands:
- make release - make release
when: when:
@@ -319,14 +319,14 @@ steps:
api_key: api_key:
from_secret: github_release_api_key from_secret: github_release_api_key
files: files:
- dist/release/* - "dist/release/*"
when: when:
event: event:
- tag - tag
trigger: trigger:
ref: ref:
- refs/tags/** - "refs/tags/**"
depends_on: depends_on:
- testing - testing
@@ -354,7 +354,7 @@ steps:
trigger: trigger:
ref: ref:
- refs/heads/master - refs/heads/master
- refs/tags/** - "refs/tags/**"
depends_on: depends_on:
- linux-amd64 - linux-amd64
+50 -45
View File
@@ -11,35 +11,21 @@ image: appleboy/drone-scp
The SCP plugin copy files and artifacts to target host machine via SSH. The below pipeline configuration demonstrates simple usage: The SCP plugin copy files and artifacts to target host machine via SSH. The below pipeline configuration demonstrates simple usage:
```yaml ```yaml
pipeline: - name: scp files
scp: image: appleboy/drone-scp
image: appleboy/drone-scp settings:
settings: host: example.com
host: example.com username: foo
target: /home/deploy/web password: bar
source: release.tar.gz port: 22
``` target: /var/www/deploy/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}
source: release.tar.gz
Example configuration with custom username, password and port:
```diff
pipeline:
scp:
image: appleboy/drone-scp
settings:
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: Example configuration with multiple source and target folder:
```diff ```diff
pipeline: - name: scp files
scp:
image: appleboy/drone-scp image: appleboy/drone-scp
settings: settings:
host: example.com host: example.com
@@ -54,8 +40,7 @@ pipeline:
Example configuration with multiple host: Example configuration with multiple host:
```diff ```diff
pipeline: - name: scp files
scp:
image: appleboy/drone-scp image: appleboy/drone-scp
settings: settings:
- host: example.com - host: example.com
@@ -69,8 +54,7 @@ pipeline:
Example configuration with wildcard pattern of source list: Example configuration with wildcard pattern of source list:
```diff ```diff
pipeline: - name: scp files
scp:
image: appleboy/drone-scp image: appleboy/drone-scp
settings: settings:
host: host:
@@ -86,9 +70,8 @@ pipeline:
Remove target folder before copy files and artifacts to target: Remove target folder before copy files and artifacts to target:
```diff ```diff
scp: - name: scp files
image: appleboy/drone-scp image: appleboy/drone-scp
host: example.com
settings: settings:
target: /home/deploy/web target: /home/deploy/web
source: release.tar.gz source: release.tar.gz
@@ -98,7 +81,7 @@ Remove target folder before copy files and artifacts to target:
Example for remove the specified number of leading path elements: Example for remove the specified number of leading path elements:
```diff ```diff
scp: - name: scp files
image: appleboy/drone-scp image: appleboy/drone-scp
settings: settings:
host: example.com host: example.com
@@ -110,8 +93,7 @@ Example for remove the specified number of leading path elements:
Example configuration using SSHProxyCommand: Example configuration using SSHProxyCommand:
```diff ```diff
pipeline: - name: scp files
scp:
image: appleboy/drone-scp image: appleboy/drone-scp
settings: settings:
host: host:
@@ -129,8 +111,7 @@ pipeline:
Example configuration using password from secrets: Example configuration using password from secrets:
```diff ```diff
pipeline: - name: scp files
scp:
image: appleboy/drone-scp image: appleboy/drone-scp
settings: settings:
host: host:
@@ -149,29 +130,27 @@ pipeline:
Example configuration using command timeout: Example configuration using command timeout:
```diff ```diff
pipeline: - name: scp files
scp:
image: appleboy/drone-scp image: appleboy/drone-scp
settings: settings:
host: host:
- example1.com - example1.com
- example2.com - example2.com
user: ubuntu user: ubuntu
password: password:
from_secret: ssh_password from_secret: ssh_password
port: 22 port: 22
- command_timeout: 120 - command_timeout: 120
+ command_timeout: 2m + command_timeout: 2m
target: /home/deploy/web target: /home/deploy/web
source: source:
- release/*.tar.gz - release/*.tar.gz
``` ```
Example configuration for ignore list: Example configuration for ignore list:
```diff ```diff
pipeline: - name: scp files
scp:
image: appleboy/drone-scp image: appleboy/drone-scp
settings: settings:
host: host:
@@ -188,6 +167,26 @@ pipeline:
- release/* - release/*
``` ```
Example configuration for passphrase which protecting a private key:
```diff
- name: scp files
image: appleboy/drone-scp
settings:
host:
- example1.com
- example2.com
user: ubuntu
+ key:
+ from_secret: ssh_key
+ passphrase: 1234
port: 22
command_timeout: 2m
target: /home/deploy/web
source:
- release/*
```
## Parameter Reference ## Parameter Reference
host host
@@ -205,6 +204,9 @@ password
key key
: plain text of user private key : plain text of user private key
passphrase
: The purpose of the passphrase is usually to encrypt the private key.
target target
: folder path of target host : folder path of target host
@@ -215,10 +217,10 @@ rm
: remove target folder before copy files and artifacts : remove target folder before copy files and artifacts
timeout timeout
: timeout is the maximum amount of time for the TCP connection to establish : Timeout is the maximum amount of time for the ssh connection to establish, default is 30 seconds.
command_timeout command_timeout
: timeout is the maximum amount of time for execute command : Command timeout is the maximum amount of time for the execute commands, default is 10 minutes.
strip_components strip_components
: remove the specified number of leading path elements : remove the specified number of leading path elements
@@ -250,6 +252,9 @@ proxy_key
proxy_key_path proxy_key_path
: key path of proxy private key : key path of proxy private key
proxy_passphrase
: The purpose of the passphrase is usually to encrypt the private key.
## Template Reference ## Template Reference
repo.owner repo.owner
+4 -7
View File
@@ -9,7 +9,6 @@ DEPLOY_IMAGE := $(EXECUTABLE)
TARGETS ?= linux darwin windows TARGETS ?= linux darwin windows
ARCHS ?= amd64 386 ARCHS ?= amd64 386
PACKAGES ?= $(shell $(GO) list ./...)
SOURCES ?= $(shell find . -name "*.go" -type f) SOURCES ?= $(shell find . -name "*.go" -type f)
TAGS ?= TAGS ?=
LDFLAGS ?= -X 'main.Version=$(VERSION)' LDFLAGS ?= -X 'main.Version=$(VERSION)'
@@ -32,7 +31,7 @@ fmt:
$(GOFMT) -w $(SOURCES) $(GOFMT) -w $(SOURCES)
vet: vet:
$(GO) vet $(PACKAGES) $(GO) vet ./...
lint: lint:
@hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ @hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
@@ -64,7 +63,7 @@ fmt-check:
fi; fi;
test: fmt-check test: fmt-check
@$(GO) test -v -cover -coverprofile coverage.txt $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1 @$(GO) test -v -cover -coverprofile coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1
install: $(SOURCES) install: $(SOURCES)
$(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' $(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
@@ -122,7 +121,8 @@ ssh-server:
echo drone-scp:1234 | chpasswd echo drone-scp:1234 | chpasswd
mkdir -p /home/drone-scp/.ssh mkdir -p /home/drone-scp/.ssh
chmod 700 /home/drone-scp/.ssh chmod 700 /home/drone-scp/.ssh
cp tests/.ssh/id_rsa.pub /home/drone-scp/.ssh/authorized_keys cat tests/.ssh/id_rsa.pub >> /home/drone-scp/.ssh/authorized_keys
cat tests/.ssh/test.pub >> /home/drone-scp/.ssh/authorized_keys
chown -R drone-scp /home/drone-scp/.ssh chown -R drone-scp /home/drone-scp/.ssh
# install ssh and start server # install ssh and start server
apk add --update openssh openrc apk add --update openssh openrc
@@ -136,6 +136,3 @@ coverage:
clean: clean:
$(GO) clean -x -i ./... $(GO) clean -x -i ./...
rm -rf coverage.txt $(EXECUTABLE) $(DIST) rm -rf coverage.txt $(EXECUTABLE) $(DIST)
version:
@echo $(VERSION)
+2 -2
View File
@@ -36,8 +36,7 @@ Copy files and artifacts via SSH using a binary, docker or [Drone CI](http://doc
`v1.5.0`: change command timeout flag to `Duration`. See the following setting: `v1.5.0`: change command timeout flag to `Duration`. See the following setting:
```diff ```diff
pipeline: - name: scp files
scp:
image: appleboy/drone-scp image: appleboy/drone-scp
settings: settings:
host: host:
@@ -65,6 +64,7 @@ The pre-compiled binaries can be downloaded from [release page](https://github.c
With `Go` installed With `Go` installed
```sh ```sh
export GO111MODULE=on
go get -u -v github.com/appleboy/drone-scp go get -u -v github.com/appleboy/drone-scp
``` ```
+3 -5
View File
@@ -4,11 +4,9 @@ go 1.13
require ( require (
github.com/appleboy/com v0.0.2 github.com/appleboy/com v0.0.2
github.com/appleboy/easyssh-proxy v1.2.0 github.com/appleboy/easyssh-proxy v1.3.0
github.com/fatih/color v1.7.0 github.com/fatih/color v1.9.0
github.com/joho/godotenv v1.3.0 github.com/joho/godotenv v1.3.0
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.9 // indirect
github.com/stretchr/testify v1.4.0 github.com/stretchr/testify v1.4.0
github.com/urfave/cli v1.22.1 github.com/urfave/cli/v2 v2.1.1
) )
+22 -15
View File
@@ -1,21 +1,25 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/ScaleFT/sshkeys v0.0.0-20181112160850-82451a803681 h1:JS2rl38kZmHgWa0xINSaSYH0Whtvem64/4+Ef0+Y5pE=
github.com/ScaleFT/sshkeys v0.0.0-20181112160850-82451a803681/go.mod h1:WfDateMPQ/55dPbZRp5Zxrux5WiEaHsjk9puUhz0KgY=
github.com/appleboy/com v0.0.2 h1:sexcPX7gp7peXMlOJMxEYcRucW7DW0XHgFZqUB6PI6g= github.com/appleboy/com v0.0.2 h1:sexcPX7gp7peXMlOJMxEYcRucW7DW0XHgFZqUB6PI6g=
github.com/appleboy/com v0.0.2/go.mod h1:jnufjIC3opMlReyPPPye+8JqNvUzLm25o7h6SOy8nv0= github.com/appleboy/com v0.0.2/go.mod h1:jnufjIC3opMlReyPPPye+8JqNvUzLm25o7h6SOy8nv0=
github.com/appleboy/easyssh-proxy v1.2.0 h1:KvaUGC18WkBFet+N1oofQy03jkC5HaKFn2XGxFxCTtg= github.com/appleboy/easyssh-proxy v1.3.0 h1:ToH+hZDPWP9/9E58lwxDLJQSHvgGgDAQ9ZVx6x5oofI=
github.com/appleboy/easyssh-proxy v1.2.0/go.mod h1:vHskChUNhxwW4dXMe2MNE/k+UBCkBagrQDm70UWZrS0= github.com/appleboy/easyssh-proxy v1.3.0/go.mod h1:Kk57I3w7OCafOjp5kgZFvxk2fO8Tca5CriBTOsbSbjY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a h1:saTgr5tMLFnmy/yg3qDTft4rE5DY2uJ/cCxCe3q0XTU=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a/go.mod h1:Bw9BbhOJVNR+t0jCqx2GC6zv0TGBsShs56Y3gfSCvl0=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg= github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
@@ -26,15 +30,18 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25 h1:jsG6UpNLt9iAsb0S2AGW28DveNzzgmbXR+ENoPjUeIU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 h1:sKJQZMuxjOAR/Uo2LBfU90onWEf1dF4C+0hPJCc9Mpc=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+164 -151
View File
@@ -8,7 +8,7 @@ import (
"github.com/appleboy/easyssh-proxy" "github.com/appleboy/easyssh-proxy"
"github.com/joho/godotenv" "github.com/joho/godotenv"
_ "github.com/joho/godotenv/autoload" _ "github.com/joho/godotenv/autoload"
"github.com/urfave/cli" "github.com/urfave/cli/v2"
) )
// Version set at compile-time // Version set at compile-time
@@ -22,7 +22,7 @@ func main() {
app.Usage = "Copy files and artifacts via SSH." app.Usage = "Copy files and artifacts via SSH."
app.Copyright = "Copyright (c) 2019 Bo-Yi Wu" app.Copyright = "Copyright (c) 2019 Bo-Yi Wu"
app.Version = Version app.Version = Version
app.Authors = []cli.Author{ app.Authors = []*cli.Author{
{ {
Name: "Bo-Yi Wu", Name: "Bo-Yi Wu",
Email: "appleboy.tw@gmail.com", Email: "appleboy.tw@gmail.com",
@@ -31,182 +31,193 @@ func main() {
app.Action = run app.Action = run
app.Version = Version app.Version = Version
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: "host, H", Name: "host, H",
Usage: "Server host", Usage: "Server host",
EnvVar: "PLUGIN_HOST,SCP_HOST,SSH_HOST,HOST,INPUT_HOST", EnvVars: []string{"PLUGIN_HOST", "SCP_HOST", "SSH_HOST", "HOST", "INPUT_HOST"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "port, P", Name: "port, P",
Value: "22", Value: "22",
Usage: "Server port, default to 22", Usage: "Server port, default to 22",
EnvVar: "PLUGIN_PORT,SCP_PORT,SSH_PORT,PORT,INPUT_PORT", EnvVars: []string{"PLUGIN_PORT", "SCP_PORT", "SSH_PORT", "PORT", "INPUT_PORT"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "username, u", Name: "username, u",
Usage: "Server username", Usage: "Server username",
EnvVar: "PLUGIN_USERNAME,PLUGIN_USER,SCP_USERNAME,SSH_USERNAME,USERNAME,INPUT_USERNAME", EnvVars: []string{"PLUGIN_USERNAME", "PLUGIN_USER", "SCP_USERNAME", "SSH_USERNAME", "USERNAME", "INPUT_USERNAME"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "password, p", Name: "password, p",
Usage: "Password for password-based authentication", Usage: "Password for password-based authentication",
EnvVar: "PLUGIN_PASSWORD,SCP_PASSWORD,SSH_PASSWORD,PASSWORD,INPUT_PASSWORD", EnvVars: []string{"PLUGIN_PASSWORD", "SCP_PASSWORD", "SSH_PASSWORD", "PASSWORD", "INPUT_PASSWORD"},
}, },
cli.DurationFlag{ &cli.DurationFlag{
Name: "timeout", Name: "timeout",
Usage: "connection timeout", Usage: "connection timeout",
EnvVar: "PLUGIN_TIMEOUT,SCP_TIMEOUT,INPUT_TIMEOUT", EnvVars: []string{"PLUGIN_TIMEOUT", "SCP_TIMEOUT", "INPUT_TIMEOUT"},
Value: 30 * time.Second,
}, },
cli.DurationFlag{ &cli.DurationFlag{
Name: "command.timeout,T", Name: "command.timeout",
Usage: "command timeout", Usage: "command timeout",
EnvVar: "PLUGIN_COMMAND_TIMEOUT,SSH_COMMAND_TIMEOUT,INPUT_COMMAND_TIMEOUT", EnvVars: []string{"PLUGIN_COMMAND_TIMEOUT", "SSH_COMMAND_TIMEOUT", "INPUT_COMMAND_TIMEOUT"},
Value: 60 * time.Second, Value: 10 * time.Minute,
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "key, k", Name: "ssh-key, k",
Usage: "ssh private key", Usage: "ssh private key",
EnvVar: "PLUGIN_KEY,SCP_KEY,SSH_KEY,KEY,INPUT_KEY", EnvVars: []string{"PLUGIN_SSH_KEY,", "PLUGIN_KEY", "SCP_KEY", "SSH_KEY", "KEY", "INPUT_KEY"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "key-path, i", Name: "ssh-passphrase",
Usage: "ssh private key path", Usage: "The purpose of the passphrase is usually to encrypt the private key.",
EnvVar: "PLUGIN_KEY_PATH,SCP_KEY_PATH,SSH_KEY_PATH,INPUT_KEY_PATH", EnvVars: []string{"PLUGIN_SSH_PASSPHRASE", "PLUGIN_PASSPHRASE", "SSH_PASSPHRASE", "PASSPHRASE", "INPUT_PASSPHRASE"},
}, },
cli.StringSliceFlag{ &cli.StringFlag{
Name: "target, t", Name: "key-path, i",
Usage: "Target path on the server", Usage: "ssh private key path",
EnvVar: "PLUGIN_TARGET,SCP_TARGET,TARGET,INPUT_TARGET", EnvVars: []string{"PLUGIN_KEY_PATH", "SCP_KEY_PATH", "SSH_KEY_PATH", "INPUT_KEY_PATH"},
}, },
cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: "source, s", Name: "target, t",
Usage: "scp file list", Usage: "Target path on the server",
EnvVar: "PLUGIN_SOURCE,SCP_SOURCE,SOURCE,INPUT_SOURCE", EnvVars: []string{"PLUGIN_TARGET", "SCP_TARGET", "TARGET", "INPUT_TARGET"},
}, },
cli.BoolFlag{ &cli.StringSliceFlag{
Name: "rm, r", Name: "source, s",
Usage: "remove target folder before upload data", Usage: "scp file list",
EnvVar: "PLUGIN_RM,SCP_RM,RM,INPUT_RM", EnvVars: []string{"PLUGIN_SOURCE", "SCP_SOURCE", "SOURCE", "INPUT_SOURCE"},
}, },
cli.StringFlag{ &cli.BoolFlag{
Name: "repo.owner", Name: "rm, r",
Usage: "repository owner", Usage: "remove target folder before upload data",
EnvVar: "DRONE_REPO_OWNER", EnvVars: []string{"PLUGIN_RM", "SCP_RM", "RM", "INPUT_RM"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "repo.name", Name: "repo.owner",
Usage: "repository name", Usage: "repository owner",
EnvVar: "DRONE_REPO_NAME", EnvVars: []string{"DRONE_REPO_OWNER"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "commit.sha", Name: "repo.name",
Usage: "git commit sha", Usage: "repository name",
EnvVar: "DRONE_COMMIT_SHA", EnvVars: []string{"DRONE_REPO_NAME"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "commit.branch", Name: "commit.sha",
Value: "master", Usage: "git commit sha",
Usage: "git commit branch", EnvVars: []string{"DRONE_COMMIT_SHA"},
EnvVar: "DRONE_COMMIT_BRANCH",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "commit.author", Name: "commit.branch",
Usage: "git author name", Value: "master",
EnvVar: "DRONE_COMMIT_AUTHOR", Usage: "git commit branch",
EnvVars: []string{"DRONE_COMMIT_BRANCH"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "commit.message", Name: "commit.author",
Usage: "commit message", Usage: "git author name",
EnvVar: "DRONE_COMMIT_MESSAGE", EnvVars: []string{"DRONE_COMMIT_AUTHOR"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "build.event", Name: "commit.message",
Value: "push", Usage: "commit message",
Usage: "build event", EnvVars: []string{"DRONE_COMMIT_MESSAGE"},
EnvVar: "DRONE_BUILD_EVENT",
}, },
cli.IntFlag{ &cli.StringFlag{
Name: "build.number", Name: "build.event",
Usage: "build number", Value: "push",
EnvVar: "DRONE_BUILD_NUMBER", Usage: "build event",
EnvVars: []string{"DRONE_BUILD_EVENT"},
}, },
cli.StringFlag{ &cli.IntFlag{
Name: "build.status", Name: "build.number",
Usage: "build status", Usage: "build number",
Value: "success", EnvVars: []string{"DRONE_BUILD_NUMBER"},
EnvVar: "DRONE_BUILD_STATUS",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "build.link", Name: "build.status",
Usage: "build link", Usage: "build status",
EnvVar: "DRONE_BUILD_LINK", Value: "success",
EnvVars: []string{"DRONE_BUILD_STATUS"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "build.link",
Usage: "build link",
EnvVars: []string{"DRONE_BUILD_LINK"},
},
&cli.StringFlag{
Name: "env-file", Name: "env-file",
Usage: "source env file", Usage: "source env file",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "proxy.ssh-key", Name: "proxy.ssh-key",
Usage: "private ssh key of proxy", Usage: "private ssh key of proxy",
EnvVar: "PLUGIN_PROXY_SSH_KEY,PLUGIN_PROXY_KEY,PROXY_SSH_KEY,PROXY_KEY,INPUT_PROXY_SSH_KEY", EnvVars: []string{"PLUGIN_PROXY_SSH_KEY", "PLUGIN_PROXY_KEY", "PROXY_SSH_KEY", "PROXY_KEY", "INPUT_PROXY_SSH_KEY"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "proxy.key-path", Name: "proxy.ssh-passphrase",
Usage: "ssh private key path of proxy", Usage: "The purpose of the passphrase is usually to encrypt the private key.",
EnvVar: "PLUGIN_PROXY_KEY_PATH,PROXY_SSH_KEY_PATH,INPUT_PROXY_SSH_KEY_PATH", EnvVars: []string{"PLUGIN_PROXY_SSH_PASSPHRASE", "PLUGIN_PROXY_PASSPHRASE", "PROXY_SSH_PASSPHRASE", "PROXY_PASSPHRASE", "INPUT_PROXY_PASSPHRASE"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "proxy.username", Name: "proxy.key-path",
Usage: "connect as user of proxy", Usage: "ssh private key path of proxy",
EnvVar: "PLUGIN_PROXY_USERNAME,PLUGIN_PROXY_USER,PROXY_SSH_USERNAME,PROXY_USERNAME,INPUT_PROXY_USERNAME", EnvVars: []string{"PLUGIN_PROXY_KEY_PATH", "PROXY_SSH_KEY_PATH", "INPUT_PROXY_SSH_KEY_PATH"},
Value: "root",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "proxy.password", Name: "proxy.username",
Usage: "user password of proxy", Usage: "connect as user of proxy",
EnvVar: "PLUGIN_PROXY_PASSWORD,PROXY_SSH_PASSWORD,PROXY_PASSWORD,INPUT_PROXY_PASSWORD", EnvVars: []string{"PLUGIN_PROXY_USERNAME", "PLUGIN_PROXY_USER", "PROXY_SSH_USERNAME", "PROXY_USERNAME", "INPUT_PROXY_USERNAME"},
Value: "root",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "proxy.host", Name: "proxy.password",
Usage: "connect to host of proxy", Usage: "user password of proxy",
EnvVar: "PLUGIN_PROXY_HOST,PROXY_SSH_HOST,PROXY_HOST,INPUT_PROXY_HOST", EnvVars: []string{"PLUGIN_PROXY_PASSWORD", "PROXY_SSH_PASSWORD", "PROXY_PASSWORD", "INPUT_PROXY_PASSWORD"},
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "proxy.port", Name: "proxy.host",
Usage: "connect to port of proxy", Usage: "connect to host of proxy",
EnvVar: "PLUGIN_PROXY_PORT,PROXY_SSH_PORT,PROXY_PORT,INPUT_PROXY_PORT", EnvVars: []string{"PLUGIN_PROXY_HOST", "PROXY_SSH_HOST", "PROXY_HOST", "INPUT_PROXY_HOST"},
Value: "22",
}, },
cli.DurationFlag{ &cli.StringFlag{
Name: "proxy.timeout", Name: "proxy.port",
Usage: "proxy connection timeout", Usage: "connect to port of proxy",
EnvVar: "PLUGIN_PROXY_TIMEOUT,PROXY_SSH_TIMEOUT,INPUT_PROXY_TIMEOUT", EnvVars: []string{"PLUGIN_PROXY_PORT", "PROXY_SSH_PORT", "PROXY_PORT", "INPUT_PROXY_PORT"},
Value: "22",
}, },
cli.IntFlag{ &cli.DurationFlag{
Name: "strip.components", Name: "proxy.timeout",
Usage: "Remove the specified number of leading path elements.", Usage: "proxy connection timeout",
EnvVar: "PLUGIN_STRIP_COMPONENTS,TAR_STRIP_COMPONENTS,INPUT_STRIP_COMPONENTS", EnvVars: []string{"PLUGIN_PROXY_TIMEOUT", "PROXY_SSH_TIMEOUT", "INPUT_PROXY_TIMEOUT"},
}, },
cli.StringFlag{ &cli.IntFlag{
Name: "tar.exec", Name: "strip.components",
Usage: "Alternative `tar` executable to on the dest host", Usage: "Remove the specified number of leading path elements.",
EnvVar: "PLUGIN_TAR_EXEC,SCP_TAR_EXEC,INPUT_TAR_EXEC", EnvVars: []string{"PLUGIN_STRIP_COMPONENTS", "TAR_STRIP_COMPONENTS", "INPUT_STRIP_COMPONENTS"},
Value: "tar",
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "tar.tmp-path", Name: "tar.exec",
Usage: "Temporary path for tar file on the dest host", Usage: "Alternative `tar` executable to on the dest host",
EnvVar: "PLUGIN_TAR_TMP_PATH,SCP_TAR_TMP_PATH", EnvVars: []string{"PLUGIN_TAR_EXEC", "SCP_TAR_EXEC", "INPUT_TAR_EXEC"},
Value: "tar",
}, },
cli.BoolFlag{ &cli.StringFlag{
Name: "debug", Name: "tar.tmp-path",
Usage: "remove target folder before upload data", Usage: "Temporary path for tar file on the dest host",
EnvVar: "PLUGIN_DEBUG,DEBUG,INPUT_DEBUG", EnvVars: []string{"PLUGIN_TAR_TMP_PATH", "SCP_TAR_TMP_PATH"},
}, },
cli.BoolFlag{ &cli.BoolFlag{
Name: "overwrite", Name: "debug",
Usage: "use --overwrite flag with tar", Usage: "remove target folder before upload data",
EnvVar: "PLUGIN_OVERWRITE,SCP_OVERWRITE,INPUT_OVERWRITE", EnvVars: []string{"PLUGIN_DEBUG", "DEBUG", "INPUT_DEBUG"},
},
&cli.BoolFlag{
Name: "overwrite",
Usage: "use --overwrite flag with tar",
EnvVars: []string{"PLUGIN_OVERWRITE", "SCP_OVERWRITE", "INPUT_OVERWRITE"},
}, },
} }
@@ -273,9 +284,10 @@ func run(c *cli.Context) error {
Port: c.String("port"), Port: c.String("port"),
Username: c.String("username"), Username: c.String("username"),
Password: c.String("password"), Password: c.String("password"),
Passphrase: c.String("ssh-passphrase"),
Timeout: c.Duration("timeout"), Timeout: c.Duration("timeout"),
CommandTimeout: c.Duration("command.timeout"), CommandTimeout: c.Duration("command.timeout"),
Key: c.String("key"), Key: c.String("ssh-key"),
KeyPath: c.String("key-path"), KeyPath: c.String("key-path"),
Target: c.StringSlice("target"), Target: c.StringSlice("target"),
Source: c.StringSlice("source"), Source: c.StringSlice("source"),
@@ -286,13 +298,14 @@ func run(c *cli.Context) error {
TarTmpPath: c.String("tar.tmp-path"), TarTmpPath: c.String("tar.tmp-path"),
Overwrite: c.Bool("overwrite"), Overwrite: c.Bool("overwrite"),
Proxy: easyssh.DefaultConfig{ Proxy: easyssh.DefaultConfig{
Key: c.String("proxy.ssh-key"), Key: c.String("proxy.ssh-key"),
KeyPath: c.String("proxy.key-path"), Passphrase: c.String("proxy.ssh-passphrase"),
User: c.String("proxy.username"), KeyPath: c.String("proxy.key-path"),
Password: c.String("proxy.password"), User: c.String("proxy.username"),
Server: c.String("proxy.host"), Password: c.String("proxy.password"),
Port: c.String("proxy.port"), Server: c.String("proxy.host"),
Timeout: c.Duration("proxy.timeout"), Port: c.String("proxy.port"),
Timeout: c.Duration("proxy.timeout"),
}, },
}, },
} }
+8 -8
View File
@@ -9,7 +9,7 @@
steps: [ steps: [
{ {
name: 'vet', name: 'vet',
image: 'golang:1.13', image: 'golang:1.14',
pull: 'always', pull: 'always',
commands: [ commands: [
'make vet', 'make vet',
@@ -23,7 +23,7 @@
}, },
{ {
name: 'lint', name: 'lint',
image: 'golang:1.13', image: 'golang:1.14',
pull: 'always', pull: 'always',
commands: [ commands: [
'make lint', 'make lint',
@@ -37,7 +37,7 @@
}, },
{ {
name: 'misspell', name: 'misspell',
image: 'golang:1.13', image: 'golang:1.14',
pull: 'always', pull: 'always',
commands: [ commands: [
'make misspell-check', 'make misspell-check',
@@ -51,7 +51,7 @@
}, },
{ {
name: 'test', name: 'test',
image: 'golang:1.13-alpine', image: 'golang:1.14-alpine',
pull: 'always', pull: 'always',
commands: [ commands: [
'apk add git make curl perl bash build-base zlib-dev ucl-dev', 'apk add git make curl perl bash build-base zlib-dev ucl-dev',
@@ -93,7 +93,7 @@
steps: [ steps: [
{ {
name: 'build-push', name: 'build-push',
image: 'golang:1.13', image: 'golang:1.14',
pull: 'always', pull: 'always',
environment: { environment: {
CGO_ENABLED: '0', CGO_ENABLED: '0',
@@ -109,7 +109,7 @@
}, },
{ {
name: 'build-tag', name: 'build-tag',
image: 'golang:1.13', image: 'golang:1.14',
pull: 'always', pull: 'always',
environment: { environment: {
CGO_ENABLED: '0', CGO_ENABLED: '0',
@@ -123,7 +123,7 @@
}, },
{ {
name: 'executable', name: 'executable',
image: 'golang:1.13', image: 'golang:1.14',
pull: 'always', pull: 'always',
commands: [ commands: [
'./release/' + os + '/' + arch + '/' + name + ' --help', './release/' + os + '/' + arch + '/' + name + ' --help',
@@ -188,7 +188,7 @@
steps: [ steps: [
{ {
name: 'build-all-binary', name: 'build-all-binary',
image: 'golang:1.13', image: 'golang:1.14',
pull: 'always', pull: 'always',
commands: [ commands: [
'make release' 'make release'
+36 -31
View File
@@ -50,6 +50,7 @@ type (
Username string Username string
Password string Password string
Key string Key string
Passphrase string
KeyPath string KeyPath string
Timeout time.Duration Timeout time.Duration
CommandTimeout time.Duration CommandTimeout time.Duration
@@ -164,21 +165,23 @@ func (p *Plugin) removeDestFile(ssh *easyssh.MakeConfig) error {
func (p *Plugin) removeAllDestFile() error { func (p *Plugin) removeAllDestFile() error {
for _, host := range p.Config.Host { for _, host := range p.Config.Host {
ssh := &easyssh.MakeConfig{ ssh := &easyssh.MakeConfig{
Server: host, Server: host,
User: p.Config.Username, User: p.Config.Username,
Password: p.Config.Password, Password: p.Config.Password,
Port: p.Config.Port, Port: p.Config.Port,
Key: p.Config.Key, Key: p.Config.Key,
KeyPath: p.Config.KeyPath, KeyPath: p.Config.KeyPath,
Timeout: p.Config.Timeout, Passphrase: p.Config.Passphrase,
Timeout: p.Config.Timeout,
Proxy: easyssh.DefaultConfig{ Proxy: easyssh.DefaultConfig{
Server: p.Config.Proxy.Server, Server: p.Config.Proxy.Server,
User: p.Config.Proxy.User, User: p.Config.Proxy.User,
Password: p.Config.Proxy.Password, Password: p.Config.Proxy.Password,
Port: p.Config.Proxy.Port, Port: p.Config.Proxy.Port,
Key: p.Config.Proxy.Key, Key: p.Config.Proxy.Key,
KeyPath: p.Config.Proxy.KeyPath, KeyPath: p.Config.Proxy.KeyPath,
Timeout: p.Config.Proxy.Timeout, Passphrase: p.Config.Proxy.Passphrase,
Timeout: p.Config.Proxy.Timeout,
}, },
} }
@@ -272,21 +275,23 @@ func (p *Plugin) Exec() error {
go func(host string) { go func(host string) {
// Create MakeConfig instance with remote username, server address and path to private key. // Create MakeConfig instance with remote username, server address and path to private key.
ssh := &easyssh.MakeConfig{ ssh := &easyssh.MakeConfig{
Server: host, Server: host,
User: p.Config.Username, User: p.Config.Username,
Password: p.Config.Password, Password: p.Config.Password,
Port: p.Config.Port, Port: p.Config.Port,
Key: p.Config.Key, Key: p.Config.Key,
KeyPath: p.Config.KeyPath, KeyPath: p.Config.KeyPath,
Timeout: p.Config.Timeout, Passphrase: p.Config.Passphrase,
Timeout: p.Config.Timeout,
Proxy: easyssh.DefaultConfig{ Proxy: easyssh.DefaultConfig{
Server: p.Config.Proxy.Server, Server: p.Config.Proxy.Server,
User: p.Config.Proxy.User, User: p.Config.Proxy.User,
Password: p.Config.Proxy.Password, Password: p.Config.Proxy.Password,
Port: p.Config.Proxy.Port, Port: p.Config.Proxy.Port,
Key: p.Config.Proxy.Key, Key: p.Config.Proxy.Key,
KeyPath: p.Config.Proxy.KeyPath, KeyPath: p.Config.Proxy.KeyPath,
Timeout: p.Config.Proxy.Timeout, Passphrase: p.Config.Proxy.Passphrase,
Timeout: p.Config.Proxy.Timeout,
}, },
} }
@@ -381,9 +386,9 @@ func (p *Plugin) Exec() error {
} }
} }
fmt.Println("================================================") fmt.Println("===================================================")
fmt.Println("Successfully executed transfer data to all host.") fmt.Println("Successfully executed transfer data to all host")
fmt.Println("================================================") fmt.Println("===================================================")
return nil return nil
} }
+40 -1
View File
@@ -130,6 +130,45 @@ func TestSCPFileFromPublicKey(t *testing.T) {
} }
} }
func TestSCPFileFromPublicKeyWithPassphrase(t *testing.T) {
if os.Getenv("SSH_AUTH_SOCK") != "" {
if err := exec.Command("eval", "`ssh-agent -k`").Run(); err != nil {
t.Fatalf("exec: %v", err)
}
}
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/test",
Passphrase: "1234",
Source: []string{"tests/a.txt", "tests/b.txt"},
Target: []string{filepath.Join(u.HomeDir, "/test2")},
CommandTimeout: 60 * time.Second,
TarExec: "tar",
},
}
err = plugin.Exec()
assert.Nil(t, err)
// check file exist
if _, err := os.Stat(filepath.Join(u.HomeDir, "/test2/tests/a.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
if _, err := os.Stat(filepath.Join(u.HomeDir, "/test2/tests/b.txt")); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
}
func TestSCPWildcardFileList(t *testing.T) { func TestSCPWildcardFileList(t *testing.T) {
if os.Getenv("SSH_AUTH_SOCK") != "" { if os.Getenv("SSH_AUTH_SOCK") != "" {
if err := exec.Command("eval", "`ssh-agent -k`").Run(); err != nil { if err := exec.Command("eval", "`ssh-agent -k`").Run(); err != nil {
@@ -389,7 +428,7 @@ func TestGlobList(t *testing.T) {
assert.Equal(t, expects, globList(paterns).Source) assert.Equal(t, expects, globList(paterns).Source)
paterns = []string{"tests/*.txt", "tests/.ssh/*", "abc*"} paterns = []string{"tests/*.txt", "tests/.ssh/*", "abc*"}
expects = []string{"tests/a.txt", "tests/b.txt", "tests/.ssh/id_rsa", "tests/.ssh/id_rsa.pub"} expects = []string{"tests/a.txt", "tests/b.txt", "tests/.ssh/id_rsa", "tests/.ssh/id_rsa.pub", "tests/.ssh/test", "tests/.ssh/test.pub"}
assert.Equal(t, expects, globList(paterns).Source) assert.Equal(t, expects, globList(paterns).Source)
paterns = []string{"tests/?.txt"} paterns = []string{"tests/?.txt"}
+50
View File
@@ -0,0 +1,50 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABAZka7A7i
FscMeJBPyPteclAAAAEAAAAAEAAAIXAAAAB3NzaC1yc2EAAAADAQABAAACAQDz6aZ1jY2o
nnuj2YNHJ/HhfvIu0B973v/+pFFOavnTUOhEEKEy3TASu+s9CkHrYZAtRc+QYIkNZI31mh
HBhotdeP/7GoO2UirkFtrzyQKPNJxEcv0RBoG9ssN8jex0PyK6DHIYYFnIWadVBEEOh/H+
rK7j7u2/big3oTzYBuFrCwmYFcz5na99MzFeAUhazF44gVBma+zO+1quGeqF51UDIg1SMG
vX8I7LNEqrKEBaIUQJKFQcxlOWlRLQsjJCymrOujsXsRrXHAQWcnxDcNevv2ZMOUl0ybvv
9yH0BiGbRBd1Hy8/QPILbAQaqu0oQE7fubN8Q8lqb3Jg0loID4x/5GPhSY8WAXpuLcXTOr
b93SnCw1JsAgJDNqpuuRFy3BSZ7wBOr1jfeIoo7xk14OHiUjJ0uXDL9cLMkcw6ElWz81mr
D2VCkXUz+qFyjJ+G7aGWRtctZoOzKln4yfNfUmwW8/8ra3QnmrMZ2xW2Ylw3ZhO+tLi7jI
NHYFb54bAdLVPUU1ctIuJns2qkWnjJCxxMiynIqCif20/OU1n8CTJuOWiURmRdmvKOH4PE
3JxC2Qnk/3tV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