Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/api/ci
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/ci')
-rw-r--r--lib/api/ci/helpers/runner.rb6
-rw-r--r--lib/api/ci/job_artifacts.rb38
-rw-r--r--lib/api/ci/jobs.rb4
-rw-r--r--lib/api/ci/pipeline_schedules.rb10
-rw-r--r--lib/api/ci/pipelines.rb22
-rw-r--r--lib/api/ci/runner.rb12
-rw-r--r--lib/api/ci/runners.rb12
7 files changed, 57 insertions, 47 deletions
diff --git a/lib/api/ci/helpers/runner.rb b/lib/api/ci/helpers/runner.rb
index fe49074afed..269f2fa7ddc 100644
--- a/lib/api/ci/helpers/runner.rb
+++ b/lib/api/ci/helpers/runner.rb
@@ -138,17 +138,13 @@ module API
def set_application_context
return unless current_job
- Gitlab::ApplicationContext.push(job: current_job)
+ Gitlab::ApplicationContext.push(job: current_job, runner: current_runner)
end
def track_ci_minutes_usage!(_build, _runner)
# noop: overridden in EE
end
- def log_artifact_size(artifact)
- Gitlab::ApplicationContext.push(artifact: artifact)
- end
-
private
def get_runner_config_from_request
diff --git a/lib/api/ci/job_artifacts.rb b/lib/api/ci/job_artifacts.rb
index 8b332f96be0..b843404e9d7 100644
--- a/lib/api/ci/job_artifacts.rb
+++ b/lib/api/ci/job_artifacts.rb
@@ -30,15 +30,16 @@ module API
requires :job, type: String, desc: 'The name for the job'
end
route_setting :authentication, job_token_allowed: true
- get ':id/jobs/artifacts/:ref_name/download', urgency: :low,
- requirements: { ref_name: /.+/ } do
- authorize_download_artifacts!
+ get ':id/jobs/artifacts/:ref_name/download',
+ urgency: :low,
+ requirements: { ref_name: /.+/ } do
+ authorize_download_artifacts!
- latest_build = user_project.latest_successful_build_for_ref!(params[:job], params[:ref_name])
- authorize_read_job_artifacts!(latest_build)
+ latest_build = user_project.latest_successful_build_for_ref!(params[:job], params[:ref_name])
+ authorize_read_job_artifacts!(latest_build)
- present_artifacts_file!(latest_build.artifacts_file)
- end
+ present_artifacts_file!(latest_build.artifacts_file)
+ end
desc 'Download a specific file from artifacts archive from a ref' do
detail 'This feature was introduced in GitLab 11.5'
@@ -49,21 +50,22 @@ module API
requires :artifact_path, type: String, desc: 'Artifact path'
end
route_setting :authentication, job_token_allowed: true
- get ':id/jobs/artifacts/:ref_name/raw/*artifact_path', urgency: :low,
- format: false,
- requirements: { ref_name: /.+/ } do
- authorize_download_artifacts!
+ get ':id/jobs/artifacts/:ref_name/raw/*artifact_path',
+ urgency: :low,
+ format: false,
+ requirements: { ref_name: /.+/ } do
+ authorize_download_artifacts!
- build = user_project.latest_successful_build_for_ref!(params[:job], params[:ref_name])
- authorize_read_job_artifacts!(build)
+ build = user_project.latest_successful_build_for_ref!(params[:job], params[:ref_name])
+ authorize_read_job_artifacts!(build)
- path = Gitlab::Ci::Build::Artifacts::Path
- .new(params[:artifact_path])
+ path = Gitlab::Ci::Build::Artifacts::Path
+ .new(params[:artifact_path])
- bad_request! unless path.valid?
+ bad_request! unless path.valid?
- send_artifacts_entry(build.artifacts_file, path)
- end
+ send_artifacts_entry(build.artifacts_file, path)
+ end
desc 'Download the artifacts archive from a job' do
detail 'This feature was introduced in GitLab 8.5'
diff --git a/lib/api/ci/jobs.rb b/lib/api/ci/jobs.rb
index 97471d3c96e..cd5f1f77ced 100644
--- a/lib/api/ci/jobs.rb
+++ b/lib/api/ci/jobs.rb
@@ -152,8 +152,8 @@ module API
end
params do
requires :job_id, type: Integer, desc: 'The ID of a Job'
- optional :job_variables_attributes, type: Array,
- desc: 'User defined variables that will be included when running the job' do
+ optional :job_variables_attributes,
+ type: Array, desc: 'User defined variables that will be included when running the job' do
requires :key, type: String, desc: 'The name of the variable'
requires :value, type: String, desc: 'The value of the variable'
end
diff --git a/lib/api/ci/pipeline_schedules.rb b/lib/api/ci/pipeline_schedules.rb
index 4b522f37524..886c3509c51 100644
--- a/lib/api/ci/pipeline_schedules.rb
+++ b/lib/api/ci/pipeline_schedules.rb
@@ -42,6 +42,16 @@ module API
present pipeline_schedule, with: Entities::Ci::PipelineScheduleDetails, user: current_user
end
+ desc 'Get all pipelines triggered from a pipeline schedule' do
+ success Entities::Ci::PipelineBasic
+ end
+ params do
+ requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule ID'
+ end
+ get ':id/pipeline_schedules/:pipeline_schedule_id/pipelines' do
+ present paginate(pipeline_schedule.pipelines), with: Entities::Ci::PipelineBasic
+ end
+
desc 'Create a new pipeline schedule' do
success Entities::Ci::PipelineScheduleDetails
end
diff --git a/lib/api/ci/pipelines.rb b/lib/api/ci/pipelines.rb
index cd686a28dd2..72a81330e71 100644
--- a/lib/api/ci/pipelines.rb
+++ b/lib/api/ci/pipelines.rb
@@ -21,17 +21,17 @@ module API
helpers do
params :optional_scope do
optional :scope, types: [String, Array[String]], desc: 'The scope of builds to show',
- values: ::CommitStatus::AVAILABLE_STATUSES,
- coerce_with: ->(scope) {
- case scope
- when String
- [scope]
- when ::Array
- scope
- else
- ['unknown']
- end
- }
+ values: ::CommitStatus::AVAILABLE_STATUSES,
+ coerce_with: ->(scope) {
+ case scope
+ when String
+ [scope]
+ when ::Array
+ scope
+ else
+ ['unknown']
+ end
+ }
end
end
diff --git a/lib/api/ci/runner.rb b/lib/api/ci/runner.rb
index 65dc002e67d..9e4a700d0f3 100644
--- a/lib/api/ci/runner.rb
+++ b/lib/api/ci/runner.rb
@@ -38,7 +38,8 @@ module API
attributes[:maintenance_note] ||= deprecated_note if deprecated_note
attributes[:active] = !attributes.delete(:paused) if attributes.include?(:paused)
- @runner = ::Ci::Runners::RegisterRunnerService.new.execute(params[:token], attributes)
+ result = ::Ci::Runners::RegisterRunnerService.new.execute(params[:token], attributes)
+ @runner = result.success? ? result.payload[:runner] : nil
forbidden! unless @runner
if @runner.persisted?
@@ -255,7 +256,7 @@ module API
optional :filesize, type: Integer, desc: %q(Artifacts filesize)
optional :artifact_type, type: String, desc: %q(The type of artifact),
- default: 'archive', values: ::Ci::JobArtifact.file_types.keys
+ default: 'archive', values: ::Ci::JobArtifact.file_types.keys
end
post '/:id/artifacts/authorize', feature_category: :build_artifacts, urgency: :low do
not_allowed! unless Gitlab.config.artifacts.enabled
@@ -288,9 +289,9 @@ module API
optional :token, type: String, desc: %q(Job's authentication token)
optional :expire_in, type: String, desc: %q(Specify when artifacts should expire)
optional :artifact_type, type: String, desc: %q(The type of artifact),
- default: 'archive', values: ::Ci::JobArtifact.file_types.keys
+ default: 'archive', values: ::Ci::JobArtifact.file_types.keys
optional :artifact_format, type: String, desc: %q(The format of artifact),
- default: 'zip', values: ::Ci::JobArtifact.file_formats.keys
+ default: 'zip', values: ::Ci::JobArtifact.file_formats.keys
optional :metadata, type: ::API::Validations::Types::WorkhorseFile, desc: %(The artifact metadata to store (generated by Multipart middleware))
end
post '/:id/artifacts', feature_category: :build_artifacts, urgency: :low do
@@ -305,7 +306,8 @@ module API
result = ::Ci::JobArtifacts::CreateService.new(job).execute(artifacts, params, metadata_file: metadata)
if result[:status] == :success
- log_artifact_size(result[:artifact])
+ log_artifacts_filesize(result[:artifact])
+
status :created
body "201"
else
diff --git a/lib/api/ci/runners.rb b/lib/api/ci/runners.rb
index 06bfee59140..ec9b09a3419 100644
--- a/lib/api/ci/runners.rb
+++ b/lib/api/ci/runners.rb
@@ -16,7 +16,7 @@ module API
end
params do
optional :scope, type: String, values: ::Ci::Runner::AVAILABLE_STATUSES,
- desc: 'The scope of specific runners to show'
+ desc: 'The scope of specific runners to show'
optional :type, type: String, values: ::Ci::Runner::AVAILABLE_TYPES,
desc: 'The type of the runners to show'
optional :paused, type: Boolean, desc: 'Whether to include only runners that are accepting or ignoring new jobs'
@@ -38,7 +38,7 @@ module API
end
params do
optional :scope, type: String, values: ::Ci::Runner::AVAILABLE_SCOPES,
- desc: 'The scope of specific runners to show'
+ desc: 'The scope of specific runners to show'
optional :type, type: String, values: ::Ci::Runner::AVAILABLE_TYPES,
desc: 'The type of the runners to show'
optional :paused, type: Boolean, desc: 'Whether to include only runners that are accepting or ignoring new jobs'
@@ -159,7 +159,7 @@ module API
end
params do
optional :scope, type: String, values: ::Ci::Runner::AVAILABLE_SCOPES,
- desc: 'The scope of specific runners to show'
+ desc: 'The scope of specific runners to show'
optional :type, type: String, values: ::Ci::Runner::AVAILABLE_TYPES,
desc: 'The type of the runners to show'
optional :paused, type: Boolean, desc: 'Whether to include only runners that are accepting or ignoring new jobs'
@@ -188,7 +188,7 @@ module API
runner = get_runner(params[:runner_id])
authenticate_enable_runner!(runner)
- if ::Ci::Runners::AssignRunnerService.new(runner, user_project, current_user).execute
+ if ::Ci::Runners::AssignRunnerService.new(runner, user_project, current_user).execute.success?
present runner, with: Entities::Ci::Runner
else
render_validation_error!(runner)
@@ -225,10 +225,10 @@ module API
end
params do
optional :type, type: String, values: ::Ci::Runner::AVAILABLE_TYPES,
- desc: 'The type of the runners to show'
+ desc: 'The type of the runners to show'
optional :paused, type: Boolean, desc: 'Whether to include only runners that are accepting or ignoring new jobs'
optional :status, type: String, values: ::Ci::Runner::AVAILABLE_STATUSES,
- desc: 'The status of the runners to show'
+ desc: 'The status of the runners to show'
optional :tag_list, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The tags of the runners to show'
use :pagination
end