Commit 0be6a04d authored by Matija Čupić's avatar Matija Čupić

Add bridged relation between Pipeline and Bridge

parent f12c6663
......@@ -13,6 +13,8 @@ module EE
serialize :yaml_variables, ::Gitlab::Serializer::Ci::Variables
# rubocop:enable Cop/ActiveRecordSerialize
belongs_to :source_pipeline, class_name: "::Ci::Pipeline",
foreign_key: :bridged_pipeline_id
has_many :sourced_pipelines, class_name: "::Ci::Sources::Pipeline",
foreign_key: :source_job_id
......
......@@ -28,6 +28,8 @@ module EE
has_many :auto_canceled_pipelines, class_name: 'Ci::Pipeline', foreign_key: 'auto_canceled_by_id'
has_many :auto_canceled_jobs, class_name: 'CommitStatus', foreign_key: 'auto_canceled_by_id'
has_many :bridged_jobs, class_name: '::Ci::Bridge', foreign_key: :bridged_pipeline_id
# Legacy way to fetch security reports based on job name. This has been replaced by the reports feature.
scope :with_legacy_security_reports, -> do
joins(:artifacts).where(ci_builds: { name: %w[sast dependency_scanning sast:container container_scanning dast] })
......
......@@ -20,6 +20,7 @@ ci_pipelines:
- sourced_pipelines
- triggered_by_pipeline
- triggered_pipelines
- bridged_jobs
- job_artifacts
- vulnerabilities_occurrence_pipelines
- vulnerabilities
......
......@@ -6,3 +6,5 @@ ProjectTracingSetting:
- external_url
Note:
- review_id
CommitStatus:
- bridged_pipeline_id
......@@ -14,6 +14,10 @@ describe Ci::Bridge do
{ trigger: { project: 'my/project', branch: 'master' } }
end
it 'belongs to a source pipeline' do
expect(bridge).to belong_to(:source_pipeline)
end
it 'has many sourced pipelines' do
expect(bridge).to have_many(:sourced_pipelines)
end
......
......@@ -14,6 +14,7 @@ describe Ci::Pipeline do
it { is_expected.to have_many(:sourced_pipelines) }
it { is_expected.to have_one(:triggered_by_pipeline) }
it { is_expected.to have_many(:triggered_pipelines) }
it { is_expected.to have_many(:bridged_jobs) }
it { is_expected.to have_many(:job_artifacts).through(:builds) }
it { is_expected.to have_many(:vulnerabilities).through(:vulnerabilities_occurrence_pipelines).class_name('Vulnerabilities::Occurrence') }
it { is_expected.to have_many(:vulnerabilities_occurrence_pipelines).class_name('Vulnerabilities::OccurrencePipeline') }
......
......@@ -38,7 +38,7 @@ describe Ci::RetryBuildService do
runner_id tag_taggings taggings tags trigger_request_id
user_id auto_canceled_by_id retried failure_reason
sourced_pipelines artifacts_file_store artifacts_metadata_store
metadata runner_session trace_chunks].freeze
metadata runner_session trace_chunks bridged_pipeline_id].freeze
shared_examples 'build duplication' do
let(:another_pipeline) { create(:ci_empty_pipeline, project: project) }
......
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