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