jenkins-plugin-runtime 0.1.24 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,3 +24,5 @@ require 'jenkins/listeners/run_listener'
24
24
  require 'jenkins/listeners/run_listener_proxy'
25
25
  require 'jenkins/slaves/node_property'
26
26
  require 'jenkins/slaves/node_property_proxy'
27
+ require 'jenkins/slaves/computer_listener'
28
+ require 'jenkins/slaves/computer_listener_proxy'
@@ -1,7 +1,7 @@
1
1
  module Jenkins
2
2
  class Plugin
3
3
  module Runtime
4
- VERSION = "0.1.24"
4
+ VERSION = "0.1.25"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,83 @@
1
+ module Jenkins::Slaves
2
+ # Receive notification of what computers in a build array are doing.
3
+ #
4
+ # Include this module in your class in order to receive callbacks
5
+ # when nodes come online, offline, etc.., etc...
6
+ #
7
+ # To receive a callback, override the method with the same name as
8
+ # the event. E.g.
9
+ #
10
+ # class MyComputerListener
11
+ # include Jenkins::Slaves::ComputerListener
12
+ #
13
+ # def online(computer, listener)
14
+ # puts "#{computer} is now online!"
15
+ # end
16
+ # end
17
+ #
18
+ module ComputerListener
19
+ extend Jenkins::Plugin::Behavior
20
+
21
+ implemented do |cls|
22
+ Jenkins.plugin.register_extension ComputerListenerProxy.new(Jenkins.plugin, cls.new)
23
+ end
24
+
25
+ # Called before a {ComputerLauncher} is asked to launch a connection with {Computer}.
26
+ #
27
+ # This enables you to do some configurable checks to see if we
28
+ # want to bring this slave online or if there are considerations
29
+ # that would keep us from doing so.
30
+ #
31
+ # Calling Computer#abort would let you veto the launch operation. Other thrown exceptions
32
+ # will also have the same effect
33
+ #
34
+ # @param [Jenkins::Model::Computer] computer the computer about to be launched
35
+ # @param [Jenkins::Model::Listener] listener the listener connected to the slave console log.
36
+ def prelaunch(computer, listener)
37
+ end
38
+
39
+ # Called when a slave attempted to connect via {ComputerLauncher} but failed.
40
+ #
41
+ # @param [Jenkins::Model::Computer] computer the computer that was trying to launch
42
+ # @param [Jenkins::Model::Listener] listener the listener connected to the slave console log
43
+ def launchfailed(computer, listener)
44
+ end
45
+
46
+ # Called before a {Computer} is marked online.
47
+ #
48
+ # This enables you to do some work on all the slaves
49
+ # as they get connected. Unlike {#online},
50
+ # a failure to carry out this function normally will prevent
51
+ # a computer from marked as online.
52
+ #
53
+ # @param [Jenkins::Remote::Channel] channel the channel object to talk to the slave.
54
+ # @param [Jenkins::FilePath] root the directory where this slave stores files.
55
+ # @param [Jenkins::Model::Listener] listener connected to the launch log of the computer.
56
+ # @see {#online}
57
+ def preonline(computer, channel, root, listener)
58
+ end
59
+
60
+ # Called right after a {Computer} comes online.
61
+ #
62
+ # This enables you to do some work on all the slaves
63
+ # as they get connected.
64
+ #
65
+ #
66
+ # @param [Jenkins::Model::Computer] computer the computer that just came online
67
+ # @param [Jenkins::Model::Listener] listener connected to the launch log of the computer.
68
+ # @see {#preonline}
69
+ #
70
+ def online(computer, listener)
71
+ end
72
+
73
+ # Called right after a {@link Computer} went offline.
74
+ #
75
+ # @param [Jenkins::Model::Computer] computer the computer that just went offline
76
+ def offline(computer)
77
+ end
78
+
79
+ # Called when configuration of the node was changed, a node is added/removed, etc.
80
+ def configured()
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,29 @@
1
+ module Jenkins::Slaves
2
+ class ComputerListenerProxy < Java.hudson.slaves.ComputerListener
3
+ include Jenkins::Plugin::Proxy
4
+
5
+ def preLaunch(computer, taskListener)
6
+ @object.prelaunch(import(computer), import(listener))
7
+ end
8
+
9
+ def onLaunchFailure(computer, taskListener)
10
+ @object.launchfailed(import(computer), import(taskListener))
11
+ end
12
+
13
+ def preOnline(computer, channel, rootFilePath, taskListener)
14
+ @object.preonline(import(computer), import(channel), Jenkins::FilePath.new(rootFilePath), import(taskListener))
15
+ end
16
+
17
+ def onOnline(computer)
18
+ @object.online(import(computer))
19
+ end
20
+
21
+ def onOffline(computer)
22
+ @object.offline(import(computer))
23
+ end
24
+
25
+ def onConfigurationChange()
26
+ @object.configured()
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jenkins-plugin-runtime
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.24
5
+ version: 0.1.25
6
6
  platform: ruby
7
7
  authors:
8
8
  - Charles Lowell
@@ -126,6 +126,8 @@ files:
126
126
  - lib/jenkins/plugin/wrapper.rb
127
127
  - lib/jenkins/rack.rb
128
128
  - lib/jenkins/slaves/cloud.rb
129
+ - lib/jenkins/slaves/computer_listener.rb
130
+ - lib/jenkins/slaves/computer_listener_proxy.rb
129
131
  - lib/jenkins/slaves/node_property.rb
130
132
  - lib/jenkins/slaves/node_property_proxy.rb
131
133
  - lib/jenkins/tasks/build_step.rb