Use V3 services for debug route
This commit is contained in:
parent
8490e9f9ce
commit
2196acb36d
|
@ -124,16 +124,6 @@ class Travis::Api::App
|
|||
end
|
||||
end
|
||||
|
||||
post "/:job_id/debug" do
|
||||
Travis.logger.debug "Reached endpoint"
|
||||
job = service(:find_job, params).run
|
||||
Travis.logger.debug "found job: #{job}"
|
||||
cfg = job.config
|
||||
cfg.merge! debug_data
|
||||
job.save!
|
||||
status 200
|
||||
end
|
||||
|
||||
def archive_url(path)
|
||||
"https://s3.amazonaws.com/#{hostname('archive')}#{path}"
|
||||
end
|
||||
|
|
|
@ -9,5 +9,9 @@ module Travis::API::V3
|
|||
def restart?
|
||||
write?
|
||||
end
|
||||
|
||||
def debug?
|
||||
write?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,6 +34,7 @@ module Travis::API::V3
|
|||
|
||||
post :cancel, '/cancel'
|
||||
post :restart, '/restart'
|
||||
post :debug, '/debug'
|
||||
end
|
||||
|
||||
resource :organization do
|
||||
|
|
19
lib/travis/api/v3/services/job/debug.rb
Normal file
19
lib/travis/api/v3/services/job/debug.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
module Travis::API::V3
|
||||
class Services::Job::Debug < Service
|
||||
|
||||
def run
|
||||
raise LoginRequired unless access_control.logged_in? or access_control.full_access?
|
||||
raise NotFound unless job = find(:job)
|
||||
access_control.permissions(job).debug!
|
||||
|
||||
Travis.logger.debug "Reached endpoint"
|
||||
job = service(:find_job, params).run
|
||||
Travis.logger.debug "found job: #{job}"
|
||||
cfg = job.config
|
||||
cfg.merge! debug_data
|
||||
job.save!
|
||||
|
||||
accepted(job: job, state_change: :created)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user