summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/api/runners.md9
-rw-r--r--lib/api/entities.rb17
-rw-r--r--lib/api/runners.rb6
-rw-r--r--spec/requests/api/runners_spec.rb8
4 files changed, 30 insertions, 10 deletions
diff --git a/doc/api/runners.md b/doc/api/runners.md
index 171857ef49e..f9a9e2bee5a 100644
--- a/doc/api/runners.md
+++ b/doc/api/runners.md
@@ -261,6 +261,15 @@ Example response:
"sha": "97de212e80737a608d939f648d959671fb0a0142",
"ref": "master",
"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"
}
}
]
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 16ae99b5c6c..65e4fa14e7d 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -80,16 +80,21 @@ module API
expose :group_access, as: :group_access_level
end
- class BasicProjectDetails < Grape::Entity
- expose :id, :description, :default_branch, :tag_list
- expose :ssh_url_to_repo, :http_url_to_repo, :web_url
+ class ProjectIdentity < Grape::Entity
+ expose :id, :description
expose :name, :name_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|
project.avatar_url(only_path: false)
end
expose :star_count, :forks_count
- expose :created_at, :last_activity_at
+ expose :last_activity_at
end
class Project < BasicProjectDetails
@@ -831,6 +836,10 @@ module API
expose :pipeline, with: PipelineBasic
end
+ class JobWithProject < Job
+ expose :project, with: ProjectIdentity
+ end
+
class Trigger < Grape::Entity
expose :id
expose :token, :description
diff --git a/lib/api/runners.rb b/lib/api/runners.rb
index 996ec1b5ba4..c4ba9361b21 100644
--- a/lib/api/runners.rb
+++ b/lib/api/runners.rb
@@ -85,7 +85,9 @@ module API
destroy_conditionally!(runner)
end
- desc 'List jobs running on a runner'
+ desc 'List jobs running on a runner' do
+ success Entities::JobWithProject
+ end
params do
requires :id, type: Integer, desc: 'The ID of the runner'
use :pagination
@@ -94,7 +96,7 @@ module API
runner = get_runner(params[:id])
authenticate_list_runners_jobs!(runner)
- present paginate(runner.builds.running), with: Entities::Job
+ present paginate(runner.builds.running), with: Entities::JobWithProject
end
end
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb
index e98588034dd..40b4f670281 100644
--- a/spec/requests/api/runners_spec.rb
+++ b/spec/requests/api/runners_spec.rb
@@ -356,10 +356,10 @@ describe API::Runners do
describe 'GET /runners/:id/jobs' do
let!(:job_1) { create(:ci_build) }
- let!(:job_2) { create(:ci_build, :running, runner: shared_runner) }
- let!(:job_3) { create(:ci_build, :failed, runner: shared_runner) }
- let!(:job_4) { create(:ci_build, :running, runner: specific_runner) }
- let!(:job_5) { create(:ci_build, :failed, runner: specific_runner) }
+ let!(:job_2) { create(:ci_build, :running, runner: shared_runner, project: project) }
+ let!(:job_3) { create(:ci_build, :failed, runner: shared_runner, project: project) }
+ let!(:job_4) { create(:ci_build, :running, runner: specific_runner, project: project) }
+ let!(:job_5) { create(:ci_build, :failed, runner: specific_runner, project: project) }
context 'admin user' do
context 'when runner exists' do