diff options
author | Matija Čupić <matteeyah@gmail.com> | 2019-05-01 18:29:15 -0400 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2019-05-28 17:06:29 +0200 |
commit | 31bd09a3924d1b76cac38996267ffe6ec08cad46 (patch) | |
tree | bec537082fcdec21510736ee8372186cf9abe4df /app/serializers | |
parent | 51183ad3bdad507325c14c916d70fe3ab9857bfc (diff) | |
download | gitlab-ce-31bd09a3924d1b76cac38996267ffe6ec08cad46.tar.gz |
Expose report download path in build details
Exposes report download paths in build details.
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/build_details_entity.rb | 4 | ||||
-rw-r--r-- | app/serializers/job_artifact_entity.rb | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb index 6928968edc0..ee5adc69660 100644 --- a/app/serializers/build_details_entity.rb +++ b/app/serializers/build_details_entity.rb @@ -42,6 +42,10 @@ class BuildDetailsEntity < JobEntity end end + expose :reports, if: -> (*) { can?(current_user, :read_build, build) }, using: JobArtifactEntity do |build| + build.job_artifacts.merge(Ci::JobArtifact.with_all_reports) + end + expose :erased_by, if: -> (*) { build.erased? }, using: UserEntity expose :erase_path, if: -> (*) { build.erasable? && can?(current_user, :erase_build, build) } do |build| erase_project_job_path(project, build) diff --git a/app/serializers/job_artifact_entity.rb b/app/serializers/job_artifact_entity.rb new file mode 100644 index 00000000000..76ded287c75 --- /dev/null +++ b/app/serializers/job_artifact_entity.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class JobArtifactEntity < Grape::Entity + include RequestAwareEntity + + expose :file_type + expose :file_format + expose :size + + expose :download_path do |artifact| + download_project_job_artifacts_path(job.project, job, file_type: artifact.file_format) + end + + alias_method :job, :object +end |