Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/ci/build.rb')
-rw-r--r--app/models/ci/build.rb47
1 files changed, 13 insertions, 34 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index e35198ba31f..7f9697d0424 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -2,6 +2,7 @@
module Ci
class Build < Ci::Processable
+ prepend Ci::BulkInsertableTags
include Ci::Metadatable
include Ci::Contextable
include TokenAuthenticatable
@@ -14,8 +15,6 @@ module Ci
extend ::Gitlab::Utils::Override
- BuildArchivedError = Class.new(StandardError)
-
belongs_to :project, inverse_of: :builds
belongs_to :runner
belongs_to :trigger_request
@@ -30,10 +29,6 @@ module Ci
return_exit_code: -> (build) { build.exit_codes_defined? }
}.freeze
- DEFAULT_RETRIES = {
- scheduler_failure: 2
- }.freeze
-
DEGRADATION_THRESHOLD_VARIABLE_NAME = 'DEGRADATION_THRESHOLD'
RUNNERS_STATUS_CACHE_EXPIRATION = 1.minute
@@ -172,7 +167,6 @@ module Ci
end
scope :with_artifacts_not_expired, -> { with_downloadable_artifacts.where('artifacts_expire_at IS NULL OR artifacts_expire_at > ?', Time.current) }
- scope :with_expired_artifacts, -> { with_downloadable_artifacts.where('artifacts_expire_at < ?', Time.current) }
scope :with_pipeline_locked_artifacts, -> { joins(:pipeline).where('pipeline.locked': Ci::Pipeline.lockeds[:artifacts_locked]) }
scope :last_month, -> { where('created_at > ?', Date.today - 1.month) }
scope :manual_actions, -> { where(when: :manual, status: COMPLETED_STATUSES + %i[manual]) }
@@ -187,13 +181,6 @@ module Ci
joins(:metadata).where("ci_builds_metadata.config_options -> 'artifacts' -> 'reports' ?| array[:job_types]", job_types: job_types)
end
- scope :queued_before, ->(time) { where(arel_table[:queued_at].lt(time)) }
-
- scope :preload_project_and_pipeline_project, -> do
- preload(Ci::Pipeline::PROJECT_ROUTE_AND_NAMESPACE_ROUTE,
- pipeline: Ci::Pipeline::PROJECT_ROUTE_AND_NAMESPACE_ROUTE)
- end
-
scope :with_coverage, -> { where.not(coverage: nil) }
scope :without_coverage, -> { where(coverage: nil) }
scope :with_coverage_regex, -> { where.not(coverage_regex: nil) }
@@ -207,7 +194,7 @@ module Ci
after_save :stick_build_if_status_changed
after_create unless: :importing? do |build|
- run_after_commit { BuildHooksWorker.perform_async(build.id) }
+ run_after_commit { BuildHooksWorker.perform_async(build) }
end
class << self
@@ -217,10 +204,6 @@ module Ci
ActiveModel::Name.new(self, nil, 'job')
end
- def first_pending
- pending.unstarted.order('created_at ASC').first
- end
-
def with_preloads
preload(:job_artifacts_archive, :job_artifacts, :tags, project: [:namespace])
end
@@ -302,7 +285,7 @@ module Ci
build.run_after_commit do
BuildQueueWorker.perform_async(id)
- BuildHooksWorker.perform_async(id)
+ BuildHooksWorker.perform_async(build)
end
end
@@ -330,7 +313,7 @@ module Ci
build.run_after_commit do
build.ensure_persistent_ref
- BuildHooksWorker.perform_async(id)
+ BuildHooksWorker.perform_async(build)
end
end
@@ -338,11 +321,7 @@ module Ci
build.run_after_commit do
build.run_status_commit_hooks!
- if Feature.enabled?(:ci_build_finished_worker_namespace_changed, build.project)
- Ci::BuildFinishedWorker.perform_async(id)
- else
- ::BuildFinishedWorker.perform_async(id)
- end
+ Ci::BuildFinishedWorker.perform_async(id)
end
end
@@ -446,10 +425,6 @@ module Ci
true
end
- def save_tags
- super unless Thread.current['ci_bulk_insert_tags']
- end
-
def archived?
return true if degenerated?
@@ -556,10 +531,6 @@ module Ci
self.options.dig(:environment, :deployment_tier) if self.options
end
- def outdated_deployment?
- success? && !deployment.try(:last?)
- end
-
def triggered_by?(current_user)
user == current_user
end
@@ -1162,6 +1133,14 @@ module Ci
Gitlab::Utils::UsageData.track_usage_event('ci_users_executing_deployment_job', user_id) if user_id.present? && count_user_deployment?
end
+ def track_verify_usage
+ Gitlab::Utils::UsageData.track_usage_event('ci_users_executing_verify_environment_job', user_id) if user_id.present? && count_user_verification?
+ end
+
+ def count_user_verification?
+ has_environment? && environment_action == 'verify'
+ end
+
def each_report(report_types)
job_artifacts_for_types(report_types).each do |report_artifact|
report_artifact.each_blob do |blob|