Module: Capistrano::Deploy::Strategy::JenkinsArtifact::ApiClient
- Defined in:
- lib/capistrano/recipes/deploy/strategy/jenkins_artifact.rb
Class Method Summary collapse
-
.get_last_successful_build(jenkins_origin, dir_name) ⇒ Object
jenkins_origin: URI => Maybe[$parsed_body: Hash].
Class Method Details
.get_last_successful_build(jenkins_origin, dir_name) ⇒ Object
jenkins_origin: URI
> Maybe[$parsed_body: Hash]
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/capistrano/recipes/deploy/strategy/jenkins_artifact.rb', line 11 def self.get_last_successful_build(jenkins_origin, dir_name) uri = jenkins_origin.clone uri.path += "/job/#{URI.encode_www_form_component(dir_name)}/lastSuccessfulBuild/api/json" req = Net::HTTP::Get.new(uri.path) res = Net::HTTP.start(uri.host, uri.port) {|session| session.use_ssl = uri.scheme == 'https' session.request(req) } case res when Net::HTTPSuccess if /\Aapplication\/json\b/ === (res.content_type || '') JSON.parse(res.body) end end end |