Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Gradle SSH Plugin
Search
Hidetake Iwata
June 20, 2014
Technology
0
270
Gradle SSH Plugin
わいわいGroovy ~ 教えてG*小ネタ大会!
https://jggug.doorkeeper.jp/events/11365
Hidetake Iwata
June 20, 2014
Tweet
Share
More Decks by Hidetake Iwata
See All by Hidetake Iwata
Rewrite Go error handling using AST transformation
int128
1
1.3k
Cluster AutoscalerをTerraformとHelmfileでデプロイしてPrometheusでモニタリングする / Deploy the Cluster Autoscaler with Terraform and Helmfile, Monitor with Prometheus
int128
3
1.7k
認証の仕組みとclient-go credential plugin / authentication and client-go credential plugin
int128
7
7.4k
CLIでOAuth/OIDCを快適に利用する
int128
0
840
AppEngine × Spring Boot × Kotlin
int128
0
100
いつものJIRA設定
int128
1
180
Swaggerのテンプレートを魔改造した話 / Customize Swagger Templates
int128
1
4.8k
本番環境のリリースを自動化した話
int128
0
740
Swagger × Spring Cloud
int128
0
92
Other Decks in Technology
See All in Technology
От ручной разметки к LLM: как мы создавали облако тегов в Lamoda. Анастасия Ангелова, Data Scientist, Lamoda Tech
lamodatech
0
690
Amazon CloudWatch Application Signals ではじめるバーンレートアラーム / Burn rate alarm with Amazon CloudWatch Application Signals
ymotongpoo
5
390
自分の軸足を見つけろ
tsuemura
2
680
Dynamic Reteaming And Self Organization
miholovesq
2
120
Ops-JAWS_Organizations小ネタ3選.pdf
chunkof
2
140
Micro Frontends: Necessity, Implementation, and Challenges
rainerhahnekamp
2
470
Automatically generating types by running tests
sinsoku
2
1.9k
古き良き Laravel のシステムは関数型スタイルでリファクタできるのか
leveragestech
1
670
AI AgentOps LT大会(2025/04/16) Algomatic伊藤発表資料
kosukeito
0
130
AWSで作るセキュアな認証基盤with OAuth mTLS / Secure Authentication Infrastructure with OAuth mTLS on AWS
kaminashi
0
100
Creating Awesome Change in SmartNews
martin_lover
1
270
AI Agentを「期待通り」に動かすために:設計アプローチの模索と現在地
kworkdev
PRO
2
430
Featured
See All Featured
Code Review Best Practice
trishagee
67
18k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
The Language of Interfaces
destraynor
157
24k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
660
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.8k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
How STYLIGHT went responsive
nonsquared
99
5.5k
Typedesign – Prime Four
hannesfritz
41
2.6k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
30k
A Tale of Four Properties
chriscoyier
158
23k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Transcript
Gradle SSH Plugin @int128 #jggug
はじめに 5分ぐらいで Gradle SSH Pluginを紹介します。 http://gradle-ssh-plugin.github.io @int128 Groovy and Scala
Programmer Certified ScrumMaster
どうやって デプロイしてますか?
どうやってデプロイしてますか? アプリをサーバにデプロイする方法 ➔ 手順書 ➔ シェルスクリプト ➔ Capistrano ➔ Maven
➔ Ant ➔ Gradle
Gradleからデプロイできると 便利ですよね
Gradleからデプロイするメリット 使い慣れたツールでビルドからデプロイまでをシー ムレスに記述できます ビルドやデプロイの設定を一元管理することでメン テナンスの無駄がなくなります JavaVMさえ入っていればすぐにデプロイできます (Gradle Wrapperのおかげ)
Gradle SSH Pluginとは GradleでSSHを使うためのプラグイン ➔ Gradleとの統合 ➔ コマンド実行やファイル転送 ➔ 標準入出力とのインタラクション
➔ パスワード、公開鍵、ssh-agentによる認証 ➔ 踏み台サーバやプロキシを経由した接続
使用例1: アプリのデプロイ Gradleでビルドした成果物 (JARやWAR) をサー バに配置する例 1. ビルドしてWARファイルを生成 2. WebサーバにWARファイルを配置
3. プロセスを再起動
apply plugin: 'war' apply plugin: 'ssh' remotes { webServer {
host = '192.168.1.101' user = 'jenkins' } } task deploy(type: SshTask, dependsOn: war) { session(remotes.webServer) { put war.archivePath, '/webapps' execute 'sudo service tomcat restart' } } Webサーバを定義 WebサーバにWARをデプロイ WARファイルを配置し、Tomcatサービスを再起動 プラグインを適用 warタスクの後にdeployタスクを実行
例2: SSHオペレーションの自動化 ネットワーク機器 (Cisco Catalyst) から設定を取 得してファイルに保存する例 1. ネットワーク機器にSSHで接続 2.
特権モードに移行 3. パスワードを入力 4. 現在の設定を取得 5. 終了
task backupConfig(type: SshTask) { session(remotes.switch01) { file('config.txt').withWriter { writer ->
shell { interaction { when(partial: ~/.*>/) { standardInput << 'terminal length 0\n' standardInput << 'enable\n' when(partial: /Password: /) { standardInput << enablePassword << '\n' when(partial: ~/.*#/) { standardInput << 'show run\n' when(partial: ~/.*[#>]/) { standardInput << 'exit\n' } when(line: _) { line -> writer << line << '\n' } } } パスワードを入力 プロンプトが出現したらコマンドを入力 show runコマンドを入力 プロンプトが出現したらexitコマンドを入力 プロンプト以外の標準出力をファイルに保存 ネットワーク機器の設定を取得
まとめ Gradle SSH Pluginを使用することで、 使い慣れたGradleでビルドからデプロイまでを シームレスに実現できます デプロイだけでなく、SSHオペレーションの 自動化全般に使用できます
おまけ:アーキテクチャ プロダクト ➔ Groovy 1.8(Gradle 1.xに同梱) ➔ JSch テスト ➔
Spock ➔ Apache MINA SSHD server 受け入れテスト ➔ Travis CI ◆ localhostにSSH接続してテストを実行