柴田 博志
SHIBATA Hiroshi
paperboy&co.
asakusa.rb
paperboy&co., Inc.
How to develop Jenkins plugin using to ruby and
Jenkins.r...
Jenkins User
Conference Tokyo
開催おめでとうございます。
スポンサーのご紹介
自己紹介
SHIBATA Hiroshi
http://twitter.com/hsbt/
http://www.hsbt.org/
http://github.com/hsbt/
会社紹介```
仕事内容
技術基盤
整備
エンジニア
会社紹介
終わり
豊富なプラグイン
自分でもプ
ラグインな
ら作れそう
な気がする
Java...
jenkins.rb
1. java-runtime
4. ruby-tools/jpi
3. ruby-tools/cli
2. ruby-runtime
java-runtime
ruby-runtime
Jenkins に JRuby を
組み込む
Jenkins の Java クラス
を JRuby でラッパーする
ruby-tools/cli
ruby-tools/jpi
jenkins を操作する奴
今日はなすこと
jpi.rb
rbenv install jruby-1.6.7.2
rbenv shell jruby-1.6.7.2
gem install jpi
Commands:
jpi help [COMMAND]
jpi new NAME
jpi generate [options] [arguments]
jpi build
jpi server
jpi release
jpi version
jpi
help
jpi
version
省略
jpi
new
% jpi new rbenv
create rbenv/Gemfile
create rbenv/jenkins-
rbenv.pluginspec
source :rubygems
gem "jenkins-plugin-runtime", " >
0.2.0"
Gemfile
Jenkins::Plugin::Specification.new do ¦plugin¦
plugin.name = "jenkins-rbenv"
plugin.display_name = "Jenkins Rbenv Plugin"
p...
Jenkins::Plugin::Specification.new do ¦plugin¦
plugin.name = "jenkins-rbenv"
plugin.display_name = "Jenkins Rbenv Plugin"
p...
Jenkins::Plugin::Specification.new do ¦plugin¦
plugin.name = "jenkins-rbenv"
plugin.display_name = "Jenkins Rbenv Plugin"
p...
Jenkins::Plugin::Specification.new do ¦plugin¦
plugin.name = "jenkins-rbenv"
plugin.display_name = "Jenkins Rbenv Plugin"
p...
Jenkins::Plugin::Specification.new do ¦plugin¦
plugin.name = "jenkins-rbenv"
plugin.display_name = "Jenkins Rbenv Plugin"
p...
Jenkins::Plugin::Specification.new do ¦plugin¦
plugin.name = "jenkins-rbenv"
plugin.display_name = "Jenkins Rbenv Plugin"
p...
Jenkins::Plugin::Specification.new do ¦plugin¦
plugin.name = "jenkins-rbenv"
plugin.display_name = "Jenkins Rbenv Plugin"
p...
Jenkins::Plugin::Specification.new do ¦plugin¦
plugin.name = "jenkins-rbenv"
plugin.display_name = "Jenkins Rbenv Plugin"
p...
Jenkins::Plugin::Specification.new do ¦plugin¦
plugin.name = "jenkins-rbenv"
plugin.display_name = "Jenkins Rbenv Plugin"
p...
jpi
generate
Available Generators:
publisher
builder
wrapper
node_property
run_listener
computer_listener
1. publisher
3. wrapper
2. builder
ビルド後に何かやる
ビルドとして何かやる
ビルド前後に処理を挟む
4. node_property
6. computer_listener
5. run_listener
jenkins の node 設定
ビルドの完了を受け取っ
て何かやる
ステータスが変わった時
に何かやる
wrapper
を作ってみよう
% cd rbenv
% jpi generate wrapper
rbenv
create models/
rbenv_wrapper.rb
class RbenvWrapper <
Jenkins::Tasks::BuildWrapper
display_name "Rbenv build wrapper"
def initialize(attrs = {})
end
def se...
class RbenvWrapper <
Jenkins::Tasks::BuildWrapper
display_name "Rbenv build wrapper"
def initialize(attrs = {})
end
def se...
class RbenvWrapper <
Jenkins::Tasks::BuildWrapper
display_name "Rbenv build wrapper"
def initialize(attrs = {})
end
def se...
class RbenvWrapper <
Jenkins::Tasks::BuildWrapper
display_name "Rbenv build wrapper"
def initialize(attrs = {})
end
def se...
設定画面を
使いたい
mkdir -p views/rbenv_wrapper
touch views/rbenv_wrapper/
config.erb
<%
f = taglib("/lib/form")
f.entry(:title => 'Version', :field =>
'version', :description => "RUBY, such as '1.9.3-
p194'")...
jelly taglib
class RbenvWrapper <
Jenkins::Tasks::BuildWrapper
display_name "Rbenv build wrapper"
def initialize(attrs = {})
end
def se...
attr_accessor :version
def initialize(attrs = {})
@version =
attrs['version']
end
rbenv_wrapper.rb
class RbenvWrapper <
Jenkins::Tasks::BuildWrapper
display_name "Rbenv build wrapper"
def initialize(attrs = {})
end
def se...
install_path = " /.rbenv/versions/#{@version}"
begin
unless FileTest.directory?
File.expand_path(" /.rbenv")
listener << "...
install_path = " /.rbenv/versions/#{@version}"
begin
unless FileTest.directory?
File.expand_path(" /.rbenv")
listener << "...
install_path = " /.rbenv/versions/#{@version}"
begin
unless FileTest.directory?
File.expand_path(" /.rbenv")
listener << "...
install_path = " /.rbenv/versions/#{@version}"
begin
unless FileTest.directory?
File.expand_path(" /.rbenv")
listener << "...
jpi
build
1. pluginspec から
pom.xml を生成
2. hpi ファイルを生
成
jpi
server
plugin を
読み込んだ
Jenkins
を起動する
手動テスト
jpi
release
1. jenkins-ci.org にアッ
プロードする
3. 引数無しは snapshot,
--release を付けると
production
2. /.jenkins-ci.org の
アカウント情報を使用
その他
test-unit
or
rspec
テスト
使えないので
Java ライブラリ
で頑張る
rubygems
etc
https://github.com/jenkinsci/rvm-plugin
https://github.com/hsbt/jenkins-rbenv-plugin
https://github.com/takai/jenkins-...
Write your plugin
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rb
Upcoming SlideShare
Loading in …5
×

How to develop Jenkins plugin using to ruby and Jenkins.rb

834 views

Published on

Published in: Technology, Art & Photos
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
834
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

How to develop Jenkins plugin using to ruby and Jenkins.rb

  1. 1. 柴田 博志 SHIBATA Hiroshi paperboy&co. asakusa.rb paperboy&co., Inc. How to develop Jenkins plugin using to ruby and Jenkins.rb 発表場所 Jenkins User Conference 2012-07-29(Sun) jenkins.rb で始める Ruby で Jenkins プラグイン作成
  2. 2. Jenkins User Conference Tokyo 開催おめでとうございます。
  3. 3. スポンサーのご紹介
  4. 4. 自己紹介
  5. 5. SHIBATA Hiroshi
  6. 6. http://twitter.com/hsbt/ http://www.hsbt.org/ http://github.com/hsbt/
  7. 7. 会社紹介```
  8. 8. 仕事内容
  9. 9. 技術基盤 整備 エンジニア
  10. 10. 会社紹介 終わり
  11. 11. 豊富なプラグイン
  12. 12. 自分でもプ ラグインな ら作れそう な気がする
  13. 13. Java...
  14. 14. jenkins.rb
  15. 15. 1. java-runtime 4. ruby-tools/jpi 3. ruby-tools/cli 2. ruby-runtime
  16. 16. java-runtime ruby-runtime Jenkins に JRuby を 組み込む Jenkins の Java クラス を JRuby でラッパーする
  17. 17. ruby-tools/cli ruby-tools/jpi jenkins を操作する奴 今日はなすこと
  18. 18. jpi.rb
  19. 19. rbenv install jruby-1.6.7.2 rbenv shell jruby-1.6.7.2 gem install jpi
  20. 20. Commands: jpi help [COMMAND] jpi new NAME jpi generate [options] [arguments] jpi build jpi server jpi release jpi version
  21. 21. jpi help jpi version
  22. 22. 省略
  23. 23. jpi new
  24. 24. % jpi new rbenv create rbenv/Gemfile create rbenv/jenkins- rbenv.pluginspec
  25. 25. source :rubygems gem "jenkins-plugin-runtime", " > 0.2.0" Gemfile
  26. 26. Jenkins::Plugin::Specification.new do ¦plugin¦ plugin.name = "jenkins-rbenv" plugin.display_name = "Jenkins Rbenv Plugin" plugin.version = '0.0.1' plugin.description = 'TODO: enter description here' plugin.url = 'https://wiki.jenkins-ci.org/ display/JENKINS/Jenkins+Rbenv+Plugin' plugin.developed_by "shibata.hiroshi", "SHIBATA Hiroshi <shibata.hiroshi@gmail.com>" plugin.uses_repository :github => "jenkins- rbenv-plugin" plugin.depends_on 'ruby-runtime', '0.10' end jenkins-rbenv.pluginspec
  27. 27. Jenkins::Plugin::Specification.new do ¦plugin¦ plugin.name = "jenkins-rbenv" plugin.display_name = "Jenkins Rbenv Plugin" plugin.version = '0.0.1' plugin.description = 'TODO: enter description here' plugin.url = 'https://wiki.jenkins-ci.org/ display/JENKINS/Jenkins+Rbenv+Plugin' plugin.developed_by "shibata.hiroshi", "SHIBATA Hiroshi <shibata.hiroshi@gmail.com>" plugin.uses_repository :github => "jenkins- rbenv-plugin" plugin.depends_on 'ruby-runtime', '0.10' end jenkins-rbenv.pluginspec
  28. 28. Jenkins::Plugin::Specification.new do ¦plugin¦ plugin.name = "jenkins-rbenv" plugin.display_name = "Jenkins Rbenv Plugin" plugin.version = '0.0.1' plugin.description = 'TODO: enter description here' plugin.url = 'https://wiki.jenkins-ci.org/ display/JENKINS/Jenkins+Rbenv+Plugin' plugin.developed_by "shibata.hiroshi", "SHIBATA Hiroshi <shibata.hiroshi@gmail.com>" plugin.uses_repository :github => "jenkins- rbenv-plugin" plugin.depends_on 'ruby-runtime', '0.10' end jenkins-rbenv.pluginspec
  29. 29. Jenkins::Plugin::Specification.new do ¦plugin¦ plugin.name = "jenkins-rbenv" plugin.display_name = "Jenkins Rbenv Plugin" plugin.version = '0.0.1' plugin.description = 'TODO: enter description here' plugin.url = 'https://wiki.jenkins-ci.org/ display/JENKINS/Jenkins+Rbenv+Plugin' plugin.developed_by "shibata.hiroshi", "SHIBATA Hiroshi <shibata.hiroshi@gmail.com>" plugin.uses_repository :github => "jenkins- rbenv-plugin" plugin.depends_on 'ruby-runtime', '0.10' end jenkins-rbenv.pluginspec
  30. 30. Jenkins::Plugin::Specification.new do ¦plugin¦ plugin.name = "jenkins-rbenv" plugin.display_name = "Jenkins Rbenv Plugin" plugin.version = '0.0.1' plugin.description = 'TODO: enter description here' plugin.url = 'https://wiki.jenkins-ci.org/ display/JENKINS/Jenkins+Rbenv+Plugin' plugin.developed_by "shibata.hiroshi", "SHIBATA Hiroshi <shibata.hiroshi@gmail.com>" plugin.uses_repository :github => "jenkins- rbenv-plugin" plugin.depends_on 'ruby-runtime', '0.10' end jenkins-rbenv.pluginspec
  31. 31. Jenkins::Plugin::Specification.new do ¦plugin¦ plugin.name = "jenkins-rbenv" plugin.display_name = "Jenkins Rbenv Plugin" plugin.version = '0.0.1' plugin.description = 'TODO: enter description here' plugin.url = 'https://wiki.jenkins-ci.org/ display/JENKINS/Jenkins+Rbenv+Plugin' plugin.developed_by "shibata.hiroshi", "SHIBATA Hiroshi <shibata.hiroshi@gmail.com>" plugin.uses_repository :github => "jenkins- rbenv-plugin" plugin.depends_on 'ruby-runtime', '0.10' end jenkins-rbenv.pluginspec
  32. 32. Jenkins::Plugin::Specification.new do ¦plugin¦ plugin.name = "jenkins-rbenv" plugin.display_name = "Jenkins Rbenv Plugin" plugin.version = '0.0.1' plugin.description = 'TODO: enter description here' plugin.url = 'https://wiki.jenkins-ci.org/ display/JENKINS/Jenkins+Rbenv+Plugin' plugin.developed_by "shibata.hiroshi", "SHIBATA Hiroshi <shibata.hiroshi@gmail.com>" plugin.uses_repository :github => "jenkins- rbenv-plugin" plugin.depends_on 'ruby-runtime', '0.10' end jenkins-rbenv.pluginspec
  33. 33. Jenkins::Plugin::Specification.new do ¦plugin¦ plugin.name = "jenkins-rbenv" plugin.display_name = "Jenkins Rbenv Plugin" plugin.version = '0.0.1' plugin.description = 'TODO: enter description here' plugin.url = 'https://wiki.jenkins-ci.org/ display/JENKINS/Jenkins+Rbenv+Plugin' plugin.developed_by "shibata.hiroshi", "SHIBATA Hiroshi <shibata.hiroshi@gmail.com>" plugin.uses_repository :github => "jenkins- rbenv-plugin" plugin.depends_on 'ruby-runtime', '0.10' end jenkins-rbenv.pluginspec
  34. 34. Jenkins::Plugin::Specification.new do ¦plugin¦ plugin.name = "jenkins-rbenv" plugin.display_name = "Jenkins Rbenv Plugin" plugin.version = '0.0.1' plugin.description = 'TODO: enter description here' plugin.url = 'https://wiki.jenkins-ci.org/ display/JENKINS/Jenkins+Rbenv+Plugin' plugin.developed_by "shibata.hiroshi", "SHIBATA Hiroshi <shibata.hiroshi@gmail.com>" plugin.uses_repository :github => "jenkins- rbenv-plugin" plugin.depends_on 'ruby-runtime', '0.10' end jenkins-rbenv.pluginspec
  35. 35. jpi generate
  36. 36. Available Generators: publisher builder wrapper node_property run_listener computer_listener
  37. 37. 1. publisher 3. wrapper 2. builder ビルド後に何かやる ビルドとして何かやる ビルド前後に処理を挟む
  38. 38. 4. node_property 6. computer_listener 5. run_listener jenkins の node 設定 ビルドの完了を受け取っ て何かやる ステータスが変わった時 に何かやる
  39. 39. wrapper を作ってみよう
  40. 40. % cd rbenv % jpi generate wrapper rbenv create models/ rbenv_wrapper.rb
  41. 41. class RbenvWrapper < Jenkins::Tasks::BuildWrapper display_name "Rbenv build wrapper" def initialize(attrs = {}) end def setup(build, launcher, listener) end def teardown(build, listener) end end rbenv_wrapper.rb
  42. 42. class RbenvWrapper < Jenkins::Tasks::BuildWrapper display_name "Rbenv build wrapper" def initialize(attrs = {}) end def setup(build, launcher, listener) end def teardown(build, listener) end end rbenv_wrapper.rb
  43. 43. class RbenvWrapper < Jenkins::Tasks::BuildWrapper display_name "Rbenv build wrapper" def initialize(attrs = {}) end def setup(build, launcher, listener) end def teardown(build, listener) end end rbenv_wrapper.rb
  44. 44. class RbenvWrapper < Jenkins::Tasks::BuildWrapper display_name "Rbenv build wrapper" def initialize(attrs = {}) end def setup(build, launcher, listener) end def teardown(build, listener) end end rbenv_wrapper.rb
  45. 45. 設定画面を 使いたい
  46. 46. mkdir -p views/rbenv_wrapper touch views/rbenv_wrapper/ config.erb
  47. 47. <% f = taglib("/lib/form") f.entry(:title => 'Version', :field => 'version', :description => "RUBY, such as '1.9.3- p194'") do f.textbox end f.entry(:title => 'Preinstall gem list', :field => 'gem_list', :description => "ex. bundler,rake") do f.textbox(:value => 'bundler,rake') end %> config.erb
  48. 48. jelly taglib
  49. 49. class RbenvWrapper < Jenkins::Tasks::BuildWrapper display_name "Rbenv build wrapper" def initialize(attrs = {}) end def setup(build, launcher, listener) end def teardown(build, listener) end end rbenv_wrapper.rb
  50. 50. attr_accessor :version def initialize(attrs = {}) @version = attrs['version'] end rbenv_wrapper.rb
  51. 51. class RbenvWrapper < Jenkins::Tasks::BuildWrapper display_name "Rbenv build wrapper" def initialize(attrs = {}) end def setup(build, launcher, listener) end def teardown(build, listener) end end rbenv_wrapper.rb
  52. 52. install_path = " /.rbenv/versions/#{@version}" begin unless FileTest.directory? File.expand_path(" /.rbenv") listener << "Install rbenvn" launcher.execute("bash", "-c", "git clone #{RBENV_PATH} /.rbenv", {out: listener}) end rescue build.abort end rbenv_wrapper.rb
  53. 53. install_path = " /.rbenv/versions/#{@version}" begin unless FileTest.directory? File.expand_path(" /.rbenv") listener << "Install rbenvn" launcher.execute("bash", "-c", "git clone #{RBENV_PATH} /.rbenv", {out: listener}) end rescue build.abort end rbenv_wrapper.rb
  54. 54. install_path = " /.rbenv/versions/#{@version}" begin unless FileTest.directory? File.expand_path(" /.rbenv") listener << "Install rbenvn" launcher.execute("bash", "-c", "git clone #{RBENV_PATH} /.rbenv", {out: listener}) end rescue build.abort end rbenv_wrapper.rb
  55. 55. install_path = " /.rbenv/versions/#{@version}" begin unless FileTest.directory? File.expand_path(" /.rbenv") listener << "Install rbenvn" launcher.execute("bash", "-c", "git clone #{RBENV_PATH} /.rbenv", {out: listener}) end rescue build.abort end rbenv_wrapper.rb
  56. 56. jpi build
  57. 57. 1. pluginspec から pom.xml を生成 2. hpi ファイルを生 成
  58. 58. jpi server
  59. 59. plugin を 読み込んだ Jenkins を起動する
  60. 60. 手動テスト
  61. 61. jpi release
  62. 62. 1. jenkins-ci.org にアッ プロードする 3. 引数無しは snapshot, --release を付けると production 2. /.jenkins-ci.org の アカウント情報を使用
  63. 63. その他
  64. 64. test-unit or rspec テスト
  65. 65. 使えないので Java ライブラリ で頑張る rubygems
  66. 66. etc https://github.com/jenkinsci/rvm-plugin https://github.com/hsbt/jenkins-rbenv-plugin https://github.com/takai/jenkins-hipchat-publisher-plugin
  67. 67. Write your plugin

×