ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - appleboy/drone-scp: Copy files and artifacts via SSH using a binary, docker or Drone CI.
Copy files and artifacts via SSH using a binary, docker or Drone CI. - appleboy/drone-scp
Visit Site

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

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

drone-scp

繁體中文 | 简体中文

GoDoc Lint and Testing codecov Go Report Card Docker Pulls

Copy files and artifacts via SSH using a binary, docker or Drone CI.

Feature

  • Support routines.
  • Support wildcard pattern on source list.
  • Support send files to multiple host.
  • Support send files to multiple target folder on host.
  • Support load ssh key from absolute path or raw body.
  • Support SSH ProxyCommand.
+--------+       +----------+      +-----------+
| 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:

  - name: scp files
    image: appleboy/drone-scp
    settings:
      host:
        - example1.com
        - example2.com
      username: ubuntu
      password:
        from_secret: ssh_password
      port: 22
-     command_timeout: 120
+     command_timeout: 2m
      target: /home/deploy/web
      source:
        - release/*.tar.gz

Build or Download a binary

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

  • Windows amd64/386
  • Linux arm/amd64/386
  • Darwin amd64/386

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:

make docker

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 \
+ --password xxxxxxx \
  --target /home/appleboy/test \
  --source your_local_folder_path

Using ssh-agent

Start your local ssh agent:

eval `ssh-agent -s`

Import your local public key ~/.ssh/id_rsa

ssh-add

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 \
+ --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

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) \
  -w $(pwd) \
  appleboy/drone-scp

Using password

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:

eval `ssh-agent -s`

Import your local public key ~/.ssh/id_rsa

ssh-add

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

make test

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory