diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-30 21:10:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-30 21:10:11 +0300 |
commit | c51425915fb1b2c367d6d828449b5cc7772ac104 (patch) | |
tree | e0bb2d9f3e0c9aaec6fe71a9da26f9bab5d9890c /app/services/ci | |
parent | f65227a163435d66e3f0b80f4c52ae59d8df39a2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/ci')
-rw-r--r-- | app/services/ci/pipelines/update_metadata_service.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/services/ci/pipelines/update_metadata_service.rb b/app/services/ci/pipelines/update_metadata_service.rb new file mode 100644 index 00000000000..2f2d648c13d --- /dev/null +++ b/app/services/ci/pipelines/update_metadata_service.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Ci + module Pipelines + class UpdateMetadataService + def initialize(pipeline, params) + @pipeline = pipeline + @params = params + end + + def execute + metadata = pipeline.pipeline_metadata + + metadata = pipeline.build_pipeline_metadata(project: pipeline.project) if metadata.nil? + + params[:name] = params[:name].strip if params.key?(:name) + + if metadata.update(params) + ServiceResponse.success(message: 'Pipeline metadata was updated', payload: pipeline) + else + ServiceResponse.error(message: 'Failed to update pipeline', payload: metadata.errors.full_messages, + reason: :bad_request) + end + end + + private + + attr_reader :pipeline, :params + end + end +end |