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
260
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.3k
CLIでOAuth/OIDCを快適に利用する
int128
0
800
AppEngine × Spring Boot × Kotlin
int128
0
94
いつものJIRA設定
int128
1
170
Swaggerのテンプレートを魔改造した話 / Customize Swagger Templates
int128
1
4.7k
本番環境のリリースを自動化した話
int128
0
720
Swagger × Spring Cloud
int128
0
86
Other Decks in Technology
See All in Technology
コンピュータビジョンの社会実装について考えていたらゲームを作っていた話
takmin
1
410
ユーザーストーリーマッピングから始めるアジャイルチームと並走するQA / Starting QA with User Story Mapping
katawara
0
230
OpenID Connect for Identity Assurance の概要と翻訳版のご紹介 / 20250219-BizDay17-OIDC4IDA-Intro
oidfj
0
300
Moved to https://speakerdeck.com/toshihue/presales-engineer-career-bridging-tech-biz-ja
toshihue
2
810
PHPカンファレンス名古屋-テックリードの経験から学んだ設計の教訓
hayatokudou
2
480
クラウドサービス事業者におけるOSS
tagomoris
3
940
NFV基盤のOpenStack更新 ~9世代バージョンアップへの挑戦~
vtj
0
120
Amazon S3 Tablesと外部分析基盤連携について / Amazon S3 Tables and External Data Analytics Platform
nttcom
0
140
AIエージェント元年
shukob
0
100
2/18/25: Java meets AI: Build LLM-Powered Apps with LangChain4j
edeandrea
PRO
0
140
依存パッケージの更新はコツコツが勝つコツ! / phpcon_nagoya2025
blue_goheimochi
3
170
(機械学習システムでも) SLO から始める信頼性構築 - ゆる SRE#9 2025/02/21
daigo0927
0
190
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
328
38k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
410
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
Designing Experiences People Love
moore
140
23k
It's Worth the Effort
3n
184
28k
Embracing the Ebb and Flow
colly
84
4.6k
RailsConf 2023
tenderlove
29
1k
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接続してテストを実行