Commit 8d3e8069 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Add information about project

parent 83607a4d
...@@ -261,6 +261,15 @@ Example response: ...@@ -261,6 +261,15 @@ Example response:
"sha": "97de212e80737a608d939f648d959671fb0a0142", "sha": "97de212e80737a608d939f648d959671fb0a0142",
"ref": "master", "ref": "master",
"status": "pending" "status": "pending"
},
"project": {
"id": 1,
"description": null,
"name": "project1",
"name_with_namespace": "John Doe2 / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2017-11-16T18:38:46.620Z"
} }
} }
] ]
......
...@@ -80,16 +80,21 @@ module API ...@@ -80,16 +80,21 @@ module API
expose :group_access, as: :group_access_level expose :group_access, as: :group_access_level
end end
class BasicProjectDetails < Grape::Entity class ProjectIdentity < Grape::Entity
expose :id, :description, :default_branch, :tag_list expose :id, :description
expose :ssh_url_to_repo, :http_url_to_repo, :web_url
expose :name, :name_with_namespace expose :name, :name_with_namespace
expose :path, :path_with_namespace expose :path, :path_with_namespace
expose :created_at
end
class BasicProjectDetails < ProjectIdentity
expose :default_branch, :tag_list
expose :ssh_url_to_repo, :http_url_to_repo, :web_url
expose :avatar_url do |project, options| expose :avatar_url do |project, options|
project.avatar_url(only_path: false) project.avatar_url(only_path: false)
end end
expose :star_count, :forks_count expose :star_count, :forks_count
expose :created_at, :last_activity_at expose :last_activity_at
end end
class Project < BasicProjectDetails class Project < BasicProjectDetails
...@@ -838,6 +843,10 @@ module API ...@@ -838,6 +843,10 @@ module API
expose :pipeline, with: PipelineBasic expose :pipeline, with: PipelineBasic
end end
class JobWithProject < Job
expose :project, with: ProjectIdentity
end
class Trigger < Grape::Entity class Trigger < Grape::Entity
expose :id expose :id
expose :token, :description expose :token, :description
......
...@@ -85,7 +85,9 @@ module API ...@@ -85,7 +85,9 @@ module API
destroy_conditionally!(runner) destroy_conditionally!(runner)
end end
desc 'List jobs running on a runner' desc 'List jobs running on a runner' do
success Entities::JobWithProject
end
params do params do
requires :id, type: Integer, desc: 'The ID of the runner' requires :id, type: Integer, desc: 'The ID of the runner'
use :pagination use :pagination
...@@ -94,7 +96,7 @@ module API ...@@ -94,7 +96,7 @@ module API
runner = get_runner(params[:id]) runner = get_runner(params[:id])
authenticate_list_runners_jobs!(runner) authenticate_list_runners_jobs!(runner)
present paginate(runner.builds.running), with: Entities::Job present paginate(runner.builds.running), with: Entities::JobWithProject
end end
end end
......
...@@ -356,10 +356,10 @@ describe API::Runners do ...@@ -356,10 +356,10 @@ describe API::Runners do
describe 'GET /runners/:id/jobs' do describe 'GET /runners/:id/jobs' do
let!(:job_1) { create(:ci_build) } let!(:job_1) { create(:ci_build) }
let!(:job_2) { create(:ci_build, :running, runner: shared_runner) } let!(:job_2) { create(:ci_build, :running, runner: shared_runner, project: project) }
let!(:job_3) { create(:ci_build, :failed, runner: shared_runner) } let!(:job_3) { create(:ci_build, :failed, runner: shared_runner, project: project) }
let!(:job_4) { create(:ci_build, :running, runner: specific_runner) } let!(:job_4) { create(:ci_build, :running, runner: specific_runner, project: project) }
let!(:job_5) { create(:ci_build, :failed, runner: specific_runner) } let!(:job_5) { create(:ci_build, :failed, runner: specific_runner, project: project) }
context 'admin user' do context 'admin user' do
context 'when runner exists' do context 'when runner exists' 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