Skip to content

Commit 8d3e806

Browse files
committed
Add information about project
1 parent 83607a4 commit 8d3e806

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

doc/api/runners.md

+9
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ Example response:
261261
"sha": "97de212e80737a608d939f648d959671fb0a0142",
262262
"ref": "master",
263263
"status": "pending"
264+
},
265+
"project": {
266+
"id": 1,
267+
"description": null,
268+
"name": "project1",
269+
"name_with_namespace": "John Doe2 / project1",
270+
"path": "project1",
271+
"path_with_namespace": "namespace1/project1",
272+
"created_at": "2017-11-16T18:38:46.620Z"
264273
}
265274
}
266275
]

lib/api/entities.rb

+13-4
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,21 @@ class SharedGroup < Grape::Entity
8080
expose :group_access, as: :group_access_level
8181
end
8282

83-
class BasicProjectDetails < Grape::Entity
84-
expose :id, :description, :default_branch, :tag_list
85-
expose :ssh_url_to_repo, :http_url_to_repo, :web_url
83+
class ProjectIdentity < Grape::Entity
84+
expose :id, :description
8685
expose :name, :name_with_namespace
8786
expose :path, :path_with_namespace
87+
expose :created_at
88+
end
89+
90+
class BasicProjectDetails < ProjectIdentity
91+
expose :default_branch, :tag_list
92+
expose :ssh_url_to_repo, :http_url_to_repo, :web_url
8893
expose :avatar_url do |project, options|
8994
project.avatar_url(only_path: false)
9095
end
9196
expose :star_count, :forks_count
92-
expose :created_at, :last_activity_at
97+
expose :last_activity_at
9398
end
9499

95100
class Project < BasicProjectDetails
@@ -838,6 +843,10 @@ class Job < Grape::Entity
838843
expose :pipeline, with: PipelineBasic
839844
end
840845

846+
class JobWithProject < Job
847+
expose :project, with: ProjectIdentity
848+
end
849+
841850
class Trigger < Grape::Entity
842851
expose :id
843852
expose :token, :description

lib/api/runners.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ class Runners < Grape::API
8585
destroy_conditionally!(runner)
8686
end
8787

88-
desc 'List jobs running on a runner'
88+
desc 'List jobs running on a runner' do
89+
success Entities::JobWithProject
90+
end
8991
params do
9092
requires :id, type: Integer, desc: 'The ID of the runner'
9193
use :pagination
@@ -94,7 +96,7 @@ class Runners < Grape::API
9496
runner = get_runner(params[:id])
9597
authenticate_list_runners_jobs!(runner)
9698

97-
present paginate(runner.builds.running), with: Entities::Job
99+
present paginate(runner.builds.running), with: Entities::JobWithProject
98100
end
99101
end
100102

spec/requests/api/runners_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,10 @@ def update_runner(id, user, args)
356356

357357
describe 'GET /runners/:id/jobs' do
358358
let!(:job_1) { create(:ci_build) }
359-
let!(:job_2) { create(:ci_build, :running, runner: shared_runner) }
360-
let!(:job_3) { create(:ci_build, :failed, runner: shared_runner) }
361-
let!(:job_4) { create(:ci_build, :running, runner: specific_runner) }
362-
let!(:job_5) { create(:ci_build, :failed, runner: specific_runner) }
359+
let!(:job_2) { create(:ci_build, :running, runner: shared_runner, project: project) }
360+
let!(:job_3) { create(:ci_build, :failed, runner: shared_runner, project: project) }
361+
let!(:job_4) { create(:ci_build, :running, runner: specific_runner, project: project) }
362+
let!(:job_5) { create(:ci_build, :failed, runner: specific_runner, project: project) }
363363

364364
context 'admin user' do
365365
context 'when runner exists' do

0 commit comments

Comments
 (0)