travis-api/lib/travis/api/app/endpoint/jobs.rb
Piotr Sarnacki a565522f41 Redirect to full amazon url
Amazon can't work properly with SSL and CNAME for subdomains. For now we
can use full amazon url.
2013-01-28 03:43:28 +01:00

33 lines
774 B
Ruby

require 'travis/api/app'
class Travis::Api::App
class Endpoint
class Jobs < Endpoint
get '/' do
respond_with service(:find_jobs, params)
end
get '/:id' do
respond_with service(:find_job, params)
end
get '/:job_id/log' do
resource = service(:find_artifact, params).run
if !resource || resource.archived?
redirect archive_url("/jobs/#{params[:job_id]}/log.txt")
else
respond_with resource
end
end
def archive_url(path)
"https://s3.amazonaws.com/#{hostname('archive')}#{path}"
end
def hostname(name)
"#{name}#{'-staging' if Travis.env == 'staging'}.#{Travis.config.host.split('.')[-2, 2].join('.')}"
end
end
end
end