summaryrefslogtreecommitdiff
path: root/app/models/ci/build.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 06:07:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 06:07:42 +0000
commit8e22ef10e4f9c6d1ef2411aa26ddd0658e2f1461 (patch)
tree1ffd5ffed59b0f752fc358524f4d2170f6694cb9 /app/models/ci/build.rb
parent2ccde70b80730fd52f75797e7d711748fb5b769b (diff)
downloadgitlab-ce-8e22ef10e4f9c6d1ef2411aa26ddd0658e2f1461.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/ci/build.rb')
-rw-r--r--app/models/ci/build.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index b8068a22c02..21dbbae1747 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -23,6 +23,7 @@ module Ci
belongs_to :runner
belongs_to :trigger_request
belongs_to :erased_by, class_name: 'User'
+ belongs_to :resource_group, class_name: 'Ci::ResourceGroup', inverse_of: :builds
RUNNER_FEATURES = {
upload_multiple_artifacts: -> (build) { build.publishes_artifacts_reports? },
@@ -34,6 +35,7 @@ module Ci
}.freeze
has_one :deployment, as: :deployable, class_name: 'Deployment'
+ has_one :resource, class_name: 'Ci::Resource', inverse_of: :build
has_many :trace_sections, class_name: 'Ci::BuildTraceSection'
has_many :trace_chunks, class_name: 'Ci::BuildTraceChunk', foreign_key: :build_id
@@ -441,6 +443,15 @@ module Ci
environment.present?
end
+ def requires_resource?
+ Feature.enabled?(:ci_resource_group, project) &&
+ self.resource_group_id.present? && resource.nil?
+ end
+
+ def retains_resource?
+ self.resource_group_id.present? && resource.present?
+ end
+
def starts_environment?
has_environment? && self.environment_action == 'start'
end