diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-08-02 20:31:01 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-08-02 21:31:17 +0300 |
commit | 593490e5ac6ec5a92fdcc9b82eebbb455ea6cf48 (patch) | |
tree | 56dd0ba4cbb8876e96cfab57a22c186e3fff418d /app/services | |
parent | 8156e77c1a25bc6050e5036fa3bbfd29201a6d5c (diff) |
Extend PipelineProcessWorker to accept a list of builds
This changes used worker from `BuildProcessWorker`
to `PipelineProcessWorker` to make pipeline
processing much simpler. We process `pipeline_id`,
based on some triggers.
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/ci/process_pipeline_service.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb index e46615bcf75..184d5321020 100644 --- a/app/services/ci/process_pipeline_service.rb +++ b/app/services/ci/process_pipeline_service.rb @@ -4,7 +4,7 @@ module Ci class ProcessPipelineService < BaseService attr_reader :pipeline - def execute(pipeline, trigger_build_name = nil) + def execute(pipeline, trigger_build_ids = nil) @pipeline = pipeline update_retried @@ -16,7 +16,7 @@ module Ci # we evaluate dependent needs, # only when the another job has finished - success = process_builds_with_needs(trigger_build_name) || success + success = process_builds_with_needs(trigger_build_ids) || success @pipeline.update_status @@ -40,12 +40,18 @@ module Ci end end - def process_builds_with_needs(trigger_build_name) - return false unless trigger_build_name + def process_builds_with_needs(trigger_build_ids) + return false unless trigger_build_ids.present? return false unless Feature.enabled?(:ci_dag_support, project) + # rubocop: disable CodeReuse/ActiveRecord + trigger_build_names = pipeline.statuses + .where(id: trigger_build_ids) + .select(:name) + # rubocop: enable CodeReuse/ActiveRecord + created_processables - .with_needs(trigger_build_name) + .with_needs(trigger_build_names) .find_each .map(&method(:process_build_with_needs)) .any? |