Skip to content

steklopod/gradle-ssh-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ก SSH - gradle plugin for easy deployment

Backend CI Build Status

Copy from local to remote server.

Deliver your distribution to remoter server.

  • From zero-config to full customization.

๐ŸŽฏ Quick start

In root project build.gradle.kts file:

plugins {
    id("online.colaba.ssh") version "1.9.6"
}
group = "online.colaba"

That's all!

This task will copy folders & files from local machine to remote host ~/${project.name}/... folder

You can set host, or it will be computed from project.group (example above)

tasks {
    scp { 
        host = "my-domain.com"
    }
}

Run task:

gradle scp

๐Ÿ”ฎ Customization:

  1. Register new task in your build.gradle.kts:
register("customSshTask", Ssh::class) {
   host = "my-domain.com"
   user = "root"
   gradle = true
   frontend = false
   docker = true
   nginx = true
   directory = "distribution"
   run = "cd ${project.name} && echo \$PWD"
}
  1. Run this task:
gradle customSshTask

โ˜๏ธ id_rsa private key:

There must be id_rsa private key in root of your project.

  • To generate it on local machine (password will be requested) and put it to remote server:
cd .ssh
ssh-keygen -m PEM -t rsa -b 2048
ssh-add id_rsa
ssh-copy-id -i id_rsa.pub root@my-server.com

๐ŸŒ€ Available gradle tasks from ssh plugin:

By default you have preconfigured tasks:

  • ssh - all options are disabled by default (false)
  • scp - all options are enabled by default (true)
  • ssh-gradle - copy gradle needed files to remote server in every subproject
  • ssh-docker - copy docker files to remote server
  • ssh-jars - copy ${subproject}/nuild/libs/___.jar file to remote server in every subproject
  • and others: ssh-ngix, ssh-briker, ssh-elasticsearch, ssh-docker...

Run gradle tasks to see the full list in groups ssh, docker-main-${project.name}.

Example of tasks, which will be available for your project:

  • There will be as many tasks as gradle subprojects.
  1. ssh-backend - copy backend distribution *.jar-file to remote server
  2. ssh-frontend - copy frontend folder to remote server
  3. ssh-nginx - copy nginx folder to remote server
  4. ...

Name of service for all tasks equals to ${project.name}


๐Ÿ”ฎ Customization

You can customize these properties:

ssh {
   host = "hostexample.com"
   directory = "copy_me_to_remote"
   nginx = true
}

๐Ÿ“‹ Project's structure example

  • There could be as many backends as you need.
 project
   |-[backend]
              | - [src/main/java/build/libs]/*.jar
              | - Dockerfile
              | - Dockerfile.dev
              | - docker-compose.yml
              | - docker-compose.dev.yml
              | - ...
   |-[backend-2]
              | - [src/main/koltin/build/libs]/*.jar
              | - ...
   |-[backend-3]
              | - [src/main/scala/build/libs]/*.jar
              | - ...
   |-[frontend]
              | - docker-compose.yml
              | - ...
   |-[nginx]
              | - ...
   |-[postgres]
              | - [backups]
              | - ...
   |-[elastic]
              | - ...
   |-[static]
              | - ...
   |-[gradle]
              | - [wrapper]
   |- gradlew
   |- gradlew.bat
   |- docker-compose.yml
   |- ...

๐Ÿ”ซ Bonus tasks:

With ssh plugin you have additional bonus task to help you with deploying applications with docker:

  • compose - docker compose up all docker-services(gradle subprojects) with recreate and rebuild;
  • compose-nginx, compose-backend, compose-frontend... - docker compose up subproject;
  • prune - remove unused docker data;
  • cmd - execute a command line process [linux/windows].
tasks{
      cmd { command = "echo ${project.name} ๐Ÿง’" }
}

About

๐Ÿ›ก๏ธ SSH & FTP ssh plugin for deployment to remote server.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages