Skip to content

Unable to set merge_access_levels and push_access_levels on new protected branch #536

Closed

Description

@willcbaker

Description of the problem, including code/CLI snippet

MASTERS = 40
DEVELOPERS = 30
ALLOW_MASTERS = {'group_id': None,
                 'user_id': None,
                 'access_level_description': 'Masters',
                 'access_level': MASTERS}
ALLOW_DEVELOPERS = {'group_id': None,
                    'user_id': None,
                    'access_level_description': 'Developers + Masters',
                    'access_level': DEVELOPERS}
p_branch = project.protectedbranches.create({'name': 'develop',
                                             'merge_access_levels': [ALLOW_MASTERS, ALLOW_DEVELOPERS],
                                             'push_access_levels': [ALLOW_MASTERS]})

Expected Behavior

modify merge and push access

Actual Behavior

Default protection

{'merge_access_levels': [{'access_level_description': 'Masters',
   'user_id': None,
   'access_level': 40,
   'group_id': None}],
 'name': 'master',
 'project_id': xxx,
 'push_access_levels': [{'access_level_description': 'Masters',
   'user_id': None,
   'access_level': 40,
   'group_id': None}]}

Specifications

  • python-gitlab version: 1.5
  • API version 4:
  • Gitlab server version (or gitlab.com): 10.6.3

Activity

  1. gpocentek commented on Jun 23, 2018

    @gpocentek
    Contributor

    Hi @willcbaker

    The API only lets you define the minimum access level required to push/merge to the protected branches. So you need something like:

    p_branch = project.protectedbranches.create({'name': 'develop',
                                                 'merge_access_level': gitlab.DEVELOPER_ACCESS,
                                                 'push_access_level': gitlab.MASTER_ACCESS})
  2. locked as resolved and limited conversation to collaborators on Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions