diff options
Diffstat (limited to 'lib/gitlab/ci/pipeline')
-rw-r--r-- | lib/gitlab/ci/pipeline/chain/seed.rb | 15 | ||||
-rw-r--r-- | lib/gitlab/ci/pipeline/seed/build.rb | 36 | ||||
-rw-r--r-- | lib/gitlab/ci/pipeline/seed/stage.rb | 2 |
3 files changed, 33 insertions, 20 deletions
diff --git a/lib/gitlab/ci/pipeline/chain/seed.rb b/lib/gitlab/ci/pipeline/chain/seed.rb index 66fc6741252..ef7447fa83d 100644 --- a/lib/gitlab/ci/pipeline/chain/seed.rb +++ b/lib/gitlab/ci/pipeline/chain/seed.rb @@ -10,10 +10,7 @@ module Gitlab def perform! raise ArgumentError, 'missing YAML processor result' unless @command.yaml_processor_result - - if ::Feature.enabled?(:ci_workflow_rules_variables, pipeline.project, default_enabled: :yaml) - raise ArgumentError, 'missing workflow rules result' unless @command.workflow_rules_result - end + raise ArgumentError, 'missing workflow rules result' unless @command.workflow_rules_result # Allocate next IID. This operation must be outside of transactions of pipeline creations. pipeline.ensure_project_iid! @@ -51,13 +48,9 @@ module Gitlab end def root_variables - if ::Feature.enabled?(:ci_workflow_rules_variables, pipeline.project, default_enabled: :yaml) - ::Gitlab::Ci::Variables::Helpers.merge_variables( - @command.yaml_processor_result.root_variables, @command.workflow_rules_result.variables - ) - else - @command.yaml_processor_result.root_variables - end + ::Gitlab::Ci::Variables::Helpers.merge_variables( + @command.yaml_processor_result.root_variables, @command.workflow_rules_result.variables + ) end end end diff --git a/lib/gitlab/ci/pipeline/seed/build.rb b/lib/gitlab/ci/pipeline/seed/build.rb index 299b27a5f13..54d92745992 100644 --- a/lib/gitlab/ci/pipeline/seed/build.rb +++ b/lib/gitlab/ci/pipeline/seed/build.rb @@ -11,11 +11,16 @@ module Gitlab delegate :dig, to: :@seed_attributes - def initialize(context, attributes, previous_stages) + def initialize(context, attributes, previous_stages, current_stage) @context = context @pipeline = context.pipeline @seed_attributes = attributes - @previous_stages = previous_stages + @stages_for_needs_lookup = if Feature.enabled?(:ci_same_stage_job_needs, @pipeline.project, default_enabled: :yaml) + (previous_stages + [current_stage]).compact + else + previous_stages + end + @needs_attributes = dig(:needs_attributes) @resource_group_key = attributes.delete(:resource_group_key) @job_variables = @seed_attributes.delete(:job_variables) @@ -67,6 +72,7 @@ module Gitlab .deep_merge(rules_attributes) .deep_merge(allow_failure_criteria_attributes) .deep_merge(@cache.cache_attributes) + .deep_merge(runner_tags) end def bridge? @@ -148,14 +154,18 @@ module Gitlab @needs_attributes.flat_map do |need| next if need[:optional] - result = @previous_stages.any? do |stage| - stage.seeds_names.include?(need[:name]) - end + result = need_present?(need) - "'#{name}' job needs '#{need[:name]}' job, but it was not added to the pipeline" unless result + "'#{name}' job needs '#{need[:name]}' job, but '#{need[:name]}' is not in any previous stage" unless result end.compact end + def need_present?(need) + @stages_for_needs_lookup.any? do |stage| + stage.seeds_names.include?(need[:name]) + end + end + def max_needs_allowed @pipeline.project.actual_limits.ci_needs_size_limit end @@ -202,6 +212,16 @@ module Gitlab end end + def runner_tags + { tag_list: evaluate_runner_tags }.compact + end + + def evaluate_runner_tags + @seed_attributes[:tag_list]&.map do |tag| + ExpandVariables.expand_existing(tag, evaluate_context.variables) + end + end + # If a job uses `allow_failure:exit_codes` and `rules:allow_failure` # we need to prevent the exit codes from being persisted because they # would break the behavior defined by `rules:allow_failure`. @@ -213,8 +233,6 @@ module Gitlab end def recalculate_yaml_variables! - return unless ::Feature.enabled?(:ci_workflow_rules_variables, @pipeline.project, default_enabled: :yaml) - @seed_attributes[:yaml_variables] = Gitlab::Ci::Variables::Helpers.inherit_yaml_variables( from: @context.root_variables, to: @job_variables, inheritance: @root_variables_inheritance ) @@ -224,3 +242,5 @@ module Gitlab end end end + +Gitlab::Ci::Pipeline::Seed::Build.prepend_mod_with('Gitlab::Ci::Pipeline::Seed::Build') diff --git a/lib/gitlab/ci/pipeline/seed/stage.rb b/lib/gitlab/ci/pipeline/seed/stage.rb index c988ea10e41..018fb260986 100644 --- a/lib/gitlab/ci/pipeline/seed/stage.rb +++ b/lib/gitlab/ci/pipeline/seed/stage.rb @@ -17,7 +17,7 @@ module Gitlab @previous_stages = previous_stages @builds = attributes.fetch(:builds).map do |attributes| - Seed::Build.new(context, attributes, previous_stages) + Seed::Build.new(context, attributes, previous_stages, self) end end |