diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-07 06:09:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-07 06:09:47 +0000 |
commit | 79c0f578e45afd2b4e753c6707cc57f835bf1cee (patch) | |
tree | 934d79a52dabe972763ded59f3c8c159c3be6b12 /app/models | |
parent | 2efabf1a7281b8a403fe052e60b4de0b6a4b0d1d (diff) | |
download | gitlab-ce-79c0f578e45afd2b4e753c6707cc57f835bf1cee.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/pipeline.rb | 1 | ||||
-rw-r--r-- | app/models/ci/pipeline_artifact.rb | 34 | ||||
-rw-r--r-- | app/models/project.rb | 1 | ||||
-rw-r--r-- | app/models/prometheus_alert.rb | 5 |
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 |