diff options
author | Steve Azzopardi <steveazz@outlook.com> | 2018-08-20 15:15:53 +0200 |
---|---|---|
committer | Steve Azzopardi <steveazz@outlook.com> | 2018-09-13 17:30:20 +0200 |
commit | 3bc5f7113350096263d615de07afe143f602659d (patch) | |
tree | 2533c44e97e9b15abf9ba3fc8d658cddb202a2e4 /app/models | |
parent | c7d1eef671dbf598814a6c2ff1f81b924583ae8a (diff) | |
download | gitlab-ce-3bc5f7113350096263d615de07afe143f602659d.tar.gz |
Add deployment information in job API
closes https://gitlab.com/gitlab-org/gitlab-ce/issues/50460
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index ab738c2fad8..63aaa0f7bcc 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -654,8 +654,31 @@ module Ci end end + # Virtual deployment status depending on the environment status. + def deployment_status + return nil unless starts_environment? + + if success? + return successful_deployment_status + elsif complete? && !success? + return :failed + end + + :creating + end + private + def successful_deployment_status + if success? && last_deployment&.last? + return :last + elsif success? && last_deployment.present? + return :out_of_date + end + + :creating + end + def each_test_report Ci::JobArtifact::TEST_REPORT_FILE_TYPES.each do |file_type| public_send("job_artifacts_#{file_type}").each_blob do |blob| # rubocop:disable GitlabSecurity/PublicSend |