summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/pipeline.rb1
-rw-r--r--app/models/ci/pipeline_artifact.rb34
-rw-r--r--app/models/project.rb1
-rw-r--r--app/models/prometheus_alert.rb5
4 files changed, 41 insertions, 0 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 473087b7c2d..3c4ffa4d6ab 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -83,6 +83,7 @@ module Ci
has_many :daily_build_group_report_results, class_name: 'Ci::DailyBuildGroupReportResult', foreign_key: :last_pipeline_id
has_many :latest_builds_report_results, through: :latest_builds, source: :report_results
+ has_many :pipeline_artifacts, class_name: 'Ci::PipelineArtifact', inverse_of: :pipeline, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
accepts_nested_attributes_for :variables, reject_if: :persisted?
diff --git a/app/models/ci/pipeline_artifact.rb b/app/models/ci/pipeline_artifact.rb
new file mode 100644
index 00000000000..daa54aaafe3
--- /dev/null
+++ b/app/models/ci/pipeline_artifact.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+# This class is being used to persist generated report consumable by gitlab frontend in a pipeline context.
+
+module Ci
+ class PipelineArtifact < ApplicationRecord
+ extend Gitlab::Ci::Model
+
+ FILE_STORE_SUPPORTED = [
+ ObjectStorage::Store::LOCAL,
+ ObjectStorage::Store::REMOTE
+ ].freeze
+
+ FILE_SIZE_LIMIT = 10.megabytes.freeze
+
+ belongs_to :project, class_name: "Project", inverse_of: :pipeline_artifacts
+ belongs_to :pipeline, class_name: "Ci::Pipeline", inverse_of: :pipeline_artifacts
+
+ validates :pipeline, :project, :file_format, presence: true
+ validates :file_store, presence: true, inclusion: { in: FILE_STORE_SUPPORTED }
+ validates :size, presence: true, numericality: { less_than_or_equal_to: FILE_SIZE_LIMIT }
+ validates :file_type, presence: true, uniqueness: { scope: [:pipeline_id] }
+
+ enum file_type: {
+ code_coverage: 1
+ }
+
+ enum file_format: {
+ raw: 1,
+ zip: 2,
+ gzip: 3
+ }, _suffix: true
+ end
+end
diff --git a/app/models/project.rb b/app/models/project.rb
index b37dc3ed397..fdca74af81d 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -299,6 +299,7 @@ class Project < ApplicationRecord
has_many :build_trace_chunks, class_name: 'Ci::BuildTraceChunk', through: :builds, source: :trace_chunks
has_many :build_report_results, class_name: 'Ci::BuildReportResult', inverse_of: :project
has_many :job_artifacts, class_name: 'Ci::JobArtifact'
+ has_many :pipeline_artifacts, class_name: 'Ci::PipelineArtifact', inverse_of: :project
has_many :runner_projects, class_name: 'Ci::RunnerProject', inverse_of: :project
has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner'
has_many :variables, class_name: 'Ci::Variable'
diff --git a/app/models/prometheus_alert.rb b/app/models/prometheus_alert.rb
index 32f9809e538..1c870f4391a 100644
--- a/app/models/prometheus_alert.rb
+++ b/app/models/prometheus_alert.rb
@@ -22,6 +22,8 @@ class PrometheusAlert < ApplicationRecord
after_destroy :clear_prometheus_adapter_cache!
validates :environment, :project, :prometheus_metric, presence: true
+ validates :runbook_url, length: { maximum: 255 }, allow_blank: true,
+ addressable_url: { enforce_sanitization: true, ascii_only: true }
validate :require_valid_environment_project!
validate :require_valid_metric_project!
@@ -59,6 +61,9 @@ class PrometheusAlert < ApplicationRecord
"gitlab" => "hook",
"gitlab_alert_id" => prometheus_metric_id,
"gitlab_prometheus_alert_id" => id
+ },
+ "annotations" => {
+ "runbook" => runbook_url
}
}
end