jenkins-plugin-runtime 0.1.23 → 0.1.24
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jenkins/model/describable.rb +2 -2
- data/lib/jenkins/model/environment.rb +24 -0
- data/lib/jenkins/model/environment_proxy.rb +52 -0
- data/lib/jenkins/plugin.rb +5 -5
- data/lib/jenkins/plugin/proxies.rb +1 -1
- data/lib/jenkins/plugin/runtime.rb +5 -0
- data/lib/jenkins/plugin/runtime/version.rb +1 -1
- data/lib/jenkins/slaves/node_property.rb +16 -0
- data/lib/jenkins/slaves/node_property_proxy.rb +7 -0
- data/lib/jenkins/tasks/build_wrapper.rb +1 -22
- data/lib/jenkins/tasks/build_wrapper_proxy.rb +15 -0
- data/spec/jenkins/model/describable_spec.rb +4 -4
- data/spec/jenkins/{plugin/proxies/build_wrapper_spec.rb → tasks/build_wrapper_proxy_spec.rb} +3 -3
- metadata +9 -5
- data/lib/jenkins/plugin/proxies/build_wrapper.rb +0 -49
@@ -41,8 +41,8 @@ module Jenkins
|
|
41
41
|
# Java class that represents the extension point, which gets eventually set to Descriptor.clazz
|
42
42
|
# :with will use this java class as the type of descriptor.
|
43
43
|
def describe_as cls, options = {}
|
44
|
-
@describe_as_type = verify_java_class(cls)
|
45
|
-
@descriptor_is = verify_java_class(options[:with])
|
44
|
+
@describe_as_type = verify_java_class(cls)
|
45
|
+
@descriptor_is = verify_java_class(options[:with]) if options[:with]
|
46
46
|
end
|
47
47
|
|
48
48
|
def describe_as_type
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Jenkins::Model
|
2
|
+
module Environment
|
3
|
+
# Perform setup for a build
|
4
|
+
#
|
5
|
+
# invoked after checkout, but before any `Builder`s have been run
|
6
|
+
# @param [Jenkins::Model::Build] build the build about to run
|
7
|
+
# @param [Jenkins::Launcher] launcher a launcher for the orderly starting/stopping of processes.
|
8
|
+
# @param [Jenkins::Model::Listener] listener channel for interacting with build output console
|
9
|
+
def setup(build, launcher, listener)
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
# Optionally perform optional teardown for a build
|
14
|
+
#
|
15
|
+
# invoked after a build has run for better or for worse. It's ok if subclasses
|
16
|
+
# don't override this.
|
17
|
+
#
|
18
|
+
# @param [Jenkins::Model::Build] the build which has completed
|
19
|
+
# @param [Jenkins::Model::Listener] listener channel for interacting with build output console
|
20
|
+
def teardown(build, listener)
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Jenkins::Model
|
2
|
+
module EnvironmentProxy
|
3
|
+
extend Jenkins::Plugin::Behavior
|
4
|
+
|
5
|
+
module InstanceMethods
|
6
|
+
def setUp(build, launcher, listener)
|
7
|
+
@object.setup(import(build), import(launcher), import(listener))
|
8
|
+
environment_class = self.class.environment_class || DefaultEnvironment
|
9
|
+
environment_class.new(self, @plugin, @object).tap do |env|
|
10
|
+
env.plugin = @plugin
|
11
|
+
env.impl = @object
|
12
|
+
end
|
13
|
+
rescue Jenkins::Model::Build::Halt
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module ClassMethods
|
19
|
+
attr_reader :environment_class
|
20
|
+
|
21
|
+
def environment_is(java_class, &block)
|
22
|
+
@environment_class = Class.new(java_class)
|
23
|
+
if block_given?
|
24
|
+
@environment_class.class_eval(&block)
|
25
|
+
end
|
26
|
+
@environment_class.class_eval do
|
27
|
+
include EnvironmentWrapper
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module EnvironmentWrapper
|
33
|
+
attr_accessor :plugin, :impl
|
34
|
+
|
35
|
+
def tearDown(build, listener)
|
36
|
+
@impl.teardown(@plugin.import(build), @plugin.import(listener))
|
37
|
+
true
|
38
|
+
rescue Jenkins::Model::Build::Halt
|
39
|
+
false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class DefaultEnvironment < Java.hudson.model.Environment
|
44
|
+
include EnvironmentWrapper
|
45
|
+
def initialize(proxy, plugin, object)
|
46
|
+
@plugin = plugin
|
47
|
+
@object = object
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
data/lib/jenkins/plugin.rb
CHANGED
@@ -116,10 +116,10 @@ module Jenkins
|
|
116
116
|
# @see [Model::Describable]
|
117
117
|
def register_describable(describable_class)
|
118
118
|
on.start do
|
119
|
-
fail "#{describable_class} is not an instance of Describable" unless describable_class
|
120
|
-
descriptor_class =
|
121
|
-
descriptor = descriptor_class.new(
|
122
|
-
@descriptors[
|
119
|
+
fail "#{describable_class} is not an instance of Describable" unless describable_class < Model::Describable
|
120
|
+
descriptor_class = describable_class.descriptor_is || Jenkins::Model::Descriptor
|
121
|
+
descriptor = descriptor_class.new(describable_class, self, describable_class.describe_as_type.java_class)
|
122
|
+
@descriptors[describable_class] = descriptor
|
123
123
|
register_extension(descriptor)
|
124
124
|
end
|
125
125
|
end
|
@@ -237,7 +237,7 @@ module Jenkins
|
|
237
237
|
def callback(listener, *args)
|
238
238
|
listener.call(*args)
|
239
239
|
rescue Exception => e
|
240
|
-
|
240
|
+
warn "#{e.class}: #{e.message}\n#{e.backtrace.join("\n")}"
|
241
241
|
end
|
242
242
|
end
|
243
243
|
end
|
@@ -172,7 +172,7 @@ module Jenkins
|
|
172
172
|
end
|
173
173
|
|
174
174
|
require 'jenkins/model/describable'
|
175
|
-
["action", "
|
175
|
+
["action", "builder", "publisher", "root_action"].each do |proxy|
|
176
176
|
require "jenkins/plugin/proxies/#{proxy}"
|
177
177
|
end
|
178
178
|
|
@@ -8,6 +8,8 @@ require 'jenkins/plugin/proxies/describable'
|
|
8
8
|
require 'jenkins/plugin/proxies'
|
9
9
|
require 'jenkins/cli/command'
|
10
10
|
require 'jenkins/model'
|
11
|
+
require 'jenkins/model/environment'
|
12
|
+
require 'jenkins/model/environment_proxy'
|
11
13
|
require 'jenkins/model/action'
|
12
14
|
require 'jenkins/model/root_action'
|
13
15
|
require 'jenkins/model/build'
|
@@ -16,6 +18,9 @@ require 'jenkins/model/listener'
|
|
16
18
|
require 'jenkins/slaves/cloud'
|
17
19
|
require 'jenkins/tasks/builder'
|
18
20
|
require 'jenkins/tasks/build_wrapper'
|
21
|
+
require 'jenkins/tasks/build_wrapper_proxy'
|
19
22
|
require 'jenkins/launcher'
|
20
23
|
require 'jenkins/listeners/run_listener'
|
21
24
|
require 'jenkins/listeners/run_listener_proxy'
|
25
|
+
require 'jenkins/slaves/node_property'
|
26
|
+
require 'jenkins/slaves/node_property_proxy'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Jenkins::Slaves
|
2
|
+
class NodeProperty
|
3
|
+
include Jenkins::Model
|
4
|
+
include Jenkins::Model::Environment
|
5
|
+
include Jenkins::Model::Describable
|
6
|
+
|
7
|
+
class NodePropertyDescriptor < Java.hudson.slaves.NodePropertyDescriptor
|
8
|
+
include Jenkins::Model::RubyDescriptor
|
9
|
+
|
10
|
+
def isApplicable(targetType)
|
11
|
+
true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
describe_as Java.hudson.slaves.NodeProperty, :with => NodePropertyDescriptor
|
15
|
+
end
|
16
|
+
end
|
@@ -7,30 +7,9 @@ module Jenkins
|
|
7
7
|
# {http://javadoc.jenkins-ci.org/hudson/tasks/BuildWrapper.html}
|
8
8
|
class BuildWrapper
|
9
9
|
include Jenkins::Model
|
10
|
+
include Jenkins::Model::Environment
|
10
11
|
include Jenkins::Model::Describable
|
11
|
-
|
12
12
|
describe_as Java.hudson.tasks.BuildWrapper
|
13
|
-
|
14
|
-
# Perform setup for a build
|
15
|
-
#
|
16
|
-
# invoked after checkout, but before any `Builder`s have been run
|
17
|
-
# @param [Jenkins::Model::Build] build the build about to run
|
18
|
-
# @param [Jenkins::Launcher] launcher a launcher for the orderly starting/stopping of processes.
|
19
|
-
# @param [Jenkins::Model::Listener] listener channel for interacting with build output console
|
20
|
-
def setup(build, launcher, listener)
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
# Optionally perform optional teardown for a build
|
25
|
-
#
|
26
|
-
# invoked after a build has run for better or for worse. It's ok if subclasses
|
27
|
-
# don't override this.
|
28
|
-
#
|
29
|
-
# @param [Jenkins::Model::Build] the build which has completed
|
30
|
-
# @param [Jenkins::Model::Listener] listener channel for interacting with build output console
|
31
|
-
def teardown(build, listener)
|
32
|
-
|
33
|
-
end
|
34
13
|
end
|
35
14
|
end
|
36
15
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Jenkins::Tasks
|
2
|
+
class BuildWrapperProxy < Java.hudson.tasks.BuildWrapper
|
3
|
+
include Jenkins::Plugin::Proxies::Describable
|
4
|
+
proxy_for Jenkins::Tasks::BuildWrapper
|
5
|
+
|
6
|
+
include Jenkins::Model::EnvironmentProxy
|
7
|
+
|
8
|
+
# BuildWrapper needs a custom Environment class, not sure why
|
9
|
+
environment_is Java.hudson.tasks.BuildWrapper::Environment do
|
10
|
+
def initialize(proxy, plugin, object)
|
11
|
+
super(proxy)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -40,7 +40,7 @@ describe Jenkins::Model::Describable do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "has the same java type as its superclass" do
|
43
|
-
@subclass.describe_as_type.should eql java.lang.Object
|
43
|
+
@subclass.describe_as_type.should eql java.lang.Object
|
44
44
|
end
|
45
45
|
|
46
46
|
describe ". a sub-subclass" do
|
@@ -51,9 +51,9 @@ describe Jenkins::Model::Describable do
|
|
51
51
|
it "is also registered as an extension of the original java type" do
|
52
52
|
@plugin.should have_received(:register_describable).with(@subsubclass)
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
it 'inherits its describe_as_type' do
|
56
|
-
@subsubclass.describe_as_type.should eql java.lang.Object
|
56
|
+
@subsubclass.describe_as_type.should eql java.lang.Object
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -70,7 +70,7 @@ describe Jenkins::Model::Describable do
|
|
70
70
|
lambda {@class.describe_as java.lang.Object, :with => Object}.should raise_error(Jenkins::Model::Describable::DescribableError)
|
71
71
|
end
|
72
72
|
it "inherits the descriptor type" do
|
73
|
-
@subclass.descriptor_is.should eql java.lang.String
|
73
|
+
@subclass.descriptor_is.should eql java.lang.String
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
data/spec/jenkins/{plugin/proxies/build_wrapper_spec.rb → tasks/build_wrapper_proxy_spec.rb}
RENAMED
@@ -1,15 +1,15 @@
|
|
1
1
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe Jenkins::
|
4
|
+
describe Jenkins::Tasks::BuildWrapperProxy do
|
5
5
|
include ProxyHelper
|
6
6
|
|
7
|
-
subject {Jenkins::
|
7
|
+
subject {Jenkins::Tasks::BuildWrapperProxy}
|
8
8
|
it {should be_transient(:plugin)}
|
9
9
|
|
10
10
|
before do
|
11
11
|
@object = mock(Jenkins::Tasks::BuildWrapper)
|
12
|
-
@wrapper = Jenkins::
|
12
|
+
@wrapper = Jenkins::Tasks::BuildWrapperProxy.new(@plugin, @object)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "passes in an env file which will be called to " do
|
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.
|
5
|
+
version: 0.1.24
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Charles Lowell
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-02-
|
13
|
+
date: 2012-02-03 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -106,6 +106,8 @@ files:
|
|
106
106
|
- lib/jenkins/model/build.rb
|
107
107
|
- lib/jenkins/model/describable.rb
|
108
108
|
- lib/jenkins/model/descriptor.rb
|
109
|
+
- lib/jenkins/model/environment.rb
|
110
|
+
- lib/jenkins/model/environment_proxy.rb
|
109
111
|
- lib/jenkins/model/listener.rb
|
110
112
|
- lib/jenkins/model/root_action.rb
|
111
113
|
- lib/jenkins/plugin.rb
|
@@ -113,7 +115,6 @@ files:
|
|
113
115
|
- lib/jenkins/plugin/proxies.rb
|
114
116
|
- lib/jenkins/plugin/proxies/action.rb
|
115
117
|
- lib/jenkins/plugin/proxies/build_step.rb
|
116
|
-
- lib/jenkins/plugin/proxies/build_wrapper.rb
|
117
118
|
- lib/jenkins/plugin/proxies/builder.rb
|
118
119
|
- lib/jenkins/plugin/proxies/describable.rb
|
119
120
|
- lib/jenkins/plugin/proxies/publisher.rb
|
@@ -125,8 +126,11 @@ files:
|
|
125
126
|
- lib/jenkins/plugin/wrapper.rb
|
126
127
|
- lib/jenkins/rack.rb
|
127
128
|
- lib/jenkins/slaves/cloud.rb
|
129
|
+
- lib/jenkins/slaves/node_property.rb
|
130
|
+
- lib/jenkins/slaves/node_property_proxy.rb
|
128
131
|
- lib/jenkins/tasks/build_step.rb
|
129
132
|
- lib/jenkins/tasks/build_wrapper.rb
|
133
|
+
- lib/jenkins/tasks/build_wrapper_proxy.rb
|
130
134
|
- lib/jenkins/tasks/builder.rb
|
131
135
|
- lib/jenkins/tasks/publisher.rb
|
132
136
|
- spec/jenkins/cli/command_proxy_spec.rb
|
@@ -141,7 +145,6 @@ files:
|
|
141
145
|
- spec/jenkins/model_spec.rb
|
142
146
|
- spec/jenkins/plugin/behavior_spec.rb
|
143
147
|
- spec/jenkins/plugin/example.pluginspec
|
144
|
-
- spec/jenkins/plugin/proxies/build_wrapper_spec.rb
|
145
148
|
- spec/jenkins/plugin/proxies/builder_spec.rb
|
146
149
|
- spec/jenkins/plugin/proxies/proxy_helper.rb
|
147
150
|
- spec/jenkins/plugin/proxies/publisher_spec.rb
|
@@ -150,6 +153,7 @@ files:
|
|
150
153
|
- spec/jenkins/plugin/proxy_spec.rb
|
151
154
|
- spec/jenkins/plugin/specification_spec.rb
|
152
155
|
- spec/jenkins/plugin_spec.rb
|
156
|
+
- spec/jenkins/tasks/build_wrapper_proxy_spec.rb
|
153
157
|
- spec/jenkins/tasks/build_wrapper_spec.rb
|
154
158
|
- spec/jenkins/tasks/builder_spec.rb
|
155
159
|
- spec/spec_helper.rb
|
@@ -195,7 +199,6 @@ test_files:
|
|
195
199
|
- spec/jenkins/model_spec.rb
|
196
200
|
- spec/jenkins/plugin/behavior_spec.rb
|
197
201
|
- spec/jenkins/plugin/example.pluginspec
|
198
|
-
- spec/jenkins/plugin/proxies/build_wrapper_spec.rb
|
199
202
|
- spec/jenkins/plugin/proxies/builder_spec.rb
|
200
203
|
- spec/jenkins/plugin/proxies/proxy_helper.rb
|
201
204
|
- spec/jenkins/plugin/proxies/publisher_spec.rb
|
@@ -204,6 +207,7 @@ test_files:
|
|
204
207
|
- spec/jenkins/plugin/proxy_spec.rb
|
205
208
|
- spec/jenkins/plugin/specification_spec.rb
|
206
209
|
- spec/jenkins/plugin_spec.rb
|
210
|
+
- spec/jenkins/tasks/build_wrapper_proxy_spec.rb
|
207
211
|
- spec/jenkins/tasks/build_wrapper_spec.rb
|
208
212
|
- spec/jenkins/tasks/builder_spec.rb
|
209
213
|
- spec/spec_helper.rb
|
@@ -1,49 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'jenkins/tasks/build_wrapper'
|
3
|
-
require 'jenkins/model/build'
|
4
|
-
|
5
|
-
module Jenkins
|
6
|
-
class Plugin
|
7
|
-
class Proxies
|
8
|
-
|
9
|
-
##
|
10
|
-
# Binds the Java hudson.tasks.BuildWrapper API to the idomatic
|
11
|
-
# Ruby API Jenkins::Tasks::BuildWrapper
|
12
|
-
|
13
|
-
class BuildWrapper < Java.hudson.tasks.BuildWrapper
|
14
|
-
include Describable
|
15
|
-
proxy_for Jenkins::Tasks::BuildWrapper
|
16
|
-
|
17
|
-
def setUp(build, launcher, listener)
|
18
|
-
@object.setup(import(build), import(launcher), import(listener))
|
19
|
-
EnvironmentWrapper.new(self, @plugin, @object)
|
20
|
-
rescue Jenkins::Model::Build::Halt
|
21
|
-
nil
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
class EnvironmentWrapper < Java.hudson.tasks.BuildWrapper::Environment
|
27
|
-
attr_accessor :env
|
28
|
-
|
29
|
-
def initialize(build_wrapper, plugin, impl)
|
30
|
-
super(build_wrapper)
|
31
|
-
@plugin = plugin
|
32
|
-
@impl = impl
|
33
|
-
end
|
34
|
-
|
35
|
-
# build wrapper that created this environment
|
36
|
-
def build_wrapper
|
37
|
-
@impl
|
38
|
-
end
|
39
|
-
|
40
|
-
def tearDown(build, listener)
|
41
|
-
@impl.teardown(@plugin.import(build), @plugin.import(listener))
|
42
|
-
true
|
43
|
-
rescue Jenkins::Model::Build::Halt
|
44
|
-
false
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|