Hi,

On Mar 15, 2012, at 8:29 PM, Rhett Sutphin wrote:

> Hi,
> 
> I'm working on my first Jenkins plugin. I'm using the Jenkins Ruby API. The 
> idea of the plugin is to archive the bundler Gemfile.lock for a ruby project 
> and have Jenkins show you how it changed between builds.
> 
> I've got the first part of this working (archiving Gemfile.lock) using a 
> subclass of Jenkins::Tasks::Publisher. It was very easy -- the development 
> environment for ruby plugins (`jpi server`, etc.) is great. 
> 
> Now I'm trying to add the action which will display the differences. I can't 
> find any examples of using actions from the ruby plugin API, except for an 
> example of a root action in the documentation for 
> Jenkins::Plugin#register_extension. Since the action is build-related, I 
> don't think that register_extension is the right point. As I said, though, 
> I'm completely new to Jenkins plugin development so I may be going at this 
> the wrong way. I've been trying variations on this:
> 
>   def perform(build, launcher, listener)
>     # ...
>     build.native.add_action(Jenkins::Plugin.instance.export(my_action))
>   end
> 
> If my_action is a subclass of Jenkins::Model::RootAction, the build is not 
> serializable. If my_action just mixes in Jenkins::Model::Action, I get an 
> "unable to find suitable Java Proxy" during the build. I'm using ruby-runtime 
> 0.4, jpi 0.3.3, and jenkins-ruby-runtime 0.1.26.
> 
> Are actions supported from the ruby API? If so, can someone give me a pointer 
> on how to construct and add one? (Or if I'm completely misunderstanding what 
> actions are for, a suggestion to go re-read the documentation would be 
> appreciated.)

I got past this issue. Here's what I did, in case anyone else has the same 
problem. First, I upgraded my plugin's dependency to ruby-runtime 0.9 and I 
upgraded jpi's development Jenkins instance to 1.455. I set up my action like 
so:

class BundledGems
  include Jenkins::Model::Action

  # ...
end

and I registered a proxy for it by hand:

class BundledGemsProxy
  include Jenkins::Plugin::Proxies::Action
  proxy_for BundledGems
end

Then in my publisher's perform method I did what I had outlined in my previous 
message:

  def perform(build, launcher, listener)
    # ...
    build.native.add_action(Jenkins.plugin.export(BundledGems.new(...)))
  end

I'm now having a problem rendering the view for the action 
(org.jruby.exceptions.RaiseException: (NameError) uninitialized constant 
Rack::VERSION) but I'll post with more details if I can't figure it out.

Thanks,
Rhett

Reply via email to