Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ruby Plugins for Jenkins

15,362 views

Published on

After almost a year of slow but steady development, the time is soon approaching when you will be able to start writing Jenkins plugins armed with nothing but a simple JRuby environment.

To illustrate exactly what this means, we'll study the anatomy of a Ruby plugin, how it works at runtime, and walk through the creation, testing and deploying of an example using nothing put 100% pure Ruby.

Finally, beyond the mechanical, we'll discuss why this effort is important for the entire Jenkins community, not just the part of the community that uses Ruby.

Published in: Technology
  • Login to see the comments

Ruby Plugins for Jenkins

  1. 1. Ruby PluginsYou’ve come a long way baby
  2. 2. Charles Lowell• cowboyd@github• cowboyd@twitter• cowboyd@jenkins-ci
  3. 3. What the hell am I doing here?
  4. 4. User Interfaces
  5. 5. Lots of Ruby
  6. 6. Lot’s of JavaScript
  7. 7. Lot’s of Java/C++ + therubyracer, therubyrhino
  8. 8. Bugs!• Ruby versions (1.8.6,1.8.7,1.9.2, rbx, jruby, ...)• CC/libc version• OS (OSX, ubuntu, rhel)
  9. 9. HELL
  10. 10. We need a DIESEL CI solution.
  11. 11. Fun Fact: Weactually designed this logo
  12. 12. jenkins.rb 0.1• rubygem containing jenkins.war• utility for starting a test jenkins server
  13. 13. Dr Nic • Saw my lightning talk • went hog wild on the gem
  14. 14. jenkins.rb 1.0 • create/list/update jobs from CLI • create sinatra/rails jobs in one go • huge arsenal of Jenkins Macros
  15. 15. Eventually, we wanted more than macros.
  16. 16. Ruby PluginsExtend Jenkins with nothing but Ruby
  17. 17. We need a plan
  18. 18. How ‘bout you do it?We need a plan
  19. 19. Mad Propers! Kohsuke Kawaguchi
  20. 20. Ruby Plugins See them in action
  21. 21. What does it mean fora plugin to be in Ruby?
  22. 22. Language Ruby. Duh.
  23. 23. APImust “feel” like Ruby, not just scripting Java.
  24. 24. Example“Push” vs “Pull” configuration
  25. 25. Java
  26. 26. Scripted Java
  27. 27. Ruby
  28. 28. ToolsThey’ve gotta be Ruby too.
  29. 29. -Maven -javac• Rake - build and assembly• Bundler - dependency management• jpi - development tools
  30. 30. TestingYup, also Ruby
  31. 31. No solid answers yet• unit testing?• mocking builds, jobs, projects?• fixtures for builds, jobs, projects?
  32. 32. How it works
  33. 33. How it works Plugin.java
  34. 34. Plugin.java Jenkins •Ruby Runtime Plugin Small as can jenkins-ruby-api possibly be Ruby Plugin A bundled gems • plugin ruby code 5 small classes Ruby Plugin B ..... • will not instantiate extension points jenkins-ruby-api Ruby Plugin C bundled gems plugin ruby code
  35. 35. Plugin.java Jenkins •Ruby Runtime Plugin every plugin gets its own scripting JRuby Ruby Plugin A container Ruby Plugin B ..... • isolation + JRuby backwards Ruby Plugin C compatibility
  36. 36. How it works Plugin.rb
  37. 37. Plugin.rb Jenkins •Ruby Runtime Plugin own copy of API JRuby ruby API Ruby Plugin A bundled gems extension points • own copy of gems Ruby Plugin B ..... • Ruby extension JRuby points detected Ruby Plugin C ruby API bundled gems and auto-loaded extension points
  38. 38. Plugin.rb JenkinsRuby Runtime Plugin JRuby • Library code is free to vary from ruby API 1.1 Ruby Plugin A json 1.5, nokogiri 1.8 extension points plugin to plugin • Ruby Plugin B ..... This includes the plugin API! JRuby ruby API 1.3rc5 Ruby Plugin C json 1.6.4 extension points
  39. 39. Plugin.rb (API)• Builder - implement build steps• Publisher - run build steps after build complete• BuildWrapper - decorate a build with setup/teardown
  40. 40. Plugin.rb (API)• All Ruby extension points are Plain old Ruby objects (TM)• Plugin maintains two-way list of proxies to support this
  41. 41. Plugin.rb (API) Jenkins Ruby Plugin • All Java Objects Java Ruby proxied •hudson.model.AbstractBuild Jenkins::Model::Build All Ruby Objects wrapped • Java Ruby referential hudson.tasks.Builder Jenkins::Tasks::Builder integrity Proxies
  42. 42. More Fundamental than Ruby
  43. 43. Supporting Features• Flexible Descriptor registration• Pluggable persistence via JRuby Xstream• Stapler support for pluggable templating
  44. 44. Supporting FeaturesMore plugin-provided metadata. Less Java reflection.
  45. 45. What works for Ruby... works for Python
  46. 46. What works for Ruby... works for Python (in theory)
  47. 47. What works for Ruby... works for Python (in theory) but not as magnificently :)
  48. 48. What works for Ruby... works for JavaScript
  49. 49. What works for Ruby... works for Clojure
  50. 50. What works for Ruby... works for Fantom
  51. 51. What works for Ruby... works for X
  52. 52. 400+ Plugins to date
  53. 53. 4,000 plugins
  54. 54. 4,000 plugins sooner than you think?
  55. 55. Applications?
  56. 56. Frameworks?
  57. 57. gem install jenkins-plugin
  58. 58. Thanks!• cowboyd@github• cowboyd@twitter• cowboyd@jenkins-ci

×