Module: GoApiClient
- Defined in:
- lib/go_api_client.rb,
lib/go_api_client/job.rb,
lib/go_api_client/user.rb,
lib/go_api_client/stage.rb,
lib/go_api_client/commit.rb,
lib/go_api_client/engine.rb,
lib/go_api_client/logger.rb,
lib/go_api_client/version.rb,
lib/go_api_client/artifact.rb,
lib/go_api_client/pipeline.rb,
lib/go_api_client/atom/feed.rb,
lib/go_api_client/atom/entry.rb,
lib/go_api_client/atom/author.rb,
lib/go_api_client/http_fetcher.rb,
lib/go_api_client/atom/feed_page.rb,
lib/go_api_client/helpers/simple_attribute_support.rb
Defined Under Namespace
Modules: Atom, Helpers, Version Classes: Artifact, Commit, Engine, HttpFetcher, Job, LastRun, Pipeline, Stage, User
Class Attribute Summary collapse
-
.logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
- .all_runs(options = {}) ⇒ Object
-
.build_finished?(options) ⇒ Boolean
Answers if a build is in completed.
-
.build_in_progress?(options = {}) ⇒ Boolean
Answers if a build is in progress.
-
.runs(options = {}) ⇒ LastRun
Connects to the a go server via the Atom Feed API and fetches entire the pipeline history for that pipeline.
-
.schedule_pipeline(options) ⇒ Object
Schedule a particular pipeline with the latest available materials.
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/go_api_client/logger.rb', line 5 def logger @logger end |
Class Method Details
.all_runs(options = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/go_api_client.rb', line 64 def all_runs(={}) = ({:ssl => false, :host => 'localhost', :port => 8153, :username => nil, :password => nil}).merge() http_fetcher = GoApiClient::HttpFetcher.new(:username => [:username], :password => [:password]) feed_url = "#{[:ssl] ? 'https' : 'http'}://#{[:host]}:#{[:port]}/go/api/pipelines.xml" feed = GoApiClient::Atom::Feed.new(feed_url, nil) feed = feed.fetch_all!(http_fetcher) feed.inject({}) do |memo, (href, entries)| memo[href] = construct_last_run(entries, http_fetcher, nil) memo end end |
.build_finished?(options) ⇒ Boolean
Answers if a build is in completed. For the list of supported connection options see #runs
89 90 91 |
# File 'lib/go_api_client.rb', line 89 def build_finished?() !build_in_progress?() end |
.build_in_progress?(options = {}) ⇒ Boolean
Answers if a build is in progress. For the list of supported connection options see #runs
78 79 80 81 82 83 84 85 |
# File 'lib/go_api_client.rb', line 78 def build_in_progress?(={}) raise ArgumentError("Hostname is mandatory") unless [:host] = ({:ssl => false, :port => 8153, :username => nil, :password => nil, :pipeline_name => 'defaultPipeline'}).merge() http_fetcher = GoApiClient::HttpFetcher.new(:username => [:username], :password => [:password]) url = "#{[:ssl] ? 'https' : 'http'}://#{[:host]}:#{[:port]}/go/cctray.xml" doc = Nokogiri::XML(http_fetcher.get!(url)) doc.css("Project[activity='Building'][name^='#{[:pipeline_name]} ::']").count > 0 end |
.runs(options = {}) ⇒ LastRun
Connects to the a go server via the Atom Feed API and fetches entire the pipeline history for that pipeline. Since this this is a wrapper around an atom feed, it is important to remember the last atom feed entry that was seen in order to prevent crawling the entire atom feed over and over again and slow the process down.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/go_api_client.rb', line 52 def runs(={}) = ({:ssl => false, :host => 'localhost', :port => 8153, :username => nil, :password => nil, :latest_atom_entry_id => nil}).merge() http_fetcher = GoApiClient::HttpFetcher.new(:username => [:username], :password => [:password]) pipeline_name = [:pipeline_name] || "defaultPipeline" feed_url = "#{[:ssl] ? 'https' : 'http'}://#{[:host]}:#{[:port]}/go/api/pipelines/#{pipeline_name}/stages.xml" feed = GoApiClient::Atom::Feed.new(feed_url, [:latest_atom_entry_id]) feed.fetch!(http_fetcher) return construct_last_run(feed, http_fetcher, [:latest_atom_entry_id]) end |
.schedule_pipeline(options) ⇒ Object
Schedule a particular pipeline with the latest available materials.
94 95 96 97 98 99 100 |
# File 'lib/go_api_client.rb', line 94 def schedule_pipeline() raise ArgumentError("Hostname is mandatory") unless [:host] = ({:ssl => false, :port => 8153, :username => nil, :password => nil, :pipeline_name => 'defaultPipeline'}).merge() uri = "#{[:ssl] ? 'https' : 'http'}://#{[:host]}:#{[:port]}/go/api/pipelines/#{[:pipeline_name]}/schedule" GoApiClient::HttpFetcher.new.post!(uri) end |