go_api_client 0.3.0 → 0.4.0
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/.gitignore +3 -0
- data/.yardopts +6 -0
- data/Gemfile.lock +1 -1
- data/README.textile +29 -1
- data/lib/go_api_client.rb +72 -32
- data/lib/go_api_client/artifact.rb +27 -0
- data/lib/go_api_client/http_fetcher.rb +30 -1
- data/lib/go_api_client/job.rb +5 -1
- data/lib/go_api_client/version.rb +1 -1
- data/test/fixtures/jobs_3.xml +36 -0
- data/test/go_api_client/artifact_test.rb +15 -0
- data/test/go_api_client/building_test.rb +15 -6
- data/test/go_api_client/stage_test.rb +6 -6
- data/test/schedule_test.rb +12 -0
- metadata +16 -2
data/.gitignore
CHANGED
data/.yardopts
ADDED
data/Gemfile.lock
CHANGED
data/README.textile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
h2. Go API Client Gem
|
2
2
|
|
3
|
-
This gem provides
|
3
|
+
This gem provides access to the "ThoughtWorks Studios Go":http://www.thoughtworks-studios.com/go-continuous-delivery API, it is capable of parsing out the atom feed and generate an object graph with all the pipelines/stages/jobs and committer information.
|
4
4
|
|
5
5
|
h2. Installation
|
6
6
|
|
@@ -8,6 +8,34 @@ h2. Installation
|
|
8
8
|
|
9
9
|
h2. Usage
|
10
10
|
|
11
|
+
See "GoApiClient":http://rubydoc.info/github/ThoughtWorksInc/go-api-client/GoApiClient for supported options and more details.
|
12
|
+
|
13
|
+
<pre>
|
14
|
+
require 'go_api_client'
|
15
|
+
|
16
|
+
# check if the server is building
|
17
|
+
GoApiClient.build_in_progress?(:host => 'go.example.com')
|
18
|
+
|
19
|
+
# check if the build has finished
|
20
|
+
GoApiClient.build_finished?(:host => 'go.example.com')
|
21
|
+
|
22
|
+
# schedule a pipeline
|
23
|
+
GoApiClient.schedule_pipeline(:host => 'go.example.com', :pipeline_name => 'MyProject')
|
24
|
+
|
25
|
+
# fetch a list of all pipelines
|
26
|
+
latest_atom_entry_id = nil
|
27
|
+
while true
|
28
|
+
last_run = GoApiClient.runs(:host => 'go.example.com', :pipeline_name => 'MyProject', :latest_atom_entry_id => latest_atom_entry_id)
|
29
|
+
latest_atom_entry_id = last_run.latest_atom_entry_id # => the last stage that was seen by the api client, keep this for further calls to #runs
|
30
|
+
|
31
|
+
pipelines = last_run.pipelines
|
32
|
+
last_pipeline = pipelines.last
|
33
|
+
puts "Finished running stage #{last_pipeline.stages.last.name} from pipeline #{last_pipeline.name}."
|
34
|
+
puts "The last commit(#{last_pipeline.commits.last.revision}) was checked in by #{last_pipeline.commits.last.user}"
|
35
|
+
sleep 10
|
36
|
+
end
|
37
|
+
</pre>
|
38
|
+
|
11
39
|
h2. License
|
12
40
|
|
13
41
|
Go API Client Gem is MIT Licensed
|
data/lib/go_api_client.rb
CHANGED
@@ -10,51 +10,91 @@ require 'go_api_client/atom'
|
|
10
10
|
require 'go_api_client/pipeline'
|
11
11
|
require 'go_api_client/stage'
|
12
12
|
require 'go_api_client/job'
|
13
|
+
require 'go_api_client/artifact'
|
13
14
|
require 'go_api_client/commit'
|
14
15
|
require 'go_api_client/user'
|
15
16
|
|
16
|
-
|
17
17
|
module GoApiClient
|
18
|
-
def self.runs(options)
|
19
|
-
options = ({:protocol => 'http', :port => 8153, :username => nil, :password => nil, :latest_atom_entry_id => nil, :pipeline_name => 'defaultPipeline'}).merge(options)
|
20
|
-
|
21
|
-
http_fetcher = GoApiClient::HttpFetcher.new(:username => options[:username], :password => options[:password])
|
22
18
|
|
23
|
-
|
19
|
+
# A wrapper that contains the last run information of scraping the go atom feed
|
20
|
+
class LastRun
|
21
|
+
# A list of pipelines
|
22
|
+
# @return [Array<Pipeline>]
|
23
|
+
# @see GoApiClient.runs
|
24
|
+
attr_reader :pipelines
|
24
25
|
|
25
|
-
feed
|
26
|
-
|
26
|
+
# The most recent atom entry when the feed was last fetched
|
27
|
+
attr_reader :latest_atom_entry_id
|
27
28
|
|
28
|
-
pipelines
|
29
|
-
|
30
|
-
|
29
|
+
def initialize(pipelines, latest_atom_entry_id)
|
30
|
+
@pipelines = pipelines
|
31
|
+
@latest_atom_entry_id = latest_atom_entry_id
|
31
32
|
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class << self
|
36
|
+
# Connects to the a go server via the "Atom Feed API":http://www.thoughtworks-studios.com/docs/go/current/help/Feeds_API.html
|
37
|
+
# and fetches entire the pipeline history for that pipeline. Since this this is a wrapper around an atom feed,
|
38
|
+
# it is important to remember the last atom feed entry that was seen in order to prevent crawling the entire atom feed
|
39
|
+
# over and over again and slow the process down.
|
40
|
+
#
|
41
|
+
# @return [LastRun] an object containing a list of all pipelines ordered by their counter along with the last stage that ran in the pipeline
|
42
|
+
# @param [Hash] options the connection options
|
43
|
+
# @option options [String] :host ("localhost") Host to connect to.
|
44
|
+
# @option options [Ingeger] :port (8153) Port to connect to.
|
45
|
+
# @option options [Boolean] :ssl (false) If connection should be made over ssl.
|
46
|
+
# @option options [String] :username (nil) The username to be used if server or the pipeline requires authorization.
|
47
|
+
# @option options [String] :password (nil) The password to be used if server or the pipeline requires authorization.
|
48
|
+
# @option options [String] :pipeline_name ("defaultPipeline") The name of the pipeline that should be fetched.
|
49
|
+
# @option options [String] :latest_atom_entry_id (nil) The id of the last atom feed entry
|
50
|
+
def runs(options={})
|
51
|
+
options = ({:ssl => false, :host => 'localhost', :port => 8153, :username => nil, :password => nil, :latest_atom_entry_id => nil, :pipeline_name => 'defaultPipeline'}).merge(options)
|
52
|
+
|
53
|
+
http_fetcher = GoApiClient::HttpFetcher.new(:username => options[:username], :password => options[:password])
|
54
|
+
|
55
|
+
feed_url = "#{options[:ssl] ? 'https' : 'http'}://#{options[:host]}:#{options[:port]}/go/api/pipelines/#{options[:pipeline_name]}/stages.xml"
|
56
|
+
|
57
|
+
feed = GoApiClient::Atom::Feed.new(feed_url, options[:latest_atom_entry_id])
|
58
|
+
feed.fetch!(http_fetcher)
|
59
|
+
|
60
|
+
pipelines = {}
|
61
|
+
stages = feed.entries.collect do |entry|
|
62
|
+
Stage.from(entry.stage_href, :authors => entry.authors, :pipeline_cache => pipelines, :http_fetcher => http_fetcher)
|
63
|
+
end
|
32
64
|
|
33
|
-
|
34
|
-
|
65
|
+
pipelines.values.each do |p|
|
66
|
+
p.stages = p.stages.sort_by {|s| s.completed_at }
|
67
|
+
end
|
68
|
+
|
69
|
+
pipelines = pipelines.values.sort_by {|p| p.counter}
|
70
|
+
latest_atom_entry_id = stages.empty? ? options[:latest_atom_entry_id] : feed.entries.first.id
|
71
|
+
return LastRun.new(pipelines, latest_atom_entry_id)
|
35
72
|
end
|
36
73
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
74
|
+
# Answers if a build is in progress. For the list of supported connection options see {GoApiClient.runs #runs}
|
75
|
+
# @see .build_finished?
|
76
|
+
def build_in_progress?(options={})
|
77
|
+
raise ArgumentError("Hostname is mandatory") unless options[:host]
|
78
|
+
options = ({:ssl => false, :port => 8153, :username => nil, :password => nil, :pipeline_name => 'defaultPipeline'}).merge(options)
|
79
|
+
http_fetcher = GoApiClient::HttpFetcher.new(:username => options[:username], :password => options[:password])
|
80
|
+
url = "#{options[:ssl] ? 'https' : 'http'}://#{options[:host]}:#{options[:port]}/go/cctray.xml"
|
81
|
+
doc = Nokogiri::XML(http_fetcher.get_response_body(url))
|
82
|
+
doc.css("Project[activity='Building'][name^='#{options[:pipeline_name]} ::']").count > 0
|
83
|
+
end
|
42
84
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
doc = Nokogiri::XML(http_fetcher.get_response_body(url))
|
49
|
-
doc.xpath("//Project[contains(@activity, 'Building')]").count > 0
|
50
|
-
end
|
85
|
+
# Answers if a build is in completed. For the list of supported connection options see {GoApiClient.runs #runs}
|
86
|
+
# @see .build_in_progress?
|
87
|
+
def build_finished?(options)
|
88
|
+
!build_in_progress?(options)
|
89
|
+
end
|
51
90
|
|
52
|
-
|
53
|
-
|
54
|
-
|
91
|
+
# Schedule a particular pipeline with the latest available materials.
|
92
|
+
def schedule_pipeline(options)
|
93
|
+
raise ArgumentError("Hostname is mandatory") unless options[:host]
|
94
|
+
options = ({:ssl => false, :port => 8153, :username => nil, :password => nil, :pipeline_name => 'defaultPipeline'}).merge(options)
|
55
95
|
|
56
|
-
|
57
|
-
|
58
|
-
|
96
|
+
uri = "#{options[:ssl] ? 'https' : 'http'}://#{options[:host]}:#{options[:port]}/go/api/pipelines/#{options[:pipeline_name]}/schedule"
|
97
|
+
GoApiClient::HttpFetcher.new.post(uri)
|
98
|
+
end
|
59
99
|
end
|
60
100
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module GoApiClient
|
2
|
+
class Artifact
|
3
|
+
attr_accessor :base_uri, :src, :dest, :artifact_type
|
4
|
+
include GoApiClient::Helpers::SimpleAttributesSupport
|
5
|
+
|
6
|
+
def initialize(attributes)
|
7
|
+
super(attributes)
|
8
|
+
end
|
9
|
+
|
10
|
+
def as_zip_file_url
|
11
|
+
"#{File.join(base_uri, src)}.zip"
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def from(artifact_base_uri, artifact_element)
|
16
|
+
attributes = {
|
17
|
+
:base_uri => artifact_base_uri,
|
18
|
+
:src => artifact_element.attributes['src'].value,
|
19
|
+
:dest => artifact_element.attributes['dest'].value,
|
20
|
+
:artifact_type => artifact_element.attributes['type'].value,
|
21
|
+
}
|
22
|
+
|
23
|
+
self.new(attributes)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -20,7 +20,7 @@ module GoApiClient
|
|
20
20
|
|
21
21
|
http = Net::HTTP.new(uri.host, uri.port)
|
22
22
|
http.use_ssl = uri.scheme == 'https'
|
23
|
-
|
23
|
+
|
24
24
|
res = http.start do |http|
|
25
25
|
req = Net::HTTP::Get.new(uri.request_uri)
|
26
26
|
req.basic_auth(username, password) if username || password
|
@@ -34,6 +34,35 @@ module GoApiClient
|
|
34
34
|
res.error!
|
35
35
|
end
|
36
36
|
|
37
|
+
def post(url, options={})
|
38
|
+
uri = URI.parse(url)
|
39
|
+
|
40
|
+
password = options[:password] || uri.password || @password
|
41
|
+
username = options[:username] || uri.user || @username
|
42
|
+
params = options[:params] || {}
|
43
|
+
headers = options[:headers] || {}
|
44
|
+
|
45
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
46
|
+
http.use_ssl = uri.scheme == 'https'
|
47
|
+
|
48
|
+
req = Net::HTTP::Post.new(uri.request_uri)
|
49
|
+
|
50
|
+
headers.each do |header_name, value|
|
51
|
+
req[header_name] = value
|
52
|
+
end
|
53
|
+
|
54
|
+
req.basic_auth(username, password) if username || password
|
55
|
+
|
56
|
+
req.set_form_data(params)
|
57
|
+
res = http.request(req)
|
58
|
+
|
59
|
+
case res
|
60
|
+
when Net::HTTPSuccess
|
61
|
+
return res
|
62
|
+
end
|
63
|
+
res.error!
|
64
|
+
end
|
65
|
+
|
37
66
|
def get_response_body(url, options={})
|
38
67
|
get(url, options).body
|
39
68
|
end
|
data/lib/go_api_client/job.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module GoApiClient
|
2
2
|
class Job
|
3
|
-
attr_accessor :artifacts_uri, :console_log_url, :url, :identifier, :http_fetcher, :name
|
3
|
+
attr_accessor :artifacts_uri, :console_log_url, :url, :identifier, :http_fetcher, :name, :artifacts
|
4
4
|
|
5
5
|
PROPERTIES = {
|
6
6
|
:duration => :cruise_job_duration,
|
@@ -35,6 +35,10 @@ module GoApiClient
|
|
35
35
|
self.url = href_from(@root.xpath("./link[@rel='self']"))
|
36
36
|
self.identifier = @root.xpath('./id').first.content
|
37
37
|
self.name = @root.attributes['name'].value
|
38
|
+
self.artifacts = @root.xpath("./artifacts/artifact").collect do |artifact_element|
|
39
|
+
Artifact.from(self.artifacts_uri, artifact_element)
|
40
|
+
end
|
41
|
+
|
38
42
|
PROPERTIES.each do |variable, property_name|
|
39
43
|
property_value = @root.xpath("./properties/property[@name='#{property_name}']").first.content rescue nil
|
40
44
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<job name="rpm">
|
4
|
+
<link rel="self" href="https://ci.snap-ci.com/go/api/jobs/10360.xml"/>
|
5
|
+
<id><![CDATA[urn:x-go.studios.thoughtworks.com:job-id:Go-SaaS-Rails:898:Dist:1:rpm]]></id>
|
6
|
+
<pipeline name="Go-SaaS-Rails" counter="898" label="898"/>
|
7
|
+
<stage name="Dist" counter="1" href="https://ci.snap-ci.com/go/api/stages/10034.xml"/>
|
8
|
+
<result>Passed</result>
|
9
|
+
<state>Completed</state>
|
10
|
+
<properties>
|
11
|
+
<property name="cruise_agent"><![CDATA[ci-server]]></property>
|
12
|
+
<property name="cruise_job_duration"><![CDATA[402]]></property>
|
13
|
+
<property name="cruise_job_id"><![CDATA[10360]]></property>
|
14
|
+
<property name="cruise_job_result"><![CDATA[Passed]]></property>
|
15
|
+
<property name="cruise_pipeline_counter"><![CDATA[898]]></property>
|
16
|
+
<property name="cruise_pipeline_label"><![CDATA[898]]></property>
|
17
|
+
<property name="cruise_stage_counter"><![CDATA[1]]></property>
|
18
|
+
<property name="cruise_timestamp_01_scheduled"><![CDATA[2013-03-15T11:28:34Z]]></property>
|
19
|
+
<property name="cruise_timestamp_02_assigned"><![CDATA[2013-03-15T11:28:36Z]]></property>
|
20
|
+
<property name="cruise_timestamp_03_preparing"><![CDATA[2013-03-15T11:28:46Z]]></property>
|
21
|
+
<property name="cruise_timestamp_04_building"><![CDATA[2013-03-15T11:28:50Z]]></property>
|
22
|
+
<property name="cruise_timestamp_05_completing"><![CDATA[2013-03-15T11:35:29Z]]></property>
|
23
|
+
<property name="cruise_timestamp_06_completed"><![CDATA[2013-03-15T11:35:32Z]]></property>
|
24
|
+
</properties>
|
25
|
+
<agent uuid="fdcb5eaf-5a6e-428b-9907-cdcd7a149438"/>
|
26
|
+
<artifacts baseUri="https://ci.snap-ci.com/go/files/Go-SaaS-Rails/898/Dist/1/rpm" pathFromArtifactRoot="pipelines/Go-SaaS-Rails/898/Dist/1/rpm">
|
27
|
+
<artifact src="tmp" dest="" type="file"/>
|
28
|
+
<artifact src="log" dest="" type="directory"/>
|
29
|
+
</artifacts>
|
30
|
+
<resources/>
|
31
|
+
<environmentvariables>
|
32
|
+
<variable name="PATH"><![CDATA[/opt/local/ruby/1.9.2-p290/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin]]></variable>
|
33
|
+
<variable name="QMAKE"><![CDATA[/usr/bin/qmake-qt47]]></variable>
|
34
|
+
<variable name="COVERAGE"><![CDATA[true]]></variable>
|
35
|
+
</environmentvariables>
|
36
|
+
</job>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
class ArtifactTest < Test::Unit::TestCase
|
5
|
+
test "should construct the artifacts from the job xml" do
|
6
|
+
stub_request(:get, "http://localhost:8153/go/api/jobs/3.xml").to_return(:body => file_contents("jobs_3.xml"))
|
7
|
+
|
8
|
+
link = "http://localhost:8153/go/api/jobs/3.xml"
|
9
|
+
job = GoApiClient::Job.from(link)
|
10
|
+
assert_equal 2, job.artifacts.count
|
11
|
+
assert_equal "https://ci.snap-ci.com/go/files/Go-SaaS-Rails/898/Dist/1/rpm/tmp.zip", job.artifacts.first.as_zip_file_url
|
12
|
+
assert_equal "https://ci.snap-ci.com/go/files/Go-SaaS-Rails/898/Dist/1/rpm/log.zip", job.artifacts.last.as_zip_file_url
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -3,30 +3,38 @@ require "test_helper"
|
|
3
3
|
module GoApiClient
|
4
4
|
class BuildingTest < Test::Unit::TestCase
|
5
5
|
|
6
|
-
test "should report that Go is building if atleast 1
|
6
|
+
test "should report that Go is building if atleast 1 stage in specified pipeline is building" do
|
7
7
|
feed = %Q{
|
8
8
|
<?xml version="1.0" encoding="utf-8"?>
|
9
9
|
<Projects>
|
10
10
|
<Project name="defaultPipeline :: RailsTests" activity="Building" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/pipelines/defaultPipeline/5/RailsTests/1" />
|
11
|
-
<Project name="defaultPipeline ::
|
11
|
+
<Project name="defaultPipeline :: SmokeTests" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/pipelines/defaultPipeline/5/RailsTests/1" />
|
12
|
+
|
13
|
+
<Project name="anotherPipeline :: RailsTests" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/pipelines/defaultPipeline/5/RailsTests/1" />
|
14
|
+
<Project name="anotherPipeline :: SmokeTests" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/pipelines/defaultPipeline/5/RailsTests/1" />
|
12
15
|
</Projects>
|
13
16
|
}
|
14
17
|
stub_request(:get, "http://go-server.2.project:8153/go/cctray.xml").
|
15
18
|
to_return(:body => feed)
|
16
|
-
assert
|
19
|
+
assert GoApiClient.build_in_progress?(:host => 'go-server.2.project', :pipeline_name => 'defaultPipeline')
|
20
|
+
assert_false GoApiClient.build_in_progress?(:host => 'go-server.2.project', :pipeline_name => 'anotherPipeline')
|
17
21
|
end
|
18
22
|
|
19
|
-
test "should report that Go is sleeping if all
|
23
|
+
test "should report that Go is sleeping if all stages in specified pipeline are sleeping" do
|
20
24
|
feed = %Q{
|
21
25
|
<?xml version="1.0" encoding="utf-8"?>
|
22
26
|
<Projects>
|
23
27
|
<Project name="defaultPipeline :: RailsTests" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/pipelines/defaultPipeline/5/RailsTests/1" />
|
24
|
-
<Project name="defaultPipeline ::
|
28
|
+
<Project name="defaultPipeline :: SmokeTests" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/pipelines/defaultPipeline/5/RailsTests/1" />
|
29
|
+
|
30
|
+
<Project name="anotherPipeline :: RailsTests" activity="Building" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/pipelines/defaultPipeline/5/RailsTests/1" />
|
31
|
+
<Project name="anotherPipeline :: SmokeTests" activity="Sleeping" lastBuildStatus="Success" lastBuildLabel="4" lastBuildTime="2012-07-19T10:03:04" webUrl="http://go-server.2.project:8153/go/pipelines/defaultPipeline/5/RailsTests/1" />
|
25
32
|
</Projects>
|
26
33
|
}
|
27
34
|
stub_request(:get, "http://go-server.2.project:8153/go/cctray.xml").
|
28
35
|
to_return(:body => feed)
|
29
|
-
|
36
|
+
assert GoApiClient.build_finished?(:host => 'go-server.2.project', :pipeline_name => 'defaultPipeline')
|
37
|
+
assert_false GoApiClient.build_finished?(:host => 'go-server.2.project', :pipeline_name => 'anotherPipeline')
|
30
38
|
end
|
31
39
|
|
32
40
|
test "should handle empty feeds" do
|
@@ -34,5 +42,6 @@ module GoApiClient
|
|
34
42
|
to_return(:body => nil)
|
35
43
|
assert_false GoApiClient.build_in_progress?(:host => 'go-server.2.project')
|
36
44
|
end
|
45
|
+
|
37
46
|
end
|
38
47
|
end
|
@@ -13,9 +13,9 @@ module GoApiClient
|
|
13
13
|
|
14
14
|
runs = GoApiClient.runs(:host => 'go-server.2.project')
|
15
15
|
|
16
|
-
assert_equal runs
|
16
|
+
assert_equal runs.pipelines.collect(&:counter).sort, runs.pipelines.collect(&:counter)
|
17
17
|
|
18
|
-
runs
|
18
|
+
runs.pipelines.each do |pipeline|
|
19
19
|
assert_equal pipeline.stages.collect(&:completed_at).sort, pipeline.stages.collect(&:completed_at)
|
20
20
|
end
|
21
21
|
end
|
@@ -29,8 +29,8 @@ module GoApiClient
|
|
29
29
|
|
30
30
|
stub_request(:get, "http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml").to_return(:body => file_contents("stages.xml"))
|
31
31
|
runs = GoApiClient.runs(:host => "localhost", :port => 8153)
|
32
|
-
pipelines = runs
|
33
|
-
assert_equal "http://localhost:8153/go/pipelines/defaultPipeline/1/Acceptance/1", runs
|
32
|
+
pipelines = runs.pipelines
|
33
|
+
assert_equal "http://localhost:8153/go/pipelines/defaultPipeline/1/Acceptance/1", runs.latest_atom_entry_id
|
34
34
|
stages = pipelines.first.stages
|
35
35
|
|
36
36
|
assert_equal 1, pipelines.count
|
@@ -38,7 +38,7 @@ module GoApiClient
|
|
38
38
|
|
39
39
|
assert_equal "http://localhost:8153/go/api/stages/1.xml", stages.first.url
|
40
40
|
assert_equal "http://localhost:8153/go/api/stages/2.xml", stages.last.url
|
41
|
-
|
41
|
+
|
42
42
|
assert_equal 1, stages.first.counter
|
43
43
|
assert_equal 1, stages.last.counter
|
44
44
|
|
@@ -69,7 +69,7 @@ module GoApiClient
|
|
69
69
|
stub_request(:get, "http://localhost:8153/go/api/pipelines/defaultPipeline/stages.xml").to_return(:body => file_contents("stages_empty.xml"))
|
70
70
|
runs = GoApiClient.runs(:host => "localhost", :port => 8153)
|
71
71
|
|
72
|
-
assert runs
|
72
|
+
assert runs.pipelines.empty?
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
class ScheduleTest < Test::Unit::TestCase
|
5
|
+
test "should schedule a build specified" do
|
6
|
+
stub_request(:post, "http://go-server.2.project:8153/go/api/pipelines/defaultPipeline/schedule")
|
7
|
+
GoApiClient.schedule_pipeline(:host => 'go-server.2.project')
|
8
|
+
|
9
|
+
assert_requested(:post, "http://go-server.2.project:8153/go/api/pipelines/defaultPipeline/schedule", :body => '')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: webmock
|
@@ -105,12 +105,14 @@ extra_rdoc_files: []
|
|
105
105
|
files:
|
106
106
|
- .gitignore
|
107
107
|
- .rvmrc
|
108
|
+
- .yardopts
|
108
109
|
- Gemfile
|
109
110
|
- Gemfile.lock
|
110
111
|
- README.textile
|
111
112
|
- Rakefile
|
112
113
|
- go_api_client.gemspec
|
113
114
|
- lib/go_api_client.rb
|
115
|
+
- lib/go_api_client/artifact.rb
|
114
116
|
- lib/go_api_client/atom.rb
|
115
117
|
- lib/go_api_client/atom/author.rb
|
116
118
|
- lib/go_api_client/atom/entry.rb
|
@@ -141,6 +143,7 @@ files:
|
|
141
143
|
- test/fixtures/job_2_console.log.txt
|
142
144
|
- test/fixtures/jobs_1.xml
|
143
145
|
- test/fixtures/jobs_2.xml
|
146
|
+
- test/fixtures/jobs_3.xml
|
144
147
|
- test/fixtures/jobs_with_no_properties.xml
|
145
148
|
- test/fixtures/ordering/go/api/jobs/1.xml
|
146
149
|
- test/fixtures/ordering/go/api/jobs/10.xml
|
@@ -176,6 +179,7 @@ files:
|
|
176
179
|
- test/fixtures/stages_1.xml
|
177
180
|
- test/fixtures/stages_2.xml
|
178
181
|
- test/fixtures/stages_empty.xml
|
182
|
+
- test/go_api_client/artifact_test.rb
|
179
183
|
- test/go_api_client/atom/author_test.rb
|
180
184
|
- test/go_api_client/atom/entry_test.rb
|
181
185
|
- test/go_api_client/atom/feed_page_test.rb
|
@@ -186,6 +190,7 @@ files:
|
|
186
190
|
- test/go_api_client/pipeline_test.rb
|
187
191
|
- test/go_api_client/stage_test.rb
|
188
192
|
- test/go_api_client/user_test.rb
|
193
|
+
- test/schedule_test.rb
|
189
194
|
- test/test_helper.rb
|
190
195
|
homepage: https://github.com/ThoughtWorksInc/go-api-client
|
191
196
|
licenses: []
|
@@ -199,12 +204,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
204
|
- - ! '>='
|
200
205
|
- !ruby/object:Gem::Version
|
201
206
|
version: '0'
|
207
|
+
segments:
|
208
|
+
- 0
|
209
|
+
hash: 4219299069108051820
|
202
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
211
|
none: false
|
204
212
|
requirements:
|
205
213
|
- - ! '>='
|
206
214
|
- !ruby/object:Gem::Version
|
207
215
|
version: '0'
|
216
|
+
segments:
|
217
|
+
- 0
|
218
|
+
hash: 4219299069108051820
|
208
219
|
requirements: []
|
209
220
|
rubyforge_project: go_api_client
|
210
221
|
rubygems_version: 1.8.25
|
@@ -228,6 +239,7 @@ test_files:
|
|
228
239
|
- test/fixtures/job_2_console.log.txt
|
229
240
|
- test/fixtures/jobs_1.xml
|
230
241
|
- test/fixtures/jobs_2.xml
|
242
|
+
- test/fixtures/jobs_3.xml
|
231
243
|
- test/fixtures/jobs_with_no_properties.xml
|
232
244
|
- test/fixtures/ordering/go/api/jobs/1.xml
|
233
245
|
- test/fixtures/ordering/go/api/jobs/10.xml
|
@@ -263,6 +275,7 @@ test_files:
|
|
263
275
|
- test/fixtures/stages_1.xml
|
264
276
|
- test/fixtures/stages_2.xml
|
265
277
|
- test/fixtures/stages_empty.xml
|
278
|
+
- test/go_api_client/artifact_test.rb
|
266
279
|
- test/go_api_client/atom/author_test.rb
|
267
280
|
- test/go_api_client/atom/entry_test.rb
|
268
281
|
- test/go_api_client/atom/feed_page_test.rb
|
@@ -273,4 +286,5 @@ test_files:
|
|
273
286
|
- test/go_api_client/pipeline_test.rb
|
274
287
|
- test/go_api_client/stage_test.rb
|
275
288
|
- test/go_api_client/user_test.rb
|
289
|
+
- test/schedule_test.rb
|
276
290
|
- test/test_helper.rb
|