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
340
0
Share
Gradle SSH Plugin
わいわいGroovy ~ 教えてG*小ネタ大会!
https://jggug.doorkeeper.jp/events/11365
Hidetake Iwata
June 20, 2014
More Decks by Hidetake Iwata
See All by Hidetake Iwata
Rewrite Go error handling using AST transformation
int128
1
1.4k
Cluster AutoscalerをTerraformとHelmfileでデプロイしてPrometheusでモニタリングする / Deploy the Cluster Autoscaler with Terraform and Helmfile, Monitor with Prometheus
int128
3
1.8k
認証の仕組みとclient-go credential plugin / authentication and client-go credential plugin
int128
7
7.8k
CLIでOAuth/OIDCを快適に利用する
int128
0
990
AppEngine × Spring Boot × Kotlin
int128
0
160
いつものJIRA設定
int128
1
230
Swaggerのテンプレートを魔改造した話 / Customize Swagger Templates
int128
1
5k
本番環境のリリースを自動化した話
int128
0
840
Swagger × Spring Cloud
int128
0
130
Other Decks in Technology
See All in Technology
AI時代のガードレールとしてのAPIガバナンス
nagix
0
300
スクラムの中で AI-DLC workflow を 使い始めて3ヶ月の振り返り
kaminashi
0
100
明日からドヤれる!超マニアックなAWSセキュリティTips10連発 / 10 Ultra-Niche AWS Security Tips
yuj1osm
0
610
今年注目する!データ分析プラットフォームでのAIの活用
nayuts
0
140
Do Ruby::Box dream of Modular Monolith?
joker1007
1
350
Do Vibe Coding ao LLM em Produção para Busca Agêntica - TDC 2026 - Summit IA - São Paulo
jpbonson
3
140
20年前の「OSS革命」に学ぶ AI時代の生存戦略
samakada
0
460
Azure Static Web Apps の自動ビルドがタイムアウトしやすくなった状況に対応した件/global-azure2026
thara0402
0
420
「誰一人取り残されない」 AIエージェント時代のプロダクト設計思想 Product Management Summit 2026
mizushimac
1
660
PicoRuby as a Multi-VM Operating System
kishima
1
180
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
2.4k
AI時代における技術的負債への取り組み
codenote
1
1.7k
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.2k
Chasing Engaging Ingredients in Design
codingconduct
0
170
The SEO identity crisis: Don't let AI make you average
varn
0
450
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
Claude Code のすすめ
schroneko
67
220k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
Raft: Consensus for Rubyists
vanstee
141
7.4k
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接続してテストを実行