2017-06-07 05:36:41 -04:00
|
|
|
class BuildDetailsEntity < JobEntity
|
2017-05-23 11:10:07 -04:00
|
|
|
expose :coverage, :erased_at, :duration
|
|
|
|
expose :tag_list, as: :tags
|
2017-06-01 15:34:44 -04:00
|
|
|
expose :user, using: UserEntity
|
2017-06-13 05:05:48 -04:00
|
|
|
expose :runner, using: RunnerEntity
|
|
|
|
expose :pipeline, using: PipelineEntity
|
2017-06-01 15:34:44 -04:00
|
|
|
|
2017-05-29 03:58:20 -04:00
|
|
|
expose :erased_by, if: -> (*) { build.erased? }, using: UserEntity
|
|
|
|
expose :erase_path, if: -> (*) { build.erasable? && can?(current_user, :update_build, project) } do |build|
|
2017-06-29 13:06:35 -04:00
|
|
|
erase_project_job_path(project, build)
|
2017-05-29 03:58:20 -04:00
|
|
|
end
|
|
|
|
|
2017-06-01 15:34:44 -04:00
|
|
|
expose :merge_request, if: -> (*) { can?(current_user, :read_merge_request, build.merge_request) } do
|
2017-05-29 03:58:20 -04:00
|
|
|
expose :iid do |build|
|
|
|
|
build.merge_request.iid
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :path do |build|
|
2017-07-21 07:09:13 -04:00
|
|
|
project_merge_request_path(build.merge_request.project,
|
|
|
|
build.merge_request)
|
2017-05-29 03:58:20 -04:00
|
|
|
end
|
2017-05-23 11:10:07 -04:00
|
|
|
end
|
|
|
|
|
2017-06-02 14:32:37 -04:00
|
|
|
expose :new_issue_path, if: -> (*) { can?(request.current_user, :create_issue, project) && build.failed? } do |build|
|
2017-06-29 13:06:35 -04:00
|
|
|
new_project_issue_path(project, issue: build_failed_issue_options)
|
2017-05-23 11:10:07 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
expose :raw_path do |build|
|
2017-06-29 13:06:35 -04:00
|
|
|
raw_project_job_path(project, build)
|
2017-05-23 11:10:07 -04:00
|
|
|
end
|
2017-05-26 04:31:42 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-06-02 14:32:37 -04:00
|
|
|
def build_failed_issue_options
|
2017-08-24 12:32:23 -04:00
|
|
|
{ title: "Job Failed ##{build.id}",
|
2017-09-11 09:46:53 -04:00
|
|
|
description: "Job [##{build.id}](#{project_job_path(project, build)}) failed for #{build.sha}:\n" }
|
2017-06-02 14:32:37 -04:00
|
|
|
end
|
|
|
|
|
2017-05-26 04:31:42 -04:00
|
|
|
def current_user
|
|
|
|
request.current_user
|
|
|
|
end
|
|
|
|
|
|
|
|
def project
|
|
|
|
build.project
|
|
|
|
end
|
2017-05-23 11:10:07 -04:00
|
|
|
end
|