Use cascading settings to implement pipeline check in namespace settings

Proposal

Similar to the Disable self-approval at the instance level, this proposal is asking for a "Pipelines must succeed" checkbox in the group area that takes precedence over any project-level "Pipelines must succeed" checkboxes. This should go under the Group > Settings > General screen.

Implementation Plan

  1. Use https://docs.gitlab.com/ee/development/cascading_settings.html#cascading-settings to implement pipeline check in namespace settings.
  2. Add settings param in application settings and group settings api.
  3. override only_allow_merge_if_pipeline_succeeds column in app/models/project.rb so that it returns correct inherit settings values from ancestors (groups/subgroups).
  def only_allow_merge_if_pipeline_succeeds
    return Gitlab::CurrentSettings.only_allow_merge_if_pipeline_succeeds if Gitlab::CurrentSettings.lock_only_allow_merge_if_pipeline_succeeds
    return super unless group

    namespace_setting = group&.namespace_settings
    return namespace_setting.only_allow_merge_if_pipeline_succeeds if namespace_setting.only_allow_merge_if_pipeline_succeeds_locked_by_ancestor?

    super
  end
Edited by Harsimar Sandhu