Commit 4d0bfa24 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch '24488-expose-tag-list' into 'master'

Expose the tag_list in the Jobs API

See merge request gitlab-org/gitlab!44859
parents 5a823600 fc8d0598
......@@ -228,7 +228,7 @@ module Ci
end
def with_preloads
preload(:job_artifacts_archive, :job_artifacts, project: [:namespace])
preload(:job_artifacts_archive, :job_artifacts, :tags, project: [:namespace])
end
end
......
---
title: Add tag_list attribute to the JSON output for Jobs API
merge_request: 44859
author: Alon Liszt
type: added
......@@ -54,6 +54,9 @@ Example of response
{"file_type": "junit", "size": 750, "filename": "junit.xml.gz", "file_format": "gzip"}
],
"artifacts_expire_at": "2016-01-23T17:54:27.895Z",
"tag_list": [
"docker runner", "ubuntu18"
],
"id": 7,
"name": "teaspoon",
"pipeline": {
......@@ -104,6 +107,9 @@ Example of response
"finished_at": "2015-12-24T17:54:24.921Z",
"duration": 0.192,
"artifacts_expire_at": "2016-01-23T17:54:24.921Z",
"tag_list": [
"docker runner", "win10-2004"
],
"id": 6,
"name": "rspec:other",
"pipeline": {
......@@ -179,6 +185,9 @@ Example of response
"finished_at": "2015-12-24T17:54:24.921Z",
"duration": 0.192,
"artifacts_expire_at": "2016-01-23T17:54:24.921Z",
"tag_list": [
"docker runner", "ubuntu18"
],
"id": 6,
"name": "rspec:other",
"pipeline": {
......@@ -239,6 +248,9 @@ Example of response
{"file_type": "junit", "size": 750, "filename": "junit.xml.gz", "file_format": "gzip"}
],
"artifacts_expire_at": "2016-01-23T17:54:27.895Z",
"tag_list": [
"docker runner", "ubuntu18"
],
"id": 7,
"name": "teaspoon",
"pipeline": {
......@@ -399,6 +411,9 @@ Example of response
"finished_at": "2015-12-24T17:54:31.198Z",
"duration": 0.465,
"artifacts_expire_at": "2016-01-23T17:54:31.198Z",
"tag_list": [
"docker runner", "macos-10.15"
],
"id": 8,
"name": "rubocop",
"pipeline": {
......
......@@ -9,6 +9,9 @@ module API
expose :job_artifacts, as: :artifacts, using: ::API::Entities::Ci::JobArtifact
expose :runner, with: ::API::Entities::Runner
expose :artifacts_expire_at
expose :tag_list do |job|
job.tags.map(&:name).sort
end
end
end
end
......
......@@ -45,7 +45,7 @@ module API
builds = user_project.builds.order('id DESC')
builds = filter_builds(builds, params[:scope])
builds = builds.preload(:user, :job_artifacts_archive, :job_artifacts, :runner, pipeline: :project)
builds = builds.preload(:user, :job_artifacts_archive, :job_artifacts, :runner, :tags, pipeline: :project)
present paginate(builds), with: Entities::Ci::Job
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -18,6 +18,7 @@
"web_url",
"artifacts",
"artifacts_expire_at",
"tag_list",
"runner"
],
"properties": {
......@@ -53,6 +54,9 @@
]
},
"artifacts_expire_at": { "type": ["null", "string"] },
"tag_list": {
"type": "array"
},
"runner": {
"oneOf": [
{ "type": "null" },
......
......@@ -17,7 +17,7 @@ RSpec.describe API::Jobs do
end
let!(:job) do
create(:ci_build, :success, pipeline: pipeline,
create(:ci_build, :success, :tags, pipeline: pipeline,
artifacts_expire_at: 1.day.since)
end
......@@ -50,6 +50,7 @@ RSpec.describe API::Jobs do
expect(json_response).not_to be_empty
expect(json_response.first['commit']['id']).to eq project.commit.id
expect(Time.parse(json_response.first['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
expect(json_response.first['tag_list'].sort).to eq job.tag_list.sort
end
context 'without artifacts and trace' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment