Method: Jenkins::Plugin#register_extension
- Defined in:
- lib/jenkins/plugin.rb
#register_extension(class_or_instance, *args) ⇒ Object
Registers a singleton extension point directly with Jenkins. Extensions registered via this method are different than those registered via ‘register_describable` in that there are only one instance of them, and so things like configuration construction, and validation do not apply.
This method accepts either an instance of the extension point or a class implementing the extension point. If a class is provided, it will attempt to construct an instance with the arguments provided. e.g.
# construct an instance
plugin.register_extension SomeRootAction, "gears.png"
# pass in a preconfigured instance
ext = MyGreatExtension.build do |c|
c.name "fantastic"
c.fizzle :foo
end
plugin.register_extension ext
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/jenkins/plugin.rb', line 102 def register_extension(class_or_instance, *args) extension = class_or_instance.is_a?(Class) ? class_or_instance.new(*args) : class_or_instance # look everywhere for possible ordinal value. # extension can be a Java object, or a Proxy to a Ruby object ordinal = 0 if extension.class.respond_to? :order ordinal = extension.class.order else t = import(extension) if t.class.respond_to? :order ordinal = t.class.order end end @peer.addExtension(export(extension), ordinal) end |