diff options
Diffstat (limited to 'app/graphql/types/ci')
-rw-r--r-- | app/graphql/types/ci/stage_type.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/graphql/types/ci/stage_type.rb b/app/graphql/types/ci/stage_type.rb index 04a7698e323..56b4f248697 100644 --- a/app/graphql/types/ci/stage_type.rb +++ b/app/graphql/types/ci/stage_type.rb @@ -36,6 +36,34 @@ module Types jobs_for_pipeline(pl, indexed.keys, include_needs).each do |stage_id, statuses| key = indexed[stage_id] groups = ::Ci::Group.fabricate(project, key.stage, statuses) + + if Feature.enabled?(:ci_no_empty_groups, project) + groups.each do |group| + rejected = group.jobs.reject { |job| Ability.allowed?(current_user, :read_commit_status, job) } + group.jobs.select! { |job| Ability.allowed?(current_user, :read_commit_status, job) } + next unless group.jobs.empty? + + exc = StandardError.new('Empty Ci::Group') + traces = rejected.map do |job| + trace = [] + policy = Ability.policy_for(current_user, job) + policy.debug(:read_commit_status, trace) + trace + end + extra = { + current_user_id: current_user&.id, + project_id: project.id, + pipeline_id: pl.id, + stage_id: stage_id, + group_name: group.name, + rejected_job_ids: rejected.map(&:id), + rejected_traces: traces + } + Gitlab::ErrorTracking.track_exception(exc, extra) + end + groups.reject! { |group| group.jobs.empty? } + end + loader.call(key, groups) end end |