summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Groleau <agroleau@gitlab.com>2019-07-10 10:00:33 -0400
committerAlex Groleau <agroleau@gitlab.com>2019-07-10 10:06:40 -0400
commita1d9c9994a9a4d79b824c3fd9322688303ac8b03 (patch)
tree8fe072909bad973e030b3eac19accde1cc320751
parente787676b3752405cbe4ae75788c6cff53154783d (diff)
downloadgitlab-ce-a1d9c9994a9a4d79b824c3fd9322688303ac8b03.tar.gz
added API call for job metrics file
-rw-r--r--app/models/ci/build.rb4
-rw-r--r--lib/api/job_artifacts.rb15
2 files changed, 19 insertions, 0 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 89cc082d0bc..982ba0c04a7 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -573,6 +573,10 @@ module Ci
update_column(:trace, nil)
end
+ def metrics_file
+ job_artifacts_metrics&.file
+ end
+
def needs_touch?
Time.now - updated_at > 15.minutes.to_i
end
diff --git a/lib/api/job_artifacts.rb b/lib/api/job_artifacts.rb
index e7fed55170e..456d595e637 100644
--- a/lib/api/job_artifacts.rb
+++ b/lib/api/job_artifacts.rb
@@ -70,6 +70,21 @@ module API
present_carrierwave_file!(build.artifacts_file)
end
+ desc 'Download the artifact metrics from a job' do
+ detail 'This feature was introduced in GitLab 8.5'
+ end
+ params do
+ requires :job_id, type: Integer, desc: 'The ID of a job'
+ end
+ route_setting :authentication, job_token_allowed: true
+ get ':id/jobs/:job_id/metrics' do
+ authorize_download_artifacts!
+
+ build = find_build!(params[:job_id])
+
+ present_carrierwave_file!(build.metrics_file)
+ end
+
desc 'Download a specific file from artifacts archive' do
detail 'This feature was introduced in GitLab 10.0'
end