Hello,I've read some of the recent Jenkins mailing list activity about Ruby-based plugins with great interest. There's a particular kind of build trigger (for GitHub pull requests) that I'd love to have, and it seems like the best way to get it is to create it myself, but I have no experience with Java; I've used Ruby quite a bit, though, so the work that's been done with the Ruby plugin looks really promising.
So, my question: is it possible/practical to create triggers in Ruby with what's done so far? I don't know too much (only what I've read) about Jenkins development, but it looks like triggers might be a little different to the build steps that (as far as I can tell) are supported in Ruby so far. Would it be a matter of creating a new model and task (and maybe a new proxy?) in the jenkins-plugin-runtime gem?
Sorry if this is naive; I'm trying to figure out how this all fits together.
Thanks.Harry
> Hi Kenny,
>
> I also saw that error. I tried redefining the initialize method on
> Descriptor to add some logging, and just doing that made the exception
> stop happening - I don't know why yet, but I hope to find out and fix
> it properly at some point.
>
> I have found that the descriptor provided by a
> Java.hudson.triggers.Trigger object must actually derive from
> TriggerDescriptor (which derives from Descriptor) rather than just
> Descriptor, so register_describable doesn't actually work for triggers
> yet. Or, I may have just got things mixed up - this is my first foray
> into the Jenkins architecture.
>
I don't believe that's what's happening, but if Triggers do require TriggerDescriptors,
then that is something we will need to address further down the road. My suspicion is that it will through a ClassCastException at some point after or during instantiation. However, the trace here shows it failing at registration time, well before that happens.
I'm not sure what's going on here since descriptor.rb:9 is just explicitly invoking the super constructor on Descriptor.
Can you paste the code somewhere I can have a look at it online?
java.io.IOException: Dependency git (1.1.11) doesn't exist'
Charles,Thank you for your reply, but I don't understand what you said.I used jpi new to create a new plugin, and I created a new folder named "models", then I put the code in the folder.and I run command 'bundle' and 'jpi server', but I got error '致命的: Failed Loading plugin jenkins-jrubyjava.io.IOException: Dependency git (1.1.11) doesn't exist'
How can I install the Git plugin?
>>> Jenkins::Plugin.instance.register_describable MyTrigger, Java.hudson.triggers.Trigger
By changing this to the following, it got passed this problem:
> Jenkins::Plugin.instance.register_describable MyTrigger, Java.hudson.triggers.Trigger.java_class
The error message was very confusing. It's not the wrong number of
arguments, but rather just a type mismatch. I wonder if this is a bug in
JRuby.
There are other challenges before making this example work. So stay
tuned for further updates.
--
Kohsuke Kawaguchi | CloudBees, Inc. | http://cloudbees.com/
Try Nectar, our professional version of Jenkins
I found out the root cause. In the 2nd argument, this is actually passing in a Ruby class object, whereas the code is expecting the Java class.Jenkins::Plugin.instance.register_describable MyTrigger, Java.hudson.triggers.Trigger
By changing this to the following, it got passed this problem:Jenkins::Plugin.instance.register_describable MyTrigger, Java.hudson.triggers.Trigger.java_class
The error message was very confusing. It's not the wrong number of arguments, but rather just a type mismatch. I wonder if this is a bug in JRuby.
There are other challenges before making this example work. So stay tuned for further updates.