Commit 365b7a11 authored by Nick Thomas's avatar Nick Thomas

Merge branch '255707_add_failed_job_information_to_security_dashboard_setup_payload' into 'master'

Add failed security job information to security dashboard setup payload

See merge request gitlab-org/gitlab!43906
parents 353c8b72 6e110b21
...@@ -337,7 +337,13 @@ module EE ...@@ -337,7 +337,13 @@ module EE
pipeline: { pipeline: {
id: pipeline.id, id: pipeline.id,
path: pipeline_path(pipeline), path: pipeline_path(pipeline),
created_at: pipeline.created_at.to_s(:iso8601) created_at: pipeline.created_at.to_s(:iso8601),
security_builds: {
failed: {
count: pipeline.latest_failed_security_builds.count,
path: failures_project_pipeline_path(pipeline.project, pipeline)
}
}
} }
} }
end end
......
...@@ -160,6 +160,11 @@ module EE ...@@ -160,6 +160,11 @@ module EE
merge_request_pipeline? && merge_train_ref? merge_request_pipeline? && merge_train_ref?
end end
def latest_failed_security_builds
security_builds.select(&:latest?)
.select(&:failed?)
end
private private
def project_has_subscriptions? def project_has_subscriptions?
...@@ -175,6 +180,10 @@ module EE ...@@ -175,6 +180,10 @@ module EE
feature_names = REPORT_LICENSED_FEATURES.fetch(file_type) feature_names = REPORT_LICENSED_FEATURES.fetch(file_type)
feature_names.nil? || feature_names.any? { |feature| project.feature_available?(feature) } feature_names.nil? || feature_names.any? { |feature| project.feature_available?(feature) }
end end
def security_builds
@security_builds ||= ::Security::SecurityJobsFinder.new(pipeline: self).execute
end
end end
end end
end end
...@@ -178,7 +178,13 @@ RSpec.describe ProjectsHelper do ...@@ -178,7 +178,13 @@ RSpec.describe ProjectsHelper do
pipeline: { pipeline: {
id: pipeline.id, id: pipeline.id,
path: "/#{project.full_path}/-/pipelines/#{pipeline.id}", path: "/#{project.full_path}/-/pipelines/#{pipeline.id}",
created_at: pipeline_created_at created_at: pipeline_created_at,
security_builds: {
failed: {
count: 0,
path: "/#{project.full_path}/-/pipelines/#{pipeline.id}/failures"
}
}
} }
} }
end end
......
...@@ -495,4 +495,21 @@ RSpec.describe Ci::Pipeline do ...@@ -495,4 +495,21 @@ RSpec.describe Ci::Pipeline do
it { is_expected.to eq(:detached) } it { is_expected.to eq(:detached) }
end end
end end
describe '#latest_failed_security_builds' do
let(:sast_build) { create(:ee_ci_build, :sast, :failed, pipeline: pipeline) }
let(:dast_build) { create(:ee_ci_build, :sast, pipeline: pipeline) }
let(:retried_sast_build) { create(:ee_ci_build, :sast, :failed, :retried, pipeline: pipeline) }
let(:expected_builds) { [sast_build] }
before do
allow_next_instance_of(::Security::SecurityJobsFinder) do |finder|
allow(finder).to receive(:execute).and_return([sast_build, dast_build, retried_sast_build])
end
end
subject { pipeline.latest_failed_security_builds }
it { is_expected.to match_array(expected_builds) }
end
end end
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