2017-03-20 22:05:52 +00:00
|
|
|
module Ci
|
2017-03-28 17:47:11 +00:00
|
|
|
class PipelinePresenter < Gitlab::View::Presenter::Delegated
|
2018-04-21 22:30:37 +00:00
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
2017-10-03 11:18:59 +00:00
|
|
|
FAILURE_REASONS = {
|
|
|
|
config_error: 'CI/CD YAML configuration error!'
|
|
|
|
}.freeze
|
|
|
|
|
|
|
|
presents :pipeline
|
2017-09-29 09:14:00 +00:00
|
|
|
|
2018-04-21 22:30:37 +00:00
|
|
|
def failed_builds
|
|
|
|
return [] unless can?(current_user, :read_build, pipeline)
|
|
|
|
|
|
|
|
strong_memoize(:failed_builds) do
|
|
|
|
pipeline.builds.latest.failed
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-29 09:14:00 +00:00
|
|
|
def failure_reason
|
|
|
|
return unless pipeline.failure_reason?
|
|
|
|
|
|
|
|
FAILURE_REASONS[pipeline.failure_reason.to_sym] ||
|
|
|
|
pipeline.failure_reason
|
|
|
|
end
|
2017-03-20 22:05:52 +00:00
|
|
|
|
|
|
|
def status_title
|
2017-04-06 13:32:56 +00:00
|
|
|
if auto_canceled?
|
|
|
|
"Pipeline is redundant and is auto-canceled by Pipeline ##{auto_canceled_by_id}"
|
|
|
|
end
|
2017-03-20 22:05:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|