Class: Jenkins::Plugin::Lifecycle

Inherits:
Object
  • Object
show all
Defined in:
lib/jenkins/plugin.rb

Instance Method Summary collapse

Constructor Details

#initializeLifecycle

Returns a new instance of Lifecycle.



229
230
231
232
# File 'lib/jenkins/plugin.rb', line 229

def initialize
  @start = []
  @stop = []
end

Instance Method Details

#callback(listener, *args) ⇒ Object



249
250
251
252
253
# File 'lib/jenkins/plugin.rb', line 249

def callback(listener, *args)
  listener.call(*args)
rescue Exception => e
  warn "#{e.class}: #{e.message}\n#{e.backtrace.join("\n")}"
end

#fire(event, *args) ⇒ Object



242
243
244
245
246
247
248
# File 'lib/jenkins/plugin.rb', line 242

def fire(event, *args)
  if listeners = instance_variable_get("@#{event}")
    listeners.each do |l|
      callback(l, *args)
    end
  end
end

#start(&block) ⇒ Object



234
235
236
# File 'lib/jenkins/plugin.rb', line 234

def start(&block)
  @start << block if block
end

#stop(&block) ⇒ Object



238
239
240
# File 'lib/jenkins/plugin.rb', line 238

def stop(&block)
  @stop << block if block
end