diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-08-31 03:20:54 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-09-05 14:30:28 +0900 |
commit | dcf09d11447c264f4b4028ea80eea2be913c2f5b (patch) | |
tree | d992feb77bb5246ba05ebf18610b05bce8859c63 /app/models | |
parent | 597bc29260c4be3a1527a1c5307bec40004bac4d (diff) | |
download | gitlab-ce-dcf09d11447c264f4b4028ea80eea2be913c2f5b.tar.gz |
Implement `failure_reason` on `ci_builds`
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 2 | ||||
-rw-r--r-- | app/models/commit_status.rb | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index ba3156154ac..9c50d521880 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -103,7 +103,7 @@ module Ci end end - before_transition any => [:failed] do |build| + before_transition any => [:failed] do |build, transition| next if build.retries_max.zero? if build.retries_count < build.retries_max diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 842c6e5cb50..dae3174ba9b 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -38,6 +38,19 @@ class CommitStatus < ActiveRecord::Base scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) } scope :after_stage, -> (index) { where('stage_idx > ?', index) } + enum failure_reason: { + no_error: nil, + failed_by_script: 1, # TODO: Not used. Should we expand pipeline as well? + failed_by_missing_dependency: 2, # This will be done in the next MR. + failed_by_system: 3, # TODO: Not used. What's this state? + failed_by_failed_job_state: 4, + failed_by_out_of_quota: 5, # TODO: Only EE. How can we detect? + failed_by_stuck_and_timeout: 6, + failed_by_no_runner: 7, # TODO: Not used. How can we detect? + failed_by_api: 8, + failed_by_page: 9 + } + state_machine :status do event :process do transition [:skipped, :manual] => :created @@ -79,6 +92,11 @@ class CommitStatus < ActiveRecord::Base commit_status.finished_at = Time.now end + before_transition any => :failed do |commit_status, transition| + failure_reason = transition.args.first + commit_status.failure_reason = failure_reason + end + after_transition do |commit_status, transition| next if transition.loopback? |