add 流水线停止api

This commit is contained in:
xxq250 2025-07-29 10:33:56 +08:00
parent f4248ec14b
commit 41515575f1
2 changed files with 12 additions and 0 deletions

View File

@ -58,4 +58,15 @@ class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::B
redirect_to file_path redirect_to file_path
end end
def cancel
return render_error("请输入正确的流水线记录ID") if params[:run_id].blank?
http = Gitea::Api::Hat::Http.new($gitea_hat_client.config)
gitea_result = http.post("/repos/#{@project&.owner&.login}/#{@project&.identifier}/actions/runs/#{params[:run_id]}/cancel") rescue nil
if gitea_result
render_ok
else
render_error("停止流水线任务失败")
end
end
end end

View File

@ -193,6 +193,7 @@ defaults format: :json do
post '/jobs/:job', to: 'runs#job_show' post '/jobs/:job', to: 'runs#job_show'
post '/rerun', to: 'runs#rerun' post '/rerun', to: 'runs#rerun'
post '/jobs/:job/rerun', to: 'runs#job_rerun' post '/jobs/:job/rerun', to: 'runs#job_rerun'
post '/jobs/:job/cancel', to: 'runs#cancel'
get '/jobs/:job/logs', to: 'runs#job_logs' get '/jobs/:job/logs', to: 'runs#job_logs'
end end
end end