jpi 0.3.2 → 0.3.3
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/lib/jenkins/plugin/cli/generate.rb +37 -4
- data/lib/jenkins/plugin/cli/templates/Gemfile.tt +1 -1
- data/lib/jenkins/plugin/cli/templates/build_step.tt +7 -1
- data/lib/jenkins/plugin/cli/templates/computer_listener.tt +61 -0
- data/lib/jenkins/plugin/cli/templates/node_property.tt +32 -0
- data/lib/jenkins/plugin/cli/templates/run_listener.tt +33 -0
- data/lib/jenkins/plugin/version.rb +1 -1
- metadata +10 -4
@@ -4,23 +4,56 @@ module Jenkins
|
|
4
4
|
class CLI
|
5
5
|
class Generate < Thor
|
6
6
|
include Thor::Actions
|
7
|
-
|
7
|
+
attr_reader :name
|
8
|
+
default_task :help
|
8
9
|
source_root File.dirname(__FILE__)
|
9
10
|
|
10
|
-
|
11
|
+
def self.help(shell, task)
|
12
|
+
shell.say "Usage: jpi generate GENERATOR"
|
13
|
+
shell.say "Available Generators:"
|
14
|
+
tasks.each do |k, v|
|
15
|
+
next if k.to_s == 'help'
|
16
|
+
puts " #{k}"
|
17
|
+
end
|
18
|
+
end
|
11
19
|
|
12
20
|
desc "publisher", "publisher NAME", :desc => "generate a publish step definition"
|
13
|
-
def publisher
|
21
|
+
def publisher(name)
|
22
|
+
@name = name
|
14
23
|
@step_class = "Publisher"
|
15
24
|
template('templates/build_step.tt', "models/#{name.downcase}_publisher.rb")
|
16
25
|
end
|
17
26
|
|
18
27
|
desc "builder", "builder NAME", :desc => "generate a build step definition"
|
19
|
-
def builder
|
28
|
+
def builder(name)
|
29
|
+
@name = name
|
20
30
|
@step_class = "Builder"
|
21
31
|
template('templates/build_step.tt', "models/#{name.downcase}_builder.rb")
|
22
32
|
end
|
23
33
|
|
34
|
+
desc "wrapper", "wrapper NAME", :desc => "generate a build wrapper"
|
35
|
+
def wrapper(name)
|
36
|
+
@name = name
|
37
|
+
template('templates/build_wrapper.tt', "models/#{name.downcase}_wrapper.rb")
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "node_property", "node_property NAME", :desc => "generate a node_property extension point"
|
41
|
+
def node_property(name)
|
42
|
+
@name = name
|
43
|
+
template('templates/node_property.tt', "models/#{name.downcase}_property.rb")
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "run_listener", "run_listener NAME", :desc => "create a new run listener"
|
47
|
+
def run_listener(name)
|
48
|
+
@name = name
|
49
|
+
template('templates/run_listener.tt', "models/#{name.downcase}_listener.rb")
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "computer_listener", "computer_listener NAME", :desc => "create a new computer listener"
|
53
|
+
def computer_listener(name)
|
54
|
+
@name = name
|
55
|
+
template('templates/computer_listener.tt', "models/#{name.downcase}_listener.rb")
|
56
|
+
end
|
24
57
|
end
|
25
58
|
end
|
26
59
|
end
|
@@ -1,7 +1,13 @@
|
|
1
1
|
|
2
2
|
class <%= name.capitalize %><%= @step_class %> < Jenkins::Tasks::<%= @step_class %>
|
3
3
|
|
4
|
-
display_name "<%= name.capitalize %> <%= @step_class.downcase %>"
|
4
|
+
display_name "<%= @name.capitalize %> <%= @step_class.downcase %>"
|
5
|
+
|
6
|
+
# Invoked with the form parameters when this extension point
|
7
|
+
# is created from a configuration screen.
|
8
|
+
def initialize(attrs = {})
|
9
|
+
|
10
|
+
end
|
5
11
|
|
6
12
|
##
|
7
13
|
# Runs before the build begins
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class <%= name.capitalize %>Listener
|
2
|
+
include Jenkins::Slaves::ComputerListener
|
3
|
+
|
4
|
+
# Called before a {ComputerLauncher} is asked to launch a connection with {Computer}.
|
5
|
+
#
|
6
|
+
# This enables you to do some configurable checks to see if we
|
7
|
+
# want to bring this slave online or if there are considerations
|
8
|
+
# that would keep us from doing so.
|
9
|
+
#
|
10
|
+
# Calling Computer#abort would let you veto the launch operation. Other thrown exceptions
|
11
|
+
# will also have the same effect
|
12
|
+
#
|
13
|
+
# @param [Jenkins::Model::Computer] computer the computer about to be launched
|
14
|
+
# @param [Jenkins::Model::Listener] listener the listener connected to the slave console log.
|
15
|
+
def prelaunch(computer, listener)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Called when a slave attempted to connect via {ComputerLauncher} but failed.
|
19
|
+
#
|
20
|
+
# @param [Jenkins::Model::Computer] computer the computer that was trying to launch
|
21
|
+
# @param [Jenkins::Model::Listener] listener the listener connected to the slave console log
|
22
|
+
def launchfailed(computer, listener)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Called before a {Computer} is marked online.
|
26
|
+
#
|
27
|
+
# This enables you to do some work on all the slaves
|
28
|
+
# as they get connected. Unlike {#online},
|
29
|
+
# a failure to carry out this function normally will prevent
|
30
|
+
# a computer from marked as online.
|
31
|
+
#
|
32
|
+
# @param [Jenkins::Remote::Channel] channel the channel object to talk to the slave.
|
33
|
+
# @param [Jenkins::FilePath] root the directory where this slave stores files.
|
34
|
+
# @param [Jenkins::Model::Listener] listener connected to the launch log of the computer.
|
35
|
+
# @see {#online}
|
36
|
+
def preonline(computer, channel, root, listener)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Called right after a {Computer} comes online.
|
40
|
+
#
|
41
|
+
# This enables you to do some work on all the slaves
|
42
|
+
# as they get connected.
|
43
|
+
#
|
44
|
+
#
|
45
|
+
# @param [Jenkins::Model::Computer] computer the computer that just came online
|
46
|
+
# @param [Jenkins::Model::Listener] listener connected to the launch log of the computer.
|
47
|
+
# @see {#preonline}
|
48
|
+
#
|
49
|
+
def online(computer, listener)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Called right after a {@link Computer} went offline.
|
53
|
+
#
|
54
|
+
# @param [Jenkins::Model::Computer] computer the computer that just went offline
|
55
|
+
def offline(computer)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Called when configuration of the node was changed, a node is added/removed, etc.
|
59
|
+
def configured()
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class <%= name.capitalize %>Property < Jenkins::Slaves::NodeProperty
|
2
|
+
|
3
|
+
display_name "<%= name.capitalize %> node property"
|
4
|
+
|
5
|
+
|
6
|
+
# Invoked with the form parameters when this extension point
|
7
|
+
# is created from a configuration screen.
|
8
|
+
def initialize(attrs = {})
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
# Perform setup for a build
|
13
|
+
#
|
14
|
+
# invoked after checkout, but before any `Builder`s have been run
|
15
|
+
# @param [Jenkins::Model::Build] build the build about to run
|
16
|
+
# @param [Jenkins::Launcher] launcher a launcher for the orderly starting/stopping of processes.
|
17
|
+
# @param [Jenkins::Model::Listener] listener channel for interacting with build output console
|
18
|
+
def setup(build, launcher, listener)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
# Optionally perform optional teardown for a build
|
23
|
+
#
|
24
|
+
# invoked after a build has run for better or for worse. It's ok if subclasses
|
25
|
+
# don't override this.
|
26
|
+
#
|
27
|
+
# @param [Jenkins::Model::Build] the build which has completed
|
28
|
+
# @param [Jenkins::Model::Listener] listener channel for interacting with build output console
|
29
|
+
def teardown(build, listener)
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class <%= name.capitalize %>Listener
|
2
|
+
include Jenkins::Listeners::RunListener
|
3
|
+
|
4
|
+
# Called when a build is started (i.e. it was in the queue, and will now start running
|
5
|
+
# on an executor)
|
6
|
+
#
|
7
|
+
# @param [Jenkins::Model::Build] the started build
|
8
|
+
# @param [Jenkins::Model::TaskListener] the task listener for this build
|
9
|
+
def started(build, listener)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Called after a build is completed.
|
13
|
+
#
|
14
|
+
# @param [Jenkins::Model::Build] the completed build
|
15
|
+
# @param [Jenkins::Model::TaskListener] the task listener for this build
|
16
|
+
def completed(build, listener)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Called after a build is finalized.
|
20
|
+
#
|
21
|
+
# At this point, all the records related to a build is written down to the disk. As such,
|
22
|
+
# task Listener is no longer available. This happens later than {#completed}.
|
23
|
+
#
|
24
|
+
# @param [Jenkins::Model::Build] the finalized build
|
25
|
+
def finalized(build)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Called right before a build is going to be deleted.
|
29
|
+
#
|
30
|
+
# @param [Jenkins::Model::Build] The build.
|
31
|
+
def deleted(build)
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Charles Lowell
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2012-
|
15
|
+
date: 2012-02-03 00:00:00 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rubyzip
|
@@ -129,7 +129,10 @@ files:
|
|
129
129
|
- lib/jenkins/plugin/cli/new.rb
|
130
130
|
- lib/jenkins/plugin/cli/templates/Gemfile.tt
|
131
131
|
- lib/jenkins/plugin/cli/templates/build_step.tt
|
132
|
+
- lib/jenkins/plugin/cli/templates/computer_listener.tt
|
133
|
+
- lib/jenkins/plugin/cli/templates/node_property.tt
|
132
134
|
- lib/jenkins/plugin/cli/templates/pluginspec.tt
|
135
|
+
- lib/jenkins/plugin/cli/templates/run_listener.tt
|
133
136
|
- lib/jenkins/plugin/tools/bundle.rb
|
134
137
|
- lib/jenkins/plugin/tools/hpi.rb
|
135
138
|
- lib/jenkins/plugin/tools/loadpath.rb
|
@@ -168,5 +171,8 @@ rubygems_version: 1.8.9
|
|
168
171
|
signing_key:
|
169
172
|
specification_version: 3
|
170
173
|
summary: Tools for creating and building Jenkins Ruby plugins
|
171
|
-
test_files:
|
172
|
-
|
174
|
+
test_files:
|
175
|
+
- features/create-new-plugin.feature
|
176
|
+
- features/support/create_new_plugin_steps.rb
|
177
|
+
- features/support/directory_structure.rb
|
178
|
+
- features/support/work.rb
|