summaryrefslogtreecommitdiff
path: root/lib/api/jobs.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/jobs.rb')
-rw-r--r--lib/api/jobs.rb21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/api/jobs.rb b/lib/api/jobs.rb
index 390dbc892e2..7390219b60e 100644
--- a/lib/api/jobs.rb
+++ b/lib/api/jobs.rb
@@ -8,10 +8,11 @@ module API
feature_category :continuous_integration
- params do
- requires :id, type: String, desc: 'The ID of a project'
- end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
+ params do
+ requires :id, type: String, desc: 'The ID of a project'
+ end
+
helpers do
params :optional_scope do
optional :scope, types: [String, Array[String]], desc: 'The scope of builds to show',
@@ -168,6 +169,20 @@ module API
end
end
+ resource :job do
+ desc 'Get current project using job token' do
+ success Entities::Ci::Job
+ end
+ route_setting :authentication, job_token_allowed: true
+ get do
+ # current_authenticated_job will be nil if user is using
+ # a valid authentication that is not CI_JOB_TOKEN
+ not_found!('Job') unless current_authenticated_job
+
+ present current_authenticated_job, with: Entities::Ci::Job
+ end
+ end
+
helpers do
# rubocop: disable CodeReuse/ActiveRecord
def filter_builds(builds, scope)