Support Deployment Approval Self-Approval Option in Public Rest API
Problem
We recently shipped Add approval settings "Prevent approval by MR m... (#381418 - closed), but the option can be updated via UI only. Users want to bulk-update multiple projects via API.
Related #381418 (comment 1254132068)
Proposal
Support ci_allow_pipeline_trigger_approve_deployment
option in Edit Project API.
For example:
diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb
index 5ec1f606ef21..35af27e0be2f 100644
--- a/app/controllers/projects/settings/ci_cd_controller.rb
+++ b/app/controllers/projects/settings/ci_cd_controller.rb
@@ -88,7 +88,7 @@ def permitted_project_params
:build_timeout_human_readable, :public_builds, :ci_separated_caches,
:auto_cancel_pending_pipelines, :ci_config_path, :auto_rollback_enabled,
auto_devops_attributes: [:id, :domain, :enabled, :deploy_strategy],
- ci_cd_settings_attributes: [:default_git_depth, :forward_deployment_enabled]
+ ci_cd_settings_attributes: [:default_git_depth, :forward_deployment_enabled, :allow_pipeline_trigger_approve_deployment]
].tap do |list|
list << :max_artifacts_size if can?(current_user, :update_max_artifacts_size, project)
end
diff --git a/lib/api/entities/project.rb b/lib/api/entities/project.rb
index 37be6903d8bc..abd12bbc79cf 100644
--- a/lib/api/entities/project.rb
+++ b/lib/api/entities/project.rb
@@ -108,6 +108,7 @@ class Project < BasicProjectDetails
expose :runners_token, documentation: { type: 'string', example: 'b8547b1dc37721d05889db52fa2f02' }, if: lambda { |_project, options| options[:user_can_admin_project] }
expose :ci_default_git_depth, documentation: { type: 'integer', example: 20 }
expose :ci_forward_deployment_enabled, documentation: { type: 'boolean' }
+ expose :allow_pipeline_trigger_approve_deployment, documentation: { type: 'boolean' }
expose(:ci_job_token_scope_enabled, documentation: { type: 'boolean' }) { |p, _| p.ci_outbound_job_token_scope_enabled? }
expose :ci_separated_caches, documentation: { type: 'boolean' }
expose :ci_opt_in_jwt, documentation: { type: 'boolean' }
diff --git a/lib/api/helpers/projects_helpers.rb b/lib/api/helpers/projects_helpers.rb
index 820ad2e9b33f..20546c840df7 100644
--- a/lib/api/helpers/projects_helpers.rb
+++ b/lib/api/helpers/projects_helpers.rb
@@ -102,6 +102,7 @@ module ProjectsHelpers
params :optional_update_params_ce do
optional :ci_forward_deployment_enabled, type: Boolean, desc: 'Prevent older deployment jobs that are still pending'
+ optional :allow_pipeline_trigger_approve_deployment, type: Boolean, desc: 'Prevent older deployment jobs that are still pending'
optional :ci_allow_fork_pipelines_to_run_in_parent_project, type: Boolean, desc: 'Allow fork merge request pipelines to run in parent project'
optional :ci_separated_caches, type: Boolean, desc: 'Enable or disable separated caches based on branch protection.'
optional :restrict_user_defined_variables, type: Boolean, desc: 'Restrict use of user-defined variables when triggering a pipeline'
@@ -139,6 +140,7 @@ def self.update_params_at_least_one_of
:ci_default_git_depth,
:ci_allow_fork_pipelines_to_run_in_parent_project,
:ci_forward_deployment_enabled,
+ :allow_pipeline_trigger_approve_deployment,
:ci_separated_caches,
:container_registry_access_level,
:container_expiration_policy_attributes,