diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-10-17 16:50:39 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-10-17 18:53:08 +0300 |
commit | 5ff3c2dec9efe827d28d81f5b82aefbb37461b82 (patch) | |
tree | b864006e9c713dcc900d13b45d8188e715acb6a4 | |
parent | b3d380ec7dca09af5fe21dfe89c14e77d65bf308 (diff) |
Allow all failed commit builds to be retried.
-rw-r--r-- | app/controllers/projects/commit_controller.rb | 10 | ||||
-rw-r--r-- | app/views/projects/commit/ci.html.haml | 3 | ||||
-rw-r--r-- | config/routes.rb | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 885d3d03c19..5a3ed503899 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -39,6 +39,16 @@ class Projects::CommitController < Projects::ApplicationController redirect_to ci_namespace_project_commit_path(project.namespace, project, commit.sha) end + def retry_builds + @ci_commit = @project.ci_commit(@commit.sha) + @ci_commit.builds.latest.failed.each do |build| + if build.retryable? + Ci::Build.retry(build) + end + end + + redirect_to ci_namespace_project_commit_path(project.namespace, project, commit.sha) + end def branches @branches = @project.repository.branch_names_contains(commit.id) diff --git a/app/views/projects/commit/ci.html.haml b/app/views/projects/commit/ci.html.haml index 6914cb9d876..2c535eb1867 100644 --- a/app/views/projects/commit/ci.html.haml +++ b/app/views/projects/commit/ci.html.haml @@ -26,6 +26,9 @@ - if @ci_project && current_user && can?(current_user, :manage_builds, @project) + - if @ci_commit.builds.latest.failed.any?(&:retryable?) + = link_to "Retry failed", retry_ci_namespace_project_commit_path(@project.namespace, @project, @commit.sha), class: 'btn btn-xs btn-primary', method: :post + - if @ci_commit.builds.running_or_pending.any? = link_to "Cancel all", cancel_builds_namespace_project_commit_path(@project.namespace, @project, @commit.sha), class: 'btn btn-xs btn-danger' diff --git a/config/routes.rb b/config/routes.rb index 3dbe2c4dfcc..e8d4119651c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -475,6 +475,7 @@ Gitlab::Application.routes.draw do get :branches get :ci get :cancel_builds + post :retry_builds end end |