群组 API

列出群组

获取授权用户的可见群组列表。进行未授权访问时,只返回公共群组。

默认情况下,此请求一次返回 20 个结果,因为 API 结果是分页的。

当进行未授权访问时,此端点还支持键集分页

参数:

参数 类型 是否必需 描述
skip_groups array of integers no 跳过通过的群组 ID
all_available boolean no 显示所有您可以访问的群组(对于授权用户,默认为 false;对于管理员,默认为 true
search string no 返回匹配搜索条件的授权群组的列表
order_by string no 根据 namepathidsimilarity 为群组排序(如果查询,引入于极狐GitLab 14.1)。默认为 name
sort string no 按照 ascdesc 顺序为群组排序。默认为 asc
statistics boolean no 包括群组统计(仅对管理员)
with_custom_attributes boolean no 响应中包括自定义属性(仅对管理员)
owned boolean no 限制为当前用户明确拥有的群组
min_access_level integer no 限制为当前用户至少有此访问级别的群组
top_level_only boolean no 限制为顶级群组,不包括所有子群组
GET /groups
[
  {
    "id": 1,
    "name": "Foobar Group",
    "path": "foo-bar",
    "description": "An interesting group",
    "visibility": "public",
    "share_with_group_lock": false,
    "require_two_factor_authentication": false,
    "two_factor_grace_period": 48,
    "project_creation_level": "developer",
    "auto_devops_enabled": null,
    "subgroup_creation_level": "owner",
    "emails_disabled": null,
    "mentions_disabled": null,
    "lfs_enabled": true,
    "default_branch_protection": 2,
    "avatar_url": "http://localhost:3000/uploads/group/avatar/1/foo.jpg",
    "web_url": "http://localhost:3000/groups/foo-bar",
    "request_access_enabled": false,
    "full_name": "Foobar Group",
    "full_path": "foo-bar",
    "file_template_project_id": 1,
    "parent_id": null,
    "created_at": "2020-01-15T12:36:29.590Z"
  }
]

当添加参数 statistics=true 并且授权用户是管理员,会返回额外群组统计。

GET /groups?statistics=true
[
  {
    "id": 1,
    "name": "Foobar Group",
    "path": "foo-bar",
    "description": "An interesting group",
    "visibility": "public",
    "share_with_group_lock": false,
    "require_two_factor_authentication": false,
    "two_factor_grace_period": 48,
    "project_creation_level": "developer",
    "auto_devops_enabled": null,
    "subgroup_creation_level": "owner",
    "emails_disabled": null,
    "mentions_disabled": null,
    "lfs_enabled": true,
    "default_branch_protection": 2,
    "avatar_url": "http://localhost:3000/uploads/group/avatar/1/foo.jpg",
    "web_url": "http://localhost:3000/groups/foo-bar",
    "request_access_enabled": false,
    "full_name": "Foobar Group",
    "full_path": "foo-bar",
    "file_template_project_id": 1,
    "parent_id": null,
    "created_at": "2020-01-15T12:36:29.590Z",
    "statistics": {
      "storage_size": 363,
      "repository_size": 33,
      "wiki_size": 100,
      "lfs_objects_size": 123,
      "job_artifacts_size": 57,
      "pipeline_artifacts_size": 0,
      "packages_size": 0,
      "snippets_size": 50,
      "uploads_size": 0
    }
  }
]

您可以通过名称或路径进行搜索,参见下文。

您可以使用以下内容通过自定义属性进行过滤:

GET /groups?custom_attributes[key]=value&custom_attributes[other_key]=other_value

列出群组的子群组

引入于极狐GitLab 10.3。

获取群组中可见直接子群组的列表。当进行未授权访问时,仅返回公共组。

默认情况下,此请求一次返回 20 个结果,因为 API 结果是分页的。

参数:

参数 类型 是否必需 描述
id integer/string yes 直系父群组的 ID 或 URL 编码的群组路径
skip_groups array of integers no 跳过通过的群组 ID
all_available boolean no 显示所有您可以访问的群组(对于授权用户,默认为 false;对于管理员,默认为 true
search string no 返回匹配查询条件的授权群组列表。仅搜索子群组短路径(不是完整路径)
order_by string no 根据 namepathid 为群组排序。默认为 name
sort string no 按照 ascdesc 顺序为群组排序。默认为 asc
statistics boolean no 包括群组统计(仅为管理员)
with_custom_attributes boolean no 响应中包括自定义属性(仅为管理员)
owned boolean no 限制为当前用户明确拥有的群组
min_access_level integer no 限制为当前用户至少有此访问级别的群组
GET /groups/:id/subgroups
[
  {
    "id": 1,
    "name": "Foobar Group",
    "path": "foo-bar",
    "description": "An interesting group",
    "visibility": "public",
    "share_with_group_lock": false,
    "require_two_factor_authentication": false,
    "two_factor_grace_period": 48,
    "project_creation_level": "developer",
    "auto_devops_enabled": null,
    "subgroup_creation_level": "owner",
    "emails_disabled": null,
    "mentions_disabled": null,
    "lfs_enabled": true,
    "default_branch_protection": 2,
    "avatar_url": "http://gitlab.example.com/uploads/group/avatar/1/foo.jpg",
    "web_url": "http://gitlab.example.com/groups/foo-bar",
    "request_access_enabled": false,
    "full_name": "Foobar Group",
    "full_path": "foo-bar",
    "file_template_project_id": 1,
    "parent_id": 123,
    "created_at": "2020-01-15T12:36:29.590Z"
  }
]

列出群组的下级群组

引入于极狐GitLab 13.5。

获取该群组的可见下级群组列表。当进行未授权的访问时,仅返回公共组。

默认情况下,此请求一次返回 20 个结果,因为 API 结果是分页的。

参数:

参数 类型 是否必需 描述
id integer/string yes 直系父群组的 ID 或 URL 编码的群组路径
skip_groups array of integers no 跳过通过的群组 ID
all_available boolean no 显示所有您可以访问的群组(对于授权用户,默认为 false;对于管理员,默认为 true
search string no 返回匹配查询条件的授权群组列表。仅搜索下级群组短路径(不是完整路径)
order_by string no 根据 namepathid 为群组排序。默认为 name
sort string no 按照 ascdesc 顺序为群组排序。默认为 asc
statistics boolean no 包括群组统计(仅为管理员)
with_custom_attributes boolean no 响应中包括自定义属性(仅为管理员)
owned boolean no 限制为当前用户明确拥有的群组
min_access_level integer no 限制为当前用户至少有此访问级别的群组
GET /groups/:id/descendant_groups
[
  {
    "id": 2,
    "name": "Bar Group",
    "path": "foo/bar",
    "description": "A subgroup of Foo Group",
    "visibility": "public",
    "share_with_group_lock": false,
    "require_two_factor_authentication": false,
    "two_factor_grace_period": 48,
    "project_creation_level": "developer",
    "auto_devops_enabled": null,
    "subgroup_creation_level": "owner",
    "emails_disabled": null,
    "mentions_disabled": null,
    "lfs_enabled": true,
    "default_branch_protection": 2,
    "avatar_url": "http://gitlab.example.com/uploads/group/avatar/1/bar.jpg",
    "web_url": "http://gitlab.example.com/groups/foo/bar",
    "request_access_enabled": false,
    "full_name": "Bar Group",
    "full_path": "foo/bar",
    "file_template_project_id": 1,
    "parent_id": 123,
    "created_at": "2020-01-15T12:36:29.590Z"
  },
  {
    "id": 3,
    "name": "Baz Group",
    "path": "foo/bar/baz",
    "description": "A subgroup of Bar Group",
    "visibility": "public",
    "share_with_group_lock": false,
    "require_two_factor_authentication": false,
    "two_factor_grace_period": 48,
    "project_creation_level": "developer",
    "auto_devops_enabled": null,
    "subgroup_creation_level": "owner",
    "emails_disabled": null,
    "mentions_disabled": null,
    "lfs_enabled": true,
    "default_branch_protection": 2,
    "avatar_url": "http://gitlab.example.com/uploads/group/avatar/1/baz.jpg",
    "web_url": "http://gitlab.example.com/groups/foo/bar/baz",
    "request_access_enabled": false,
    "full_name": "Baz Group",
    "full_path": "foo/bar/baz",
    "file_template_project_id": 1,
    "parent_id": 123,
    "created_at": "2020-01-15T12:36:29.590Z"
  }
]

列出群组项目

获取该群组中的项目列表。进行未授权访问时,仅返回公共项目。

默认情况下,此请求一次返回 20 个结果,因为 API 结果是分页的。

GET /groups/:id/projects

参数:

参数 类型 是否必需 描述
id integer/string yes 授权用户拥有的 ID 或 URL 编码的群组路径
archived boolean no 受归档状态限制
visibility string no 受可见性 publicinternalprivate 限制
order_by string no 返回按照 idnamepathcreated_atupdated_atsimilarity (1)或 last_activity_at 字段排序的项目。默认为 created_at
sort string no 返回按照 ascdesc 顺序排序的项目。默认为 desc
search string no 返回匹配搜索条件的授权项目列表
simple boolean no 仅返回每个项目的 ID、URL、名称和路径
owned boolean no 受限于当前用户拥有的项目
starred boolean no 受限于当前用户星标的项目
with_issues_enabled boolean no 受限于开启议题功能的项目。默认为 false
with_merge_requests_enabled boolean no 受限于开启合并请求功能的项目。默认为 false
with_shared boolean no 包括共享给此群组的项目。默认为 true
include_subgroups boolean no 包括此群组的子群组中的项目。默认为 false
min_access_level integer no 限制为当前用户至少有此访问级别的项目
with_custom_attributes boolean no 包括响应中的自定义属性(仅对管理员)
with_security_reports boolean no 仅返回构建中有安全报告产物的项目。也就是说”开启安全报告的项目”。默认为 false
  1. 按相似度排序:按照从提供的 search URL 参数计算的相似度分数对结果进行排序。 使用 order_by=similarity 时,会忽略 sort 参数。当未提供 search 参数时,API 返回按 name 排序的项目。

响应示例:

[
  {
    "id": 9,
    "description": "foo",
    "default_branch": "master",
    "tag_list": [], //deprecated, use `topics` instead
    "topics": [],
    "archived": false,
    "visibility": "internal",
    "ssh_url_to_repo": "git@gitlab.example.com/html5-boilerplate.git",
    "http_url_to_repo": "http://gitlab.example.com/h5bp/html5-boilerplate.git",
    "web_url": "http://gitlab.example.com/h5bp/html5-boilerplate",
    "name": "Html5 Boilerplate",
    "name_with_namespace": "Experimental / Html5 Boilerplate",
    "path": "html5-boilerplate",
    "path_with_namespace": "h5bp/html5-boilerplate",
    "issues_enabled": true,
    "merge_requests_enabled": true,
    "wiki_enabled": true,
    "jobs_enabled": true,
    "snippets_enabled": true,
    "created_at": "2016-04-05T21:40:50.169Z",
    "last_activity_at": "2016-04-06T16:52:08.432Z",
    "shared_runners_enabled": true,
    "creator_id": 1,
    "namespace": {
      "id": 5,
      "name": "Experimental",
      "path": "h5bp",
      "kind": "group"
    },
    "avatar_url": null,
    "star_count": 1,
    "forks_count": 0,
    "open_issues_count": 3,
    "public_jobs": true,
    "shared_with_groups": [],
    "request_access_enabled": false
  }
]
note可以使用 namespace 属性区分群组中的项目和共享给群组的项目。当一个项目已被共享到该群组时,它的 namespace 与请求所针对的群组不同。

列出群组的共享项目

获取共享给此群组的项目列表。进行未授权访问时,仅返回公共共享项目。

默认情况下,此请求一次返回 20 个结果,因为 API 结果是分页的。

GET /groups/:id/projects/shared

参数:

参数 类型 是否必需 描述
id integer/string yes 授权用户拥有的 ID 或 URL 编码的群组路径
archived boolean no 受归档状态限制
visibility string no 受可见性 publicinternalprivate 限制
order_by string no 返回按照 idnamepathcreated_atupdated_atlast_activity_at 字段排序的项目。默认为 created_at
sort string no 返回按照 ascdesc 顺序排序的项目。默认为 desc
search string no 返回匹配搜索条件的授权项目列表
simple boolean no 仅返回每个项目的 ID、URL、名称和路径
starred boolean no 受限于当前用户星标的项目
with_issues_enabled boolean no 受限于开启议题功能的项目。默认为 false
with_merge_requests_enabled boolean no 受限于开启合并请求功能的项目。默认为 false
min_access_level integer no 限制为当前用户至少有此访问级别的项目
with_custom_attributes boolean no 包括响应中的自定义属性(仅对管理员)

响应示例:

[
   {
      "id":8,
      "description":"Shared project for Html5 Boilerplate",
      "name":"Html5 Boilerplate",
      "name_with_namespace":"H5bp / Html5 Boilerplate",
      "path":"html5-boilerplate",
      "path_with_namespace":"h5bp/html5-boilerplate",
      "created_at":"2020-04-27T06:13:22.642Z",
      "default_branch":"master",
      "tag_list":[], //deprecated, use `topics` instead
      "topics":[],
      "ssh_url_to_repo":"ssh://git@gitlab.com/h5bp/html5-boilerplate.git",
      "http_url_to_repo":"https://gitlab.com/h5bp/html5-boilerplate.git",
      "web_url":"https://gitlab.com/h5bp/html5-boilerplate",
      "readme_url":"https://gitlab.com/h5bp/html5-boilerplate/-/blob/master/README.md",
      "avatar_url":null,
      "star_count":0,
      "forks_count":4,
      "last_activity_at":"2020-04-27T06:13:22.642Z",
      "namespace":{
         "id":28,
         "name":"H5bp",
         "path":"h5bp",
         "kind":"group",
         "full_path":"h5bp",
         "parent_id":null,
         "avatar_url":null,
         "web_url":"https://gitlab.com/groups/h5bp"
      },
      "_links":{
         "self":"https://gitlab.com/api/v4/projects/8",
         "issues":"https://gitlab.com/api/v4/projects/8/issues",
         "merge_requests":"https://gitlab.com/api/v4/projects/8/merge_requests",
         "repo_branches":"https://gitlab.com/api/v4/projects/8/repository/branches",
         "labels":"https://gitlab.com/api/v4/projects/8/labels",
         "events":"https://gitlab.com/api/v4/projects/8/events",
         "members":"https://gitlab.com/api/v4/projects/8/members"
      },
      "empty_repo":false,
      "archived":false,
      "visibility":"public",
      "resolve_outdated_diff_discussions":false,
      "container_registry_enabled":true,
      "container_expiration_policy":{
         "cadence":"7d",
         "enabled":true,
         "keep_n":null,
         "older_than":null,
         "name_regex":null,
         "name_regex_keep":null,
         "next_run_at":"2020-05-04T06:13:22.654Z"
      },
      "issues_enabled":true,
      "merge_requests_enabled":true,
      "wiki_enabled":true,
      "jobs_enabled":true,
      "snippets_enabled":true,
      "can_create_merge_request_in":true,
      "issues_access_level":"enabled",
      "repository_access_level":"enabled",
      "merge_requests_access_level":"enabled",
      "forking_access_level":"enabled",
      "wiki_access_level":"enabled",
      "builds_access_level":"enabled",
      "snippets_access_level":"enabled",
      "pages_access_level":"enabled",
      "security_and_compliance_access_level":"enabled",
      "emails_disabled":null,
      "shared_runners_enabled":true,
      "lfs_enabled":true,
      "creator_id":1,
      "import_status":"failed",
      "open_issues_count":10,
      "ci_default_git_depth":50,
      "ci_forward_deployment_enabled":true,
      "public_jobs":true,
      "build_timeout":3600,
      "auto_cancel_pending_pipelines":"enabled",
      "ci_config_path":null,
      "shared_with_groups":[
         {
            "group_id":24,
            "group_name":"Commit451",
            "group_full_path":"Commit451",
            "group_access_level":30,
            "expires_at":null
         }
      ],
      "only_allow_merge_if_pipeline_succeeds":false,
      "request_access_enabled":true,
      "only_allow_merge_if_all_discussions_are_resolved":false,
      "remove_source_branch_after_merge":true,
      "printing_merge_request_link_enabled":true,
      "merge_method":"merge",
      "suggestion_commit_message":null,
      "auto_devops_enabled":true,
      "auto_devops_deploy_strategy":"continuous",
      "autoclose_referenced_issues":true,
      "repository_storage":"default"
   }
]

群组详细信息

membership_lock 字段添加于极狐GitLab 14.10。

获取群组的所有详细信息。如果该群组可公开访问,则无需授权即可访问此端点。 以防如果该群组可公开访问,请求用户是管理员。如果用户是管理员或群组所有者,经过授权,则返回 runners_token

GET /groups/:id

参数:

参数 类型 是否必需 描述
id integer/string yes 授权用户拥有的 ID 或 URL 编码的群组路径
with_custom_attributes boolean no 响应中包括自定义属性(仅对管理员)
with_projects boolean no 包括属于特定群组的项目的详细信息(默认为 true)。(已废弃,计划在 API v5 中移除。获取群组内所有项目的详细信息,请使用列出群组的项目端点)
note项目中的 projectsshared_projects 属性已被废弃,并且计划在 API v5 中移除。 获取群组内所有项目的详细信息,请使用列出群组中的项目列出群组的共享项目端点。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/4"

此端点返回:

  • 极狐GitLab 12.5 及更早版本中的所有项目和共享项目。
  • 极狐GitLab 12.6 及更高版本中最多 100 个项目和共享项目。要获取群组内所有项目的详细信息,请使用列出群组的项目端点

  • 响应示例:
{
  "id": 4,
  "name": "Twitter",
  "path": "twitter",
  "description": "Aliquid qui quis dignissimos distinctio ut commodi voluptas est.",
  "visibility": "public",
  "avatar_url": null,
  "web_url": "https://gitlab.example.com/groups/twitter",
  "request_access_enabled": false,
  "full_name": "Twitter",
  "full_path": "twitter",
  "runners_token": "ba324ca7b1c77fc20bb9",
  "file_template_project_id": 1,
  "parent_id": null,
  "created_at": "2020-01-15T12:36:29.590Z",
  "shared_with_groups": [
    {
      "group_id": 28,
      "group_name": "H5bp",
      "group_full_path": "h5bp",
      "group_access_level": 20,
      "expires_at": null
    }
  ],
  "prevent_sharing_groups_outside_hierarchy": false,
  "projects": [ // Deprecated and will be removed in API v5
    {
      "id": 7,
      "description": "Voluptas veniam qui et beatae voluptas doloremque explicabo facilis.",
      "default_branch": "master",
      "tag_list": [], //deprecated, use `topics` instead
      "topics": [],
      "archived": false,
      "visibility": "public",
      "ssh_url_to_repo": "git@gitlab.example.com:twitter/typeahead-js.git",
      "http_url_to_repo": "https://gitlab.example.com/twitter/typeahead-js.git",
      "web_url": "https://gitlab.example.com/twitter/typeahead-js",
      "name": "Typeahead.Js",
      "name_with_namespace": "Twitter / Typeahead.Js",
      "path": "typeahead-js",
      "path_with_namespace": "twitter/typeahead-js",
      "issues_enabled": true,
      "merge_requests_enabled": true,
      "wiki_enabled": true,
      "jobs_enabled": true,
      "snippets_enabled": false,
      "container_registry_enabled": true,
      "created_at": "2016-06-17T07:47:25.578Z",
      "last_activity_at": "2016-06-17T07:47:25.881Z",
      "shared_runners_enabled": true,
      "creator_id": 1,
      "namespace": {
        "id": 4,
        "name": "Twitter",
        "path": "twitter",
        "kind": "group"
      },
      "avatar_url": null,
      "star_count": 0,
      "forks_count": 0,
      "open_issues_count": 3,
      "public_jobs": true,
      "shared_with_groups": [],
      "request_access_enabled": false
    },
    {
      "id": 6,
      "description": "Aspernatur omnis repudiandae qui voluptatibus eaque.",
      "default_branch": "master",
      "tag_list": [], //deprecated, use `topics` instead
      "topics": [],
      "archived": false,
      "visibility": "internal",
      "ssh_url_to_repo": "git@gitlab.example.com:twitter/flight.git",
      "http_url_to_repo": "https://gitlab.example.com/twitter/flight.git",
      "web_url": "https://gitlab.example.com/twitter/flight",
      "name": "Flight",
      "name_with_namespace": "Twitter / Flight",
      "path": "flight",
      "path_with_namespace": "twitter/flight",
      "issues_enabled": true,
      "merge_requests_enabled": true,
      "wiki_enabled": true,
      "jobs_enabled": true,
      "snippets_enabled": false,
      "container_registry_enabled": true,
      "created_at": "2016-06-17T07:47:24.661Z",
      "last_activity_at": "2016-06-17T07:47:24.838Z",
      "shared_runners_enabled": true,
      "creator_id": 1,
      "namespace": {
        "id": 4,
        "name": "Twitter",
        "path": "twitter",
        "kind": "group"
      },
      "avatar_url": null,
      "star_count": 0,
      "forks_count": 0,
      "open_issues_count": 8,
      "public_jobs": true,
      "shared_with_groups": [],
      "request_access_enabled": false
    }
  ],
  "shared_projects": [ // Deprecated and will be removed in API v5
    {
      "id": 8,
      "description": "Velit eveniet provident fugiat saepe eligendi autem.",
      "default_branch": "master",
      "tag_list": [], //deprecated, use `topics` instead
      "topics": [],
      "archived": false,
      "visibility": "private",
      "ssh_url_to_repo": "git@gitlab.example.com:h5bp/html5-boilerplate.git",
      "http_url_to_repo": "https://gitlab.example.com/h5bp/html5-boilerplate.git",
      "web_url": "https://gitlab.example.com/h5bp/html5-boilerplate",
      "name": "Html5 Boilerplate",
      "name_with_namespace": "H5bp / Html5 Boilerplate",
      "path": "html5-boilerplate",
      "path_with_namespace": "h5bp/html5-boilerplate",
      "issues_enabled": true,
      "merge_requests_enabled": true,
      "wiki_enabled": true,
      "jobs_enabled": true,
      "snippets_enabled": false,
      "container_registry_enabled": true,
      "created_at": "2016-06-17T07:47:27.089Z",
      "last_activity_at": "2016-06-17T07:47:27.310Z",
      "shared_runners_enabled": true,
      "creator_id": 1,
      "namespace": {
        "id": 5,
        "name": "H5bp",
        "path": "h5bp",
        "kind": "group"
      },
      "avatar_url": null,
      "star_count": 0,
      "forks_count": 0,
      "open_issues_count": 4,
      "public_jobs": true,
      "shared_with_groups": [
        {
          "group_id": 4,
          "group_name": "Twitter",
          "group_full_path": "twitter",
          "group_access_level": 30,
          "expires_at": null
        },
        {
          "group_id": 3,
          "group_name": "Gitlab Org",
          "group_full_path": "gitlab-org",
          "group_access_level": 10,
          "expires_at": "2018-08-14"
        }
      ]
    }
  ]
}

prevent_sharing_groups_outside_hierarchy 属性仅在顶级群组中。

极狐GitLab 专业版及更高版本的用户还可以看见 shared_runners_minutes_limitextra_shared_runners_minutes_limit 参数:

额外响应参数:

{
  "id": 4,
  "description": "Aliquid qui quis dignissimos distinctio ut commodi voluptas est.",
  "shared_runners_minutes_limit": 133,
  "extra_shared_runners_minutes_limit": 133,
  ...
}

极狐GitLab 专业版及更高版本的用户也能看见 marked_for_deletion_on 属性:

{
  "id": 4,
  "description": "Aliquid qui quis dignissimos distinctio ut commodi voluptas est.",
  "marked_for_deletion_on": "2020-04-03",
  ...
}

极狐GitLab 专业版及更高版本的用户也能看见 membership_lock 属性:

{
  "id": 4,
  "description": "Aliquid qui quis dignissimos distinctio ut commodi voluptas est.",
  "membership_lock": false,
  ...
}

添加参数 with_projects=false 时,不会返回项目。

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/4?with_projects=false"

响应示例:

{
  "id": 4,
  "name": "Twitter",
  "path": "twitter",
  "description": "Aliquid qui quis dignissimos distinctio ut commodi voluptas est.",
  "visibility": "public",
  "avatar_url": null,
  "web_url": "https://gitlab.example.com/groups/twitter",
  "request_access_enabled": false,
  "full_name": "Twitter",
  "full_path": "twitter",
  "file_template_project_id": 1,
  "parent_id": null
}

下载群组头像

获取群组头像。如果群组可公开访问,则可以不经授权访问此端点。

GET /groups/:id/avatar
参数 类型 是否必需 描述
id integer/string yes 群组 ID

示例:

curl --header "PRIVATE-TOKEN: $GITLAB_LOCAL_TOKEN" \
  --remote-header-name \
  --remote-name \
  "https://gitlab.example.com/api/v4/groups/4/avatar"

禁用结果限制

100 个结果的限制可能会破坏使用极狐GitLab 12.4 及更早版本所开发的集成。

对于极狐GitLab 12.5 到 13.12,可以使用列出群组的项目端点在迁移中禁用限制。

请求具有 Rails 控制台访问权限的极狐GitLab 管理员运行以下命令:

Feature.disable(:limit_projects_in_groups_api)

对于极狐GitLab 14.0 及更高版本,无法禁用限制。

新建群组

note在极狐GitLab SaaS 上,您必须使用极狐GitLab UI 创建没有父群组的群组。您不能使用 API 来执行此操作。

创建一个新的项目组。仅适用于可以创建群组的用户。

POST /groups

参数:

参数 类型 是否必需 描述
name string yes 群组名称
path string yes 群组路径
auto_devops_enabled boolean no 默认为群组内所有项目的 Auto DevOps 流水线
avatar mixed no 群组头像的镜像文件。引入于极狐GitLab 12.9
default_branch_protection integer no 参见 default_branch_protection 选项。默认为全局级别默认分支保护设置
description string no 群组描述
emails_disabled boolean no 禁用电子邮件通知
lfs_enabled boolean no 为群组中的项目启用/禁用大型文件存储(LFS)
mentions_disabled boolean no 禁用群组被提及的能力
parent_id integer no 创建嵌套群组的父群组 ID
project_creation_level string no 开发者是否能够在群组中创建项目。可以是 noone(没人可以)、maintainer(拥有维护者角色的用户)或 developer(拥有开发者或维护者角色的用户)
request_access_enabled boolean no 允许用户请求成员访问权限
require_two_factor_authentication boolean no 要求群组中的所有用户设置两步验证
share_with_group_lock boolean no 防止在群组中与另一个群组共享项目
subgroup_creation_level string no 允许创建子群组。可以是 owner(拥有者)或 maintainer(拥有维护者角色的用户)
two_factor_grace_period integer no 执行两步验证之前的时间(小时)
visibility string no 群组可见性:privateinternalpublic
membership_lock boolean no 用户无法到此群组的项目中
extra_shared_runners_minutes_limit integer no 仅可由管理员添加。此群组的额外 CI/CD 分钟数
shared_runners_minutes_limit integer no 仅可由管理员添加。此群组每月最大的 CI/CD 分钟数。可以是 nil(默认,继承系统默认、0(无限)或 > 0

default_branch_protection 选项

default_branch_protection 属性确定具有开发者或维护者角色的用户是否可以推送到适用的默认分支,如下表所述:

描述
0 无保护。具有开发者或维护者角色的用户可以:
- 推送新提交
- 强制推送
- 删除分支
1 部分保护。具有开发者或维护者角色的用户可以:
- 推送新提交
2 完整保护。只有具有维护者角色的用户可以:
- 推送新提交
3 保护以防止推送。具有维护者角色的用户可以:
- 推送新提交
- 强制推送
- 接收合并请求
具有开发者角色的用户可以:
- 接受合并请求

新建子群组

新建子群组与新建群组类似。您需要列出群组调用中的 parent_id。然后您可以输入以下内容:

  • subgroup_path
  • subgroup_name
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
     --header "Content-Type: application/json" \
     --data '{"path": "<subgroup_path>", "name": "<subgroup_name>", "parent_id": <parent_group_id> }' \
     "https://gitlab.example.com/api/v4/groups/"

向群组转移项目

将项目转移到群组命名空间。仅对实例管理员可用,尽管不需要管理员实例访问权限的替代 API 端点也可用。 当项目仓库中存在打标签的包时,传输项目可能会失败。

POST  /groups/:id/projects/:project_id

参数:

参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的目标群组路径
project_id integer/string yes ID 或 URL 编码的项目路径
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/groups/4/projects/56"

向新父群组转移群组/将子群组变更为顶级群组

引入于极狐GitLab 14.6。

向新父群组转移群组或将子群组变更为顶级群组。管理员和用户可用:

  • 具有要转移的群组的所有者角色。
  • 如果转移群组,则有权在新的父群组中创建子群组
  • 如果将子群组转换为顶级群组,则具有创建顶级群组的权限
POST  /groups/:id/transfer

参数:

参数 类型 是否必需 描述
id integer yes 要转移群组的 ID
group_id integer no 新父群组的 ID。如果未指定,则将要转移的群组改为顶级组
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/groups/4/transfer?group_id=7"

更新群组

更新项目群组。仅对群组拥有者和管理员可用。

PUT /groups/:id
参数 类型 是否必需 描述
id integer yes 群组 ID
name string no 群组名称
path string no 群组路径
auto_devops_enabled boolean no 默认为群组内所有项目的 Auto DevOps 流水线
avatar mixed no 群组头像的镜像文件。引入于极狐GitLab 12.9
default_branch_protection integer no 参见 default_branch_protection 选项
description string no 群组描述
emails_disabled boolean no 禁用电子邮件通知
lfs_enabled boolean no 为群组中的项目启用/禁用大型文件存储(LFS)
mentions_disabled boolean no 禁用群组被提及的能力
prevent_sharing_groups_outside_hierarchy boolean no 参见防止群组层次结构外的群组共享。此属性仅对顶级群组可用。引入于极狐GitLab 14.1
project_creation_level string no 开发者是否能够在群组中创建项目。可以是 noone(没人可以)、maintainer(拥有维护者角色的用户)或 developer(拥有开发者或维护者角色的用户)
request_access_enabled boolean no 允许用户请求成员访问权限
require_two_factor_authentication boolean no 要求群组中的所有用户设置两步验证
shared_runners_setting string no 参见 shared_runners_setting 选项。启用或禁用群组的子群组和项目的共享 Runner
share_with_group_lock boolean no 防止在群组中与另一个群组共享项目
subgroup_creation_level string no 允许创建子群组。可以是 owner(拥有者)或 maintainer(拥有维护者角色的用户)
two_factor_grace_period integer no 执行两步验证之前的时间(小时)
visibility string no 群组可见性:privateinternalpublic
extra_shared_runners_minutes_limit integer no 仅可由管理员设置。此群组的额外 CI/CD 分钟数
file_template_project_id integer no 加载自定义文件模板的项目 ID
membership_lock boolean no 用户无法添加到此群组的项目中
prevent_forking_outside_group boolean no 如果启用,用户不能从此群组派生项目到外部命名空间
shared_runners_minutes_limit integer no 仅可由管理员添加。此群组每月最大的 CI/CD 分钟数。可以是 nil(默认,继承系统默认、0(无限)或 > 0
note响应中的 projectsshared_projects 属性已被弃用并且计划在 API v5 中删除。 要获取群组内所有项目的详细信息,请使用列出群组的项目列出群组的共享项目端点。
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/groups/5?name=Experimental"

此端点返回:

  • 极狐GitLab 12.5 及更早版本中的所有项目和共享项目。
  • 极狐GitLab 12.6 及更高版本中的最多 100 个项目和共享项目。

要获取群组内所有项目的详细信息,请使用列出群组的项目端点

  • 响应示例:
{
  "id": 5,
  "name": "Experimental",
  "path": "h5bp",
  "description": "foo",
  "visibility": "internal",
  "avatar_url": null,
  "web_url": "http://gitlab.example.com/groups/h5bp",
  "request_access_enabled": false,
  "full_name": "Foobar Group",
  "full_path": "foo-bar",
  "file_template_project_id": 1,
  "parent_id": null,
  "created_at": "2020-01-15T12:36:29.590Z",
  "prevent_sharing_groups_outside_hierarchy": false,
  "projects": [ // Deprecated and will be removed in API v5
    {
      "id": 9,
      "description": "foo",
      "default_branch": "master",
      "tag_list": [], //deprecated, use `topics` instead
      "topics": [],
      "public": false,
      "archived": false,
      "visibility": "internal",
      "ssh_url_to_repo": "git@gitlab.example.com/html5-boilerplate.git",
      "http_url_to_repo": "http://gitlab.example.com/h5bp/html5-boilerplate.git",
      "web_url": "http://gitlab.example.com/h5bp/html5-boilerplate",
      "name": "Html5 Boilerplate",
      "name_with_namespace": "Experimental / Html5 Boilerplate",
      "path": "html5-boilerplate",
      "path_with_namespace": "h5bp/html5-boilerplate",
      "issues_enabled": true,
      "merge_requests_enabled": true,
      "wiki_enabled": true,
      "jobs_enabled": true,
      "snippets_enabled": true,
      "created_at": "2016-04-05T21:40:50.169Z",
      "last_activity_at": "2016-04-06T16:52:08.432Z",
      "shared_runners_enabled": true,
      "creator_id": 1,
      "namespace": {
        "id": 5,
        "name": "Experimental",
        "path": "h5bp",
        "kind": "group"
      },
      "avatar_url": null,
      "star_count": 1,
      "forks_count": 0,
      "open_issues_count": 3,
      "public_jobs": true,
      "shared_with_groups": [],
      "request_access_enabled": false
    }
  ]
}

prevent_sharing_groups_outside_hierarchy 属性仅在顶级群组中的响应中存在。

禁用结果限制

100 个结果的限制可能会破坏使用极狐GitLab 12.4 及更早版本开发的集成。

对于 12.5 到 13.12,可以使用列出群组的项目端点在迁移中禁用限制。

请求具有 Rails 控制台访问权限的极狐GitLab 管理员运行以下命令:

Feature.disable(:limit_projects_in_groups_api)

对于 14.0 及更高版本,无法禁用限制。

shared_runners_setting 选项

shared_runners_setting 属性决定共享 Runner 是否对群组的子群组和项目进行启用。

描述
enabled 为群组中所有项目和子群组启用共享 Runner
disabled_with_override 禁用此群组中所有项目和子群组的共享 Runner,但允许子群组覆盖此设置
disabled_and_unoverridable 禁用此群组中所有项目和子群组的共享 Runner,防止子群组覆盖此设置

上传群组头像

引入于极狐GitLab 12.9。

要从文件系统上传头像文件,请使用 --form 参数。这会使 curl 使用标题 Content-Type: multipart/form-data 发布数据。 file= 参数必须指向文件系统上的文件,并且前面有 @。例如:

curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/22" \
     --form "avatar=@/tmp/example.png"

移除群组

仅对群组所有者和管理员可用。

此端点:

  • 移除群组,并将后台作业排队以删除群组中的所有项目。
  • 自 12.8 以来,在专业版或更高级别中,标记要删除的群组。默认情况下删除发生在 7 天后,但这可以在实例设置中更改。
DELETE /groups/:id

参数:

参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径

如果用户有授权,则响应为 202 Accepted

NOTE: 如果 JiHuLab.com 群组链接到订阅,则无法删除它。要删除这样的群组,首先要将订阅和其他群组进行链接。

还原标记为删除的群组

引入于极狐GitLab 12.8。

还原标记为删除的群组。

POST /groups/:id/restore

参数:

参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径

查找群组

获取所有名称或路径中匹配您的字符串的群组。

GET /groups?search=foobar
[
  {
    "id": 1,
    "name": "Foobar Group",
    "path": "foo-bar",
    "description": "An interesting group"
  }
]

列出提供用户

引入于极狐GitLab 14.8。

获取给定群组提供的用户列表。不包括由子群组提供的用户。

至少需要该群组的维护者角色。

GET /groups/:id/provisioned_users

参数:

参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
username string no 返回具有特定用户名的单个用户
search string no 根据名称、电子邮件和用户名搜索用户
active boolean no 仅返回活跃用户
blocked boolean no 仅返回阻塞用户
created_after datetime no 返回特定时间后创建的用户
created_before datetime no 返回特定时间前创建的用户

响应示例:

[
  {
    id: 66,
    username: "user22",
    name: "John Doe22",
    state: "active",
    avatar_url: "https://www.gravatar.com/avatar/xxx?s=80&d=identicon",
    web_url: "http://my.gitlab.com/user22",
    created_at: "2021-09-10T12:48:22.381Z",
    bio: "",
    location: null,
    public_email: "",
    skype: "",
    linkedin: "",
    twitter: "",
    website_url: "",
    organization: null,
    job_title: "",
    pronouns: null,
    bot: false,
    work_information: null,
    followers: 0,
    following: 0,
    local_time: null,
    last_sign_in_at: null,
    confirmed_at: "2021-09-10T12:48:22.330Z",
    last_activity_on: null,
    email: "user22@example.org",
    theme_id: 1,
    color_scheme_id: 1,
    projects_limit: 100000,
    current_sign_in_at: null,
    identities: [ ],
    can_create_group: true,
    can_create_project: true,
    two_factor_enabled: false,
    external: false,
    private_profile: false,
    commit_email: "user22@example.org",
    shared_runners_minutes_limit: null,
    extra_shared_runners_minutes_limit: null
  },
  ...
]

钩子

也称为群组钩子和网络钩子。不同于系统范围的系统钩子和仅限于一个项目的项目钩子

列出群组钩子

获取群组钩子列表。

GET /groups/:id/hooks
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径

获取群组钩子

获取群组的特定钩子。

参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
hook_id integer yes 群组钩子 ID
GET /groups/:id/hooks/:hook_id
{
  "id": 1,
  "url": "http://example.com/hook",
  "group_id": 3,
  "push_events": true,
  "issues_events": true,
  "confidential_issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "confidential_note_events": true,
  "job_events": true,
  "pipeline_events": true,
  "wiki_page_events": true,
  "deployment_events": true,
  "releases_events": true,
  "subgroup_events": true,
  "enable_ssl_verification": true,
  "created_at": "2012-10-12T17:04:47Z"
}

添加群组钩子

向特定群组添加钩子。

POST /groups/:id/hooks
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
url string yes 钩子 URL
push_events boolean no 在推送事件上触发钩子
issues_events boolean no 在议题事件上触发钩子
confidential_issues_events boolean no 在私密议题事件上触发钩子
merge_requests_events boolean no 在合并请求事件上触发钩子
tag_push_events boolean no 在标签推送事件上触发钩子
note_events boolean no 在备注事件上触发钩子
confidential_note_events boolean no 在私密备注事件上触发钩子
job_events boolean no 在作业事件上触发钩子
pipeline_events boolean no 在流水线事件上触发钩子
wiki_page_events boolean no 在 Wiki 页面事件上触发钩子
deployment_events boolean no 在部署事件上触发钩子
releases_events boolean no 在发布事件上触发钩子
subgroup_events boolean no 在子群组事件上触发钩子
enable_ssl_verification boolean no 触发钩子时进行 SSL 验证
token string no 验证接收负载的 Secret 令牌,不在响应中返回

编辑群组钩子

为特定群组编辑钩子。

PUT /groups/:id/hooks/:hook_id
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
hook_id integer yes 群组钩子 ID
url string yes 钩子 URL
push_events boolean no 在推送事件上触发钩子
issues_events boolean no 在议题事件上触发钩子
confidential_issues_events boolean no 在私密议题事件上触发钩子
merge_requests_events boolean no 在合并请求事件上触发钩子
tag_push_events boolean no 在标签推送事件上触发钩子
note_events boolean no 在备注事件上触发钩子
confidential_note_events boolean no 在私密备注事件上触发钩子
job_events boolean no 在作业事件上触发钩子
pipeline_events boolean no 在流水线事件上触发钩子
wiki_page_events boolean no 在 Wiki 页面事件上触发钩子
deployment_events boolean no 在部署事件上触发钩子
releases_events boolean no 在发布事件上触发钩子
subgroup_events boolean no 在子群组事件上触发钩子
enable_ssl_verification boolean no 触发钩子时进行 SSL 验证
token string no 验证接收负载的 Secret 令牌,不在响应中返回

删除群组钩子

从群组中移除钩子。这是一种幂等方法,可以多次调用。 钩子可用或不可用。

DELETE /groups/:id/hooks/:hook_id
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
hook_id integer yes 群组钩子 ID

群组审计事件

可以通过群组审计事件 API 访问群组审计事件。

与 LDAP 同步群组

和其关联 LDAP 群组同步群组。仅群组拥有者和管理员可用。

POST /groups/:id/ldap_sync

参数:

  • id(必需)-用户群组的 ID 或路径

群组成员

请参见群组成员

LDAP 群组链接

列出、添加和删除 LDAP 群组链接。

列出 LDAP 群组链接

列出 LDAP 群组链接

GET /groups/:id/ldap_group_links
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径

用 CN 或筛选器添加 LDAP 群组链接

使用 CN 或筛选器添加 LDAP 群组链接。仅专业版及更高版本支持按筛选器添加群组链接。

POST /groups/:id/ldap_group_links
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
cn string no LDAP 群组的 CN
filter string no 群组的 LDAP 过滤器
group_access integer yes LDAP 群组成员的最小访问级别
provider string yes LDAP 群组链接的 LDAP 提供者
note要定义 LDAP 群组链接,提供 cnfilter,但不要两个都提供。

删除 LDAP 群组链接

删除 LDAP 群组链接。已废弃。预计在后续发布中移除。

DELETE /groups/:id/ldap_group_links/:cn
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
cn string yes LDAP 群组的 CN

删除特定 LDAP 提供者的 LDAP 群组链接。已废弃。预计在后续发布中移除。

DELETE /groups/:id/ldap_group_links/:provider/:cn
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
cn string yes LDAP 群组的 CN
provider string yes LDAP 群组链接的 LDAP 提供者

使用 CN 或筛选器删除 LDAP 群组链接

使用 CN 或筛选器删除 LDAP 群组链接。通过筛选器删除仅在专业版及更高版本中支持。

DELETE /groups/:id/ldap_group_links
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
cn string no LDAP 群组的 CN
filter string no 群组的 LDAP 筛选器
provider string yes LDAP 群组链接的 LDAP 提供者
note要删除 LDAP 群组链接,提供 cnfilter,但不要两个都提供。

群组中的命名空间

默认情况下,群组一次只能获得 20 个命名空间,因为 API 结果是分页的。

要获得更多(最多 100 个)命名空间,请将以下内容作为参数传递给 API 调用:

/groups?per_page=100

要切换页面,请添加:

/groups?per_page=100&page=2

群组徽章

详情请参见群组徽章

群组导入/导出

详情请参见群组导入/导出群组关系导出

和其他群组共享群组

这些端点创建和删除用于与另一个群组共享群组的链接。有关更多信息,请参见极狐GitLab 群组页面中的相关讨论。

创建和其他群组共享群组的链接

和其他群组共享群组。如果成功,则返回 200群组详情

POST /groups/:id/share
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
group_id integer yes 要共享的群组的 ID
group_access integer yes 要授予群组的访问级别
expires_at string no 共享过期日期。ISO 8601 格式:2016-09-26

删除和其他群组共享群组的链接

取消和其他群组共享群组。如果成功,返回 204,不返回任何内容。

DELETE /groups/:id/share/:group_id
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
group_id integer yes 要共享的群组 ID

推送规则

引入于极狐GitLab 13.4。

获取群组推送规则

获取群组的推送规则

仅群组拥有者和管理员可用。

GET /groups/:id/push_rule
参数 类型 是否必需 描述
id integer/string yes 群组 ID 或 URL 编码的群组路径
{
  "id": 2,
  "created_at": "2020-08-17T19:09:19.580Z",
  "commit_message_regex": "[a-zA-Z]",
  "commit_message_negative_regex": "[x+]",
  "branch_name_regex": "[a-z]",
  "deny_delete_tag": true,
  "member_check": true,
  "prevent_secrets": true,
  "author_email_regex": "^[A-Za-z0-9.]+@gitlab.com$",
  "file_name_regex": "(exe)$",
  "max_file_size": 100
}

极狐GitLab 专业版及更高版本的用户也能看见 commit_committer_checkreject_unsigned_commits 参数:

{
  "id": 2,
  "created_at": "2020-08-17T19:09:19.580Z",
  "commit_committer_check": true,
  "reject_unsigned_commits": false,
  ...
}

添加群组推送规则

推送规则添加到特定群组。

仅群组拥有者和管理员可用。

POST /groups/:id/push_rule
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
deny_delete_tag boolean no 拒绝删除标签
member_check boolean no 仅允许极狐GitLab 用户写提交
prevent_secrets boolean no 拒绝可能包括 Secret 的文件
commit_message_regex string no 所有提交信息必需匹配此属性提供的正则表达式。例如:Fixed \d+\..*
commit_message_negative_regex string no 不允许匹配此属性中提供的正则表达式的提交信息。例如:ssh\:\/\/
branch_name_regex string no 所有的分支名称必需匹配此属性中提供的正则表达式。例如: (feature |hotfix)\/*
author_email_regex string no 所有的提交作者电子邮件必需匹配此属性中提供的正则表达式。例如:@my-company.com$
file_name_regex string no 允许匹配此属性中提供的正则表达式的文件名称。例如:(jar |exe)$
max_file_size integer no 允许的最大文件大小(MB)
commit_committer_check boolean no 仅允许使用验证过的电子邮件推送的提交
reject_unsigned_commits boolean no 仅允许通过 GPG 签署的提交
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/19/push_rule"

响应:

{
    "id": 19,
    "created_at": "2020-08-31T15:53:00.073Z",
    "commit_message_regex": "[a-zA-Z]",
    "commit_message_negative_regex": "[x+]",
    "branch_name_regex": null,
    "deny_delete_tag": false,
    "member_check": false,
    "prevent_secrets": false,
    "author_email_regex": "^[A-Za-z0-9.]+@gitlab.com$",
    "file_name_regex": null,
    "max_file_size": 100
}

编辑群组推送规则

编辑特定群组的推送规则。

仅群组拥有者和管理员可用。

PUT /groups/:id/push_rule
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径
deny_delete_tag boolean no 拒绝删除标签
member_check boolean no 仅允许现存极狐GitLab 用户写提交
prevent_secrets boolean no 拒绝可能包括 Secret 的文件
commit_message_regex string no 所有提交信息必需匹配此属性提供的正则表达式。例如:Fixed \d+\..*
commit_message_negative_regex string no 不允许匹配此属性中提供的正则表达式的提交信息。例如:ssh\:\/\/
branch_name_regex string no ID 或 URL 编码的群组路径
deny_delete_tag boolean no 拒绝删除标签
member_check boolean no 仅允许极狐GitLab 用户写提交
prevent_secrets boolean no 拒绝可能包括 Secret 的文件
commit_message_regex string no 所有提交信息必需匹配此属性提供的正则表达式。例如:Fixed \d+\..*
commit_message_negative_regex string no 不允许匹配此属性中提供的正则表达式的提交信息。例如:ssh\:\/\/
branch_name_regex string no 所有的分支名称必需匹配此属性中提供的正则表达式。例如:(feature |hotfix)\/*
author_email_regex string no 所有的提交作者电子邮件必需匹配此属性中提供的正则表达式。例如:@my-company.com$
file_name_regex string no 允许匹配此属性中提供的正则表达式的文件名称。例如:(jar |exe)$
max_file_size integer no 允许的最大文件大小(MB)
commit_committer_check boolean no 仅允许使用验证过的电子邮件推送的提交
reject_unsigned_commits boolean no 仅允许通过 GPG 签署的提交
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/19/push_rule"

响应:

{
    "id": 19,
    "created_at": "2020-08-31T15:53:00.073Z",
    "commit_message_regex": "[a-zA-Z]",
    "commit_message_negative_regex": "[x+]",
    "branch_name_regex": null,
    "deny_delete_tag": false,
    "member_check": false,
    "prevent_secrets": false,
    "author_email_regex": "^[A-Za-z0-9.]+@staging.gitlab.com$",
    "file_name_regex": null,
    "max_file_size": 100
}

删除群组推送规则

删除群组推送规则

仅群组拥有者和管理员可用。

DELETE /groups/:id/push_rule
参数 类型 是否必需 描述
id integer/string yes ID 或 URL 编码的群组路径