diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-03-03 12:51:23 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-03-06 10:04:04 +0100 |
commit | dd2409119183578b12148654899e8e29c6105572 (patch) | |
tree | 980ed2434b784e3da7c981e5d3c19a4701f3a56d /app | |
parent | d1b59476df4cbc84830bdf617d915c066fcb0f60 (diff) | |
download | gitlab-ce-dd2409119183578b12148654899e8e29c6105572.tar.gz |
Add support for blocking actions to CI/CD pipeline
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/pipeline.rb | 5 | ||||
-rw-r--r-- | app/models/commit_status.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/has_status.rb | 5 | ||||
-rw-r--r-- | app/services/ci/process_pipeline_service.rb | 2 |
4 files changed, 11 insertions, 3 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 80e11a5b58f..b0ca3e9c189 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -49,6 +49,10 @@ module Ci transition any - [:canceled] => :canceled end + event :block do + transition any - [:blocked] => :blocked + end + # IMPORTANT # Do not add any operations to this state_machine # Create a separate worker for each new operation @@ -321,6 +325,7 @@ module Ci when 'failed' then drop when 'canceled' then cancel when 'skipped' then skip + when 'blocked' then block end end end diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 3ef07ffd0da..9cdabf24677 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -86,7 +86,7 @@ class CommitStatus < ActiveRecord::Base commit_status.run_after_commit do pipeline.try do |pipeline| - if complete? + if complete? || blocked? PipelineProcessWorker.perform_async(pipeline.id) else PipelineUpdateWorker.perform_async(pipeline.id) diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index 012407a72d8..2b559d8e828 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -2,11 +2,12 @@ module HasStatus extend ActiveSupport::Concern DEFAULT_STATUS = 'created'.freeze + BLOCKED_STATUS = 'blocked'.freeze AVAILABLE_STATUSES = %w[created pending running success failed canceled skipped blocked].freeze STARTED_STATUSES = %w[running success failed skipped].freeze ACTIVE_STATUSES = %w[pending running blocked].freeze COMPLETED_STATUSES = %w[success failed canceled skipped].freeze - ORDERED_STATUSES = %w[failed pending running canceled success skipped].freeze + ORDERED_STATUSES = %w[blocked failed pending running canceled success skipped].freeze class_methods do def status_sql @@ -28,7 +29,7 @@ module HasStatus WHEN (#{builds})=(#{success})+(#{skipped}) THEN 'success' WHEN (#{builds})=(#{success})+(#{skipped})+(#{canceled}) THEN 'canceled' WHEN (#{builds})=(#{created})+(#{skipped})+(#{pending}) THEN 'pending' - WHEN (#{running})+(#{pending})+(#{created})>0 THEN 'running' + WHEN (#{running})+(#{pending})>0 THEN 'running' WHEN (#{blocked})>0 THEN 'blocked' ELSE 'failed' END)" diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb index 24428d9afae..30fccbddc33 100644 --- a/app/services/ci/process_pipeline_service.rb +++ b/app/services/ci/process_pipeline_service.rb @@ -22,6 +22,8 @@ module Ci def process_stage(index) current_status = status_for_prior_stages(index) + return if HasStatus::BLOCKED_STATUS == current_status + if HasStatus::COMPLETED_STATUSES.include?(current_status) created_builds_in_stage(index).select do |build| Gitlab::OptimisticLocking.retry_lock(build) do |subject| |