Commit ef6fe42e authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-cancelable-retryable' into 'master'

Fix cancelability and retriablity of pipeline with generic statuses

Currently it's not possible to cancel or retry generic status since this is external thing to GitLab.

This fixes shown actions of pipelines containing only these actions.


See merge request !4380
parents 4581e71c 57992f3d
...@@ -20,6 +20,7 @@ v 8.9.0 (unreleased) ...@@ -20,6 +20,7 @@ v 8.9.0 (unreleased)
- Todos will display target state if issuable target is 'Closed' or 'Merged' - Todos will display target state if issuable target is 'Closed' or 'Merged'
- Fix bug when sorting issues by milestone due date and filtering by two or more labels - Fix bug when sorting issues by milestone due date and filtering by two or more labels
- Remove 'main language' feature - Remove 'main language' feature
- Pipelines can be canceled only when there are running builds
- Projects pending deletion will render a 404 page - Projects pending deletion will render a 404 page
- Measure queue duration between gitlab-workhorse and Rails - Measure queue duration between gitlab-workhorse and Rails
- Make authentication service for Container Registry to be compatible with < Docker 1.11 - Make authentication service for Container Registry to be compatible with < Docker 1.11
......
...@@ -66,6 +66,10 @@ module Ci ...@@ -66,6 +66,10 @@ module Ci
end end
end end
def cancelable?
builds.running_or_pending.any?
end
def cancel_running def cancel_running
builds.running_or_pending.each(&:cancel) builds.running_or_pending.each(&:cancel)
end end
......
...@@ -63,9 +63,9 @@ ...@@ -63,9 +63,9 @@
%span #{build.name} %span #{build.name}
- if can?(current_user, :update_pipeline, @project) - if can?(current_user, :update_pipeline, @project)
- if commit.retryable? && commit.builds.failed.any? - if commit.retryable?
= link_to retry_namespace_project_pipeline_path(@project.namespace, @project, commit.id), class: 'btn has-tooltip', title: "Retry", method: :post do = link_to retry_namespace_project_pipeline_path(@project.namespace, @project, commit.id), class: 'btn has-tooltip', title: "Retry", method: :post do
= icon("repeat") = icon("repeat")
- if commit.active? - if commit.cancelable?
= link_to cancel_namespace_project_pipeline_path(@project.namespace, @project, commit.id), class: 'btn btn-remove has-tooltip', title: "Cancel", method: :post do = link_to cancel_namespace_project_pipeline_path(@project.namespace, @project, commit.id), class: 'btn btn-remove has-tooltip', title: "Cancel", method: :post do
= icon("remove") = icon("remove")
...@@ -62,6 +62,36 @@ describe "Pipelines" do ...@@ -62,6 +62,36 @@ describe "Pipelines" do
end end
end end
context 'for generic statuses' do
context 'when running' do
let!(:running) { create(:generic_commit_status, status: 'running', commit: pipeline, stage: 'test') }
before { visit namespace_project_pipelines_path(project.namespace, project) }
it 'not be cancelable' do
expect(page).not_to have_link('Cancel')
end
it 'pipeline is running' do
expect(page).to have_selector('.ci-running')
end
end
context 'when failed' do
let!(:running) { create(:generic_commit_status, status: 'failed', commit: pipeline, stage: 'test') }
before { visit namespace_project_pipelines_path(project.namespace, project) }
it 'not be retryable' do
expect(page).not_to have_link('Retry')
end
it 'pipeline is failed' do
expect(page).to have_selector('.ci-failed')
end
end
end
context 'downloadable pipelines' do context 'downloadable pipelines' do
context 'with artifacts' do context 'with artifacts' do
let!(:with_artifacts) { create(:ci_build, :artifacts, :success, commit: pipeline, name: 'rspec tests', stage: 'test') } let!(:with_artifacts) { create(:ci_build, :artifacts, :success, commit: pipeline, name: 'rspec tests', stage: 'test') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment