summaryrefslogtreecommitdiff
path: root/app/models/ci/build.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/ci/build.rb')
-rw-r--r--app/models/ci/build.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 2f01a098b0e..cbd2cc6c58f 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -93,6 +93,12 @@ module Ci
chronic_duration_attr_reader :used_timeout_human_readable, :used_timeout
+ enum timeout_source: {
+ unknown_timeout_source: nil,
+ project_timeout_source: 1,
+ runner_timeout_source: 2
+ }
+
class << self
# This is needed for url_for to work,
# as the controller is JobsController
@@ -123,10 +129,6 @@ module Ci
end
after_transition pending: :running do |build|
- build.used_timeout = build.timeout
- build.timeout_source = build.timeout < build.project.build_timeout ? 'runner' : 'project'
- build.save!
-
build.run_after_commit do
BuildHooksWorker.perform_async(id)
end
@@ -160,6 +162,11 @@ module Ci
before_transition any => [:running] do |build|
build.validates_dependencies! unless Feature.enabled?('ci_disable_validates_dependencies')
end
+
+ before_transition pending: :running do |build|
+ build.used_timeout = build.timeout
+ build.timeout_source = build.timeout < build.project.build_timeout ? :runner_timeout_source : :project_timeout_source
+ end
end
def detailed_status(current_user)