Module: Jenkins::Slaves::ComputerListener

Extended by:
Plugin::Behavior
Includes:
Extension
Defined in:
lib/jenkins/slaves/computer_listener.rb

Overview

Receive notification of what computers in a build array are doing.

Include this module in your class in order to receive callbacks when nodes come online, offline, etc.., etc…

To receive a callback, override the method with the same name as the event. E.g.

class MyComputerListener
  include Jenkins::Slaves::ComputerListener

  def online(computer, listener)
    puts "#{computer} is now online!"
  end
end

Instance Method Summary collapse

Methods included from Plugin::Behavior

extended, implemented, included

Methods included from Plugin::Behavior::BehavesAs

#behaves_as

Instance Method Details

#configuredObject

Called when configuration of the node was changed, a node is added/removed, etc.



81
82
# File 'lib/jenkins/slaves/computer_listener.rb', line 81

def configured()
end

#launchfailed(computer, listener) ⇒ Object

Called when a slave attempted to connect via ComputerLauncher but failed.

Parameters:

  • computer (Jenkins::Model::Computer)

    the computer that was trying to launch

  • listener (Jenkins::Model::Listener)

    the listener connected to the slave console log



44
45
# File 'lib/jenkins/slaves/computer_listener.rb', line 44

def launchfailed(computer, listener)
end

#offline(computer) ⇒ Object

Called right after a Computer went offline.

Parameters:

  • computer (Jenkins::Model::Computer)

    the computer that just went offline



77
78
# File 'lib/jenkins/slaves/computer_listener.rb', line 77

def offline(computer)
end

#online(computer, listener) ⇒ Object

Called right after a Computer comes online.

This enables you to do some work on all the slaves as they get connected.

Parameters:

  • computer (Jenkins::Model::Computer)

    the computer that just came online

  • listener (Jenkins::Model::Listener)

    connected to the launch log of the computer.

See Also:

  • Jenkins::Slaves::ComputerListener.{{#preonline}


71
72
# File 'lib/jenkins/slaves/computer_listener.rb', line 71

def online(computer, listener)
end

#prelaunch(computer, listener) ⇒ Object

Called before a ComputerLauncher is asked to launch a connection with Computer.

This enables you to do some configurable checks to see if we want to bring this slave online or if there are considerations that would keep us from doing so.

Calling Computer#abort would let you veto the launch operation. Other thrown exceptions will also have the same effect

Parameters:

  • computer (Jenkins::Model::Computer)

    the computer about to be launched

  • listener (Jenkins::Model::Listener)

    the listener connected to the slave console log.



37
38
# File 'lib/jenkins/slaves/computer_listener.rb', line 37

def prelaunch(computer, listener)
end

#preonline(computer, channel, root, listener) ⇒ Object

Called before a Computer is marked online.

This enables you to do some work on all the slaves as they get connected. Unlike #online, a failure to carry out this function normally will prevent a computer from marked as online.

Parameters:

  • channel (Jenkins::Remote::Channel)

    the channel object to talk to the slave.

  • root (Jenkins::FilePath)

    the directory where this slave stores files.

  • listener (Jenkins::Model::Listener)

    connected to the launch log of the computer.

See Also:

  • Jenkins::Slaves::ComputerListener.{{#online}


58
59
# File 'lib/jenkins/slaves/computer_listener.rb', line 58

def preonline(computer, channel, root, listener)
end