Class: Janky::Builder::Client
- Inherits:
-
Object
- Object
- Janky::Builder::Client
- Defined in:
- lib/janky/builder/client.rb
Instance Attribute Summary collapse
-
#callback_url ⇒ Object
readonly
The String absoulte URL callback of this Janky host.
-
#url ⇒ Object
readonly
The String absolute URL of the Jenkins server.
Instance Method Summary collapse
-
#adapter ⇒ Object
The adapter used to trigger builds.
-
#complete! ⇒ Object
Simulate the last callback.
-
#green! ⇒ Object
(also: #enable_mock!, #reset!)
Enable the mock adapter and make subsequent builds green.
-
#initialize(url, callback_url) ⇒ Client
constructor
A new instance of Client.
- #job_creator ⇒ Object
-
#output(build) ⇒ Object
Retrieve the output of the given Build.
-
#red! ⇒ Object
Enable the mock adapter and make subsequent builds red.
-
#run(build) ⇒ Object
Trigger a Jenkins build for the given Build.
-
#setup(name, repo_uri, template_path) ⇒ Object
Setup a job on the Jenkins server.
-
#start! ⇒ Object
Simulate the first callback.
Constructor Details
#initialize(url, callback_url) ⇒ Client
Returns a new instance of Client.
4 5 6 7 |
# File 'lib/janky/builder/client.rb', line 4 def initialize(url, callback_url) @url = URI(url) @callback_url = URI(callback_url) end |
Instance Attribute Details
#callback_url ⇒ Object (readonly)
The String absoulte URL callback of this Janky host.
13 14 15 |
# File 'lib/janky/builder/client.rb', line 13 def callback_url @callback_url end |
#url ⇒ Object (readonly)
The String absolute URL of the Jenkins server.
10 11 12 |
# File 'lib/janky/builder/client.rb', line 10 def url @url end |
Instance Method Details
#adapter ⇒ Object
The adapter used to trigger builds. Defaults to HTTP, which hits the Jenkins server configured by ‘setup`.
46 47 48 |
# File 'lib/janky/builder/client.rb', line 46 def adapter @adapter ||= HTTP.new(url.user, url.password) end |
#complete! ⇒ Object
Simulate the last callback. Only available when mocked.
77 78 79 |
# File 'lib/janky/builder/client.rb', line 77 def complete! @adapter.complete end |
#green! ⇒ Object Also known as: enable_mock!, reset!
Enable the mock adapter and make subsequent builds green.
55 56 57 58 |
# File 'lib/janky/builder/client.rb', line 55 def green! @adapter = Mock.new(true, Janky.app) job_creator.enable_mock! end |
#job_creator ⇒ Object
50 51 52 |
# File 'lib/janky/builder/client.rb', line 50 def job_creator @job_creator ||= JobCreator.new(url, @callback_url) end |
#output(build) ⇒ Object
Retrieve the output of the given Build.
build - a Build object. Must have an url attribute.
Returns the String build output.
29 30 31 |
# File 'lib/janky/builder/client.rb', line 29 def output(build) Runner.new(@url, build, adapter).output end |
#red! ⇒ Object
Enable the mock adapter and make subsequent builds red.
67 68 69 |
# File 'lib/janky/builder/client.rb', line 67 def red! @adapter = Mock.new(false, Janky.app) end |
#run(build) ⇒ Object
Trigger a Jenkins build for the given Build.
build - a Build object.
Returns the Jenkins build URL.
20 21 22 |
# File 'lib/janky/builder/client.rb', line 20 def run(build) Runner.new(@url, build, adapter).run end |
#setup(name, repo_uri, template_path) ⇒ Object
Setup a job on the Jenkins server.
name - The desired job name as a String. repo_uri - The repository git URI as a String. template_path - The Pathname to the XML config template.
Returns nothing.
40 41 42 |
# File 'lib/janky/builder/client.rb', line 40 def setup(name, repo_uri, template_path) job_creator.run(name, repo_uri, template_path) end |
#start! ⇒ Object
Simulate the first callback. Only available when mocked.
72 73 74 |
# File 'lib/janky/builder/client.rb', line 72 def start! @adapter.start end |