jenkins-plugin-runtime 0.1.4 → 0.1.5
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.
- data/.travis.yml +1 -0
- data/jenkins-plugin-runtime.gemspec +1 -2
- data/lib/jenkins/launcher.rb +9 -2
- data/lib/jenkins/model/build.rb +12 -0
- data/lib/jenkins/model/descriptor.rb +3 -3
- data/lib/jenkins/plugin/proxies/builder.rb +6 -2
- data/lib/jenkins/plugin/runtime/version.rb +1 -1
- data/lib/jenkins/plugin/runtime.rb +1 -0
- data/lib/jenkins/plugin/specification.rb +49 -0
- data/spec/jenkins/model/build_spec.rb +3 -0
- data/spec/jenkins/plugin/example.pluginspec +6 -0
- data/spec/jenkins/plugin/proxies/builder_spec.rb +2 -2
- data/spec/jenkins/plugin/specification_spec.rb +28 -0
- metadata +11 -18
- data/lib/jenkins/plugin/cli.rb +0 -20
data/.travis.yml
CHANGED
@@ -21,10 +21,9 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_dependency "json"
|
23
23
|
|
24
|
-
s.add_development_dependency "rake"
|
24
|
+
s.add_development_dependency "rake", "0.8.7"
|
25
25
|
s.add_development_dependency "rspec", "~> 2.0"
|
26
26
|
s.add_development_dependency "rspec-spies"
|
27
|
-
s.add_development_dependency "cucumber", "~> 1.0"
|
28
27
|
s.add_development_dependency "jenkins-war"
|
29
28
|
|
30
29
|
end
|
data/lib/jenkins/launcher.rb
CHANGED
@@ -3,13 +3,20 @@ module Jenkins
|
|
3
3
|
|
4
4
|
# Launch processes on build slaves. No functionality is currently exposed
|
5
5
|
class Launcher
|
6
|
-
# the
|
6
|
+
# the native hudson.Launcher object
|
7
7
|
attr_reader :native
|
8
8
|
|
9
9
|
def initialize(native = nil)
|
10
10
|
@native = native
|
11
11
|
end
|
12
12
|
|
13
|
+
# TODO: wrap needed.
|
14
|
+
# Do we really wrap whole Launcher.ProcStarter things?
|
15
|
+
# Or create our own Launcher (must support remote, local, etc)
|
16
|
+
def launch
|
17
|
+
@native.launch()
|
18
|
+
end
|
19
|
+
|
13
20
|
Plugin::Proxies.register self, Java.hudson.Launcher
|
14
21
|
end
|
15
|
-
end
|
22
|
+
end
|
data/lib/jenkins/model/build.rb
CHANGED
@@ -13,6 +13,18 @@ module Jenkins
|
|
13
13
|
@native = native
|
14
14
|
end
|
15
15
|
|
16
|
+
def build_var
|
17
|
+
@native.getBuildVariables()
|
18
|
+
end
|
19
|
+
|
20
|
+
def env(listener = nil)
|
21
|
+
if listener
|
22
|
+
# TODO: not tested. dump to listener?
|
23
|
+
listener = Plugin.instance.export(listener)
|
24
|
+
end
|
25
|
+
@native.getEnvironment(listener)
|
26
|
+
end
|
27
|
+
|
16
28
|
Jenkins::Plugin::Proxies.register self, Java.hudson.model.AbstractBuild
|
17
29
|
end
|
18
30
|
|
@@ -22,9 +22,9 @@ module Jenkins
|
|
22
22
|
properties = JSON.parse(form.toString(2))
|
23
23
|
properties.delete("kind")
|
24
24
|
properties.delete("stapler-class")
|
25
|
-
instance =
|
26
|
-
puts "instance created: #{instance}"
|
27
|
-
return instance
|
25
|
+
instance = construct(properties)
|
26
|
+
puts "instance created: #{instance} (#{@java_type})"
|
27
|
+
return @plugin.export(instance)
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
@@ -8,14 +8,18 @@ module Jenkins
|
|
8
8
|
include Java.jenkins.ruby.Get
|
9
9
|
include Jenkins::Plugin::Proxy
|
10
10
|
|
11
|
-
def prebuild(build,
|
12
|
-
@object.prebuild(import(build), import(
|
11
|
+
def prebuild(build, listener)
|
12
|
+
@object.prebuild(import(build), import(listener)) ? true : false
|
13
13
|
end
|
14
14
|
|
15
15
|
def perform(build, launcher, listener)
|
16
16
|
@object.perform(import(build), import(launcher), import(listener)) ? true : false
|
17
17
|
end
|
18
18
|
|
19
|
+
def getDescriptor
|
20
|
+
@plugin.descriptors[@object.class]
|
21
|
+
end
|
22
|
+
|
19
23
|
def get(name)
|
20
24
|
@object.respond_to?(name) ? @object.send(name) : nil
|
21
25
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module Jenkins
|
5
|
+
class Plugin
|
6
|
+
class Specification
|
7
|
+
|
8
|
+
# The name of this plugin. Will be used as a globally
|
9
|
+
# unique identifier inside the Jenkins server
|
10
|
+
attr_accessor :name
|
11
|
+
|
12
|
+
# Plugin version. This is used during dependency resolution
|
13
|
+
attr_accessor :version
|
14
|
+
|
15
|
+
# Free form text description of the plugin. No character limit, but please, keep it civil.
|
16
|
+
attr_accessor :description
|
17
|
+
|
18
|
+
# A hash of dependencies, like 'foo' => '1.2.3', 'bar' => '0.0.1'
|
19
|
+
# Our dependency handling is not smart (yet).
|
20
|
+
attr_accessor :dependencies
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@dependencies = {}
|
24
|
+
yield(self) if block_given?
|
25
|
+
end
|
26
|
+
|
27
|
+
# Adds `plugin_name` as a pre-requisite of
|
28
|
+
# this plugin. This can be the name of any Jenkins plugin
|
29
|
+
# written in Ruby, Java, or any other language. Version right
|
30
|
+
# now must be an *exact* version number.
|
31
|
+
def depends_on(plugin_name, version)
|
32
|
+
dependencies[plugin_name] = version
|
33
|
+
end
|
34
|
+
|
35
|
+
# Make sure that your specification is not corrupt.
|
36
|
+
def validate!
|
37
|
+
[:name, :version, :description].each do |field|
|
38
|
+
fail SpecificationError, "field may not be nil" unless send(field)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.load(path)
|
43
|
+
eval(File.read(path), binding, path, 1)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
SpecificationError = Class.new(StandardError)
|
48
|
+
end
|
49
|
+
end
|
@@ -10,8 +10,8 @@ describe Jenkins::Plugin::Proxies::Builder do
|
|
10
10
|
|
11
11
|
describe "prebuild" do
|
12
12
|
it "calls through to its implementation" do
|
13
|
-
@object.should_receive(:prebuild).with(@build, @
|
14
|
-
@builder.prebuild(@jBuild, @
|
13
|
+
@object.should_receive(:prebuild).with(@build, @listener)
|
14
|
+
@builder.prebuild(@jBuild, @jListener)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jenkins::Plugin::Specification do
|
4
|
+
it "is invalid by default" do
|
5
|
+
expect {subject.validate!}.should raise_error Jenkins::Plugin::SpecificationError
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "when name, version and desc are set" do
|
9
|
+
before do
|
10
|
+
subject.tap do |spec|
|
11
|
+
spec.name = 'my-plugin'
|
12
|
+
spec.version = "0.0.1"
|
13
|
+
spec.description = "test plugin"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
it "is valid" do
|
17
|
+
subject.validate!.should be_true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "a spec loaded from a file" do
|
22
|
+
subject {Jenkins::Plugin::Specification.load(Pathname(__FILE__).dirname.join('example.pluginspec'))}
|
23
|
+
its(:name) {should eql "the-name"}
|
24
|
+
its(:version) {should eql "1.0.0"}
|
25
|
+
its(:description) {should eql "one great plugin"}
|
26
|
+
its(:dependencies) {should be_empty}
|
27
|
+
end
|
28
|
+
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.
|
5
|
+
version: 0.1.5
|
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: 2011-09-
|
13
|
+
date: 2011-09-16 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -30,9 +30,9 @@ dependencies:
|
|
30
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
|
-
- - "
|
33
|
+
- - "="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 0.8.7
|
36
36
|
type: :development
|
37
37
|
version_requirements: *id002
|
38
38
|
- !ruby/object:Gem::Dependency
|
@@ -57,28 +57,17 @@ dependencies:
|
|
57
57
|
version: "0"
|
58
58
|
type: :development
|
59
59
|
version_requirements: *id004
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: cucumber
|
62
|
-
prerelease: false
|
63
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: "1.0"
|
69
|
-
type: :development
|
70
|
-
version_requirements: *id005
|
71
60
|
- !ruby/object:Gem::Dependency
|
72
61
|
name: jenkins-war
|
73
62
|
prerelease: false
|
74
|
-
requirement: &
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
75
64
|
none: false
|
76
65
|
requirements:
|
77
66
|
- - ">="
|
78
67
|
- !ruby/object:Gem::Version
|
79
68
|
version: "0"
|
80
69
|
type: :development
|
81
|
-
version_requirements: *
|
70
|
+
version_requirements: *id005
|
82
71
|
description: I'll think of a better description later, but if you're reading this, then I haven't
|
83
72
|
email:
|
84
73
|
- cowboyd@thefrontside.net
|
@@ -103,13 +92,13 @@ files:
|
|
103
92
|
- lib/jenkins/model/listener.rb
|
104
93
|
- lib/jenkins/model/root_action.rb
|
105
94
|
- lib/jenkins/plugin.rb
|
106
|
-
- lib/jenkins/plugin/cli.rb
|
107
95
|
- lib/jenkins/plugin/proxies.rb
|
108
96
|
- lib/jenkins/plugin/proxies/build_wrapper.rb
|
109
97
|
- lib/jenkins/plugin/proxies/builder.rb
|
110
98
|
- lib/jenkins/plugin/proxy.rb
|
111
99
|
- lib/jenkins/plugin/runtime.rb
|
112
100
|
- lib/jenkins/plugin/runtime/version.rb
|
101
|
+
- lib/jenkins/plugin/specification.rb
|
113
102
|
- lib/jenkins/rack.rb
|
114
103
|
- lib/jenkins/slaves/cloud.rb
|
115
104
|
- lib/jenkins/tasks/build_wrapper.rb
|
@@ -120,11 +109,13 @@ files:
|
|
120
109
|
- spec/jenkins/model/describable_spec.rb
|
121
110
|
- spec/jenkins/model/listener_spec.rb
|
122
111
|
- spec/jenkins/model_spec.rb
|
112
|
+
- spec/jenkins/plugin/example.pluginspec
|
123
113
|
- spec/jenkins/plugin/proxies/build_wrapper_spec.rb
|
124
114
|
- spec/jenkins/plugin/proxies/builder_spec.rb
|
125
115
|
- spec/jenkins/plugin/proxies/proxy_helper.rb
|
126
116
|
- spec/jenkins/plugin/proxies_spec.rb
|
127
117
|
- spec/jenkins/plugin/proxy_spec.rb
|
118
|
+
- spec/jenkins/plugin/specification_spec.rb
|
128
119
|
- spec/jenkins/plugin_spec.rb
|
129
120
|
- spec/jenkins/tasks/build_wrapper_spec.rb
|
130
121
|
- spec/jenkins/tasks/builder_spec.rb
|
@@ -166,11 +157,13 @@ test_files:
|
|
166
157
|
- spec/jenkins/model/describable_spec.rb
|
167
158
|
- spec/jenkins/model/listener_spec.rb
|
168
159
|
- spec/jenkins/model_spec.rb
|
160
|
+
- spec/jenkins/plugin/example.pluginspec
|
169
161
|
- spec/jenkins/plugin/proxies/build_wrapper_spec.rb
|
170
162
|
- spec/jenkins/plugin/proxies/builder_spec.rb
|
171
163
|
- spec/jenkins/plugin/proxies/proxy_helper.rb
|
172
164
|
- spec/jenkins/plugin/proxies_spec.rb
|
173
165
|
- spec/jenkins/plugin/proxy_spec.rb
|
166
|
+
- spec/jenkins/plugin/specification_spec.rb
|
174
167
|
- spec/jenkins/plugin_spec.rb
|
175
168
|
- spec/jenkins/tasks/build_wrapper_spec.rb
|
176
169
|
- spec/jenkins/tasks/builder_spec.rb
|
data/lib/jenkins/plugin/cli.rb
DELETED