Projects API

Projects API

GitLab 中的项目可以是私有的,内部的或公共的. 这由项目中的字段确定.

项目可见性级别的值为:

  • private :必须为每个用户显式授予项目访问权限.
  • internal :任何登录的用户都可以克隆该项目.
  • public :无需任何身份验证即可访问该项目.

Project merge method

merge_method当前有三个选项可供选择:

  • merge :为每个合并创建一个合并提交,只要没有冲突就允许合并.
  • rebase_merge :为每个合并创建一个合并提交,但是仅当可能进行快速合并时才允许合并. 这样,您可以确保在合并到目标分支后,如果此合并请求将生成,则该请求也将生成.
  • ff :没有创建合并提交,并且所有合并都被快速转发,这意味着仅当分支可以被快速转发时才允许合并.

List all projects

获取已认证用户跨 GitLab 的所有可见项目的列表. 在未经身份验证的情况下访问时,仅返回带有”简单”字段的公共项目.

注意:此端点支持所选order_by选项的键集分页 .

simple=true或用户未经身份验证时,这将返回如下内容:

  1. [ { "id": 4, "description": null, "default_branch": "master", "ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git", "web_url": "http://example.com/diaspora/diaspora-client", "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md", "tag_list": [ "example", "disapora client" ], "name": "Diaspora Client", "name_with_namespace": "Diaspora / Diaspora Client", "path": "diaspora-client", "path_with_namespace": "diaspora/diaspora-client", "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "forks_count": 0, "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png", "star_count": 0, }, { "id": 6, "description": null, "default_branch": "master", ...

当用户通过身份验证且未设置simple ,将返回以下内容:

  1. [ { "id": 4, "description": null, "default_branch": "master", "visibility": "private", "ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git", "web_url": "http://example.com/diaspora/diaspora-client", "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md", "tag_list": [ "example", "disapora client" ], "owner": { "id": 3, "name": "Diaspora", "created_at": "2013-09-30T13:46:02Z" }, "name": "Diaspora Client", "name_with_namespace": "Diaspora / Diaspora Client", "path": "diaspora-client", "path_with_namespace": "diaspora/diaspora-client", "issues_enabled": true, "open_issues_count": 1, "merge_requests_enabled": true, "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, "can_create_merge_request_in": true, "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { "id": 3, "name": "Diaspora", "path": "diaspora", "kind": "group", "full_path": "diaspora" }, "import_status": "none", "archived": false, "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png", "shared_runners_enabled": true, "forks_count": 0, "star_count": 0, "runners_token": "b8547b1dc37721d05889db52fa2f02", "ci_default_git_depth": 50, "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", "autoclose_referenced_issues": true, "suggestion_commit_message": null, "marked_for_deletion_at": "2020-04-03", // Deprecated and will be removed in API v5 in favor of marked_for_deletion_on "marked_for_deletion_on": "2020-04-03", "statistics": { "commit_count": 37, "storage_size": 1038090, "repository_size": 1038090, "wiki_size" : 0, "lfs_objects_size": 0, "job_artifacts_size": 0, "packages_size": 0 }, "_links": { "self": "http://example.com/api/v4/projects", "issues": "http://example.com/api/v4/projects/1/issues", "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", "labels": "http://example.com/api/v4/projects/1/labels", "events": "http://example.com/api/v4/projects/1/events", "members": "http://example.com/api/v4/projects/1/members" }, }, { "id": 6, "description": null, "default_branch": "master", "visibility": "private", "ssh_url_to_repo": "git@example.com:brightbox/puppet.git", "http_url_to_repo": "http://example.com/brightbox/puppet.git", "web_url": "http://example.com/brightbox/puppet", "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md", "tag_list": [ "example", "puppet" ], "owner": { "id": 4, "name": "Brightbox", "created_at": "2013-09-30T13:46:02Z" }, "name": "Puppet", "name_with_namespace": "Brightbox / Puppet", "path": "puppet", "path_with_namespace": "brightbox/puppet", "issues_enabled": true, "open_issues_count": 1, "merge_requests_enabled": true, "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, "can_create_merge_request_in": true, "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { "id": 4, "name": "Brightbox", "path": "brightbox", "kind": "group", "full_path": "brightbox" }, "import_status": "none", "import_error": null, "permissions": { "project_access": { "access_level": 10, "notification_level": 3 }, "group_access": { "access_level": 50, "notification_level": 3 } }, "archived": false, "avatar_url": null, "shared_runners_enabled": true, "forks_count": 0, "star_count": 0, "runners_token": "b8547b1dc37721d05889db52fa2f02", "ci_default_git_depth": 0, "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", "auto_devops_enabled": true, "auto_devops_deploy_strategy": "continuous", "repository_storage": "default", "approvals_before_merge": 0, "mirror": false, "mirror_user_id": 45, "mirror_trigger_builds": false, "only_mirror_protected_branches": false, "mirror_overwrites_diverged_branches": false, "external_authorization_classification_label": null, "packages_enabled": true, "service_desk_enabled": false, "service_desk_address": null, "autoclose_referenced_issues": true, "suggestion_commit_message": null, "statistics": { "commit_count": 12, "storage_size": 2066080, "repository_size": 2066080, "wiki_size" : 0, "lfs_objects_size": 0, "job_artifacts_size": 0, "packages_size": 0 }, "_links": { "self": "http://example.com/api/v4/projects", "issues": "http://example.com/api/v4/projects/1/issues", "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", "labels": "http://example.com/api/v4/projects/1/labels", "events": "http://example.com/api/v4/projects/1/events", "members": "http://example.com/api/v4/projects/1/members" } } ]

注意:对于使用 GitLab 的用户已不推荐使用marked_for_deletion_at属性,并将在 API v5 中将其删除,以支持marked_for_deletion_on属性.

在 GitLab 用户还会看到approvals_before_merge参数:

  1. [ { "id": 4, "description": null, "approvals_before_merge": 0, ... } ]

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

  1. GET /projects?custom_attributes[key]=value&custom_attributes[other_key]=other_value

从 GitLab 13.0 开始, 将被限制为 50,000 条记录 . 要检索超出此限制的项目,将需要进行 .

请注意,键集分页仅支持order_by=id . 其他排序选项不可用.

List user projects

获取给定用户拥有的可见项目的列表. 在未经身份验证的情况下访问时,仅返回公共项目.

  1. GET /users/:user_id/projects
Attribute Type Required Description
user_id string yes 用户的 ID 或用户名
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 仅返回每个项目的有限字段. 这是没有身份验证的无操作操作,因为这样只会返回简单的字段.
owned boolean no 受当前用户明确拥有的项目限制
membership boolean no 受当前用户是其成员的项目的限制
starred boolean no Limit by projects starred by the current user
statistics boolean no 包括项目统计
with_custom_attributes boolean no 在响应中包括 (仅管理员)
with_issues_enabled boolean no 受启用的问题限制功能
with_merge_requests_enabled boolean no 通过启用的合并请求限制功能
with_programming_language string no 受使用给定编程语言的项目限制
min_access_level integer no 受当前用户的最小访问权限限制
id_after integer no 将结果限制为 ID 大于指定 ID 的项目
id_before integer no 将结果限制为 ID 小于指定 ID 的项目

注意:此端点支持所选order_by选项的 .

  1. [ { "id": 4, "description": null, "default_branch": "master", "visibility": "private", "ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git", "web_url": "http://example.com/diaspora/diaspora-client", "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md", "tag_list": [ "example", "disapora client" ], "owner": { "id": 3, "name": "Diaspora", "created_at": "2013-09-30T13:46:02Z" }, "name": "Diaspora Client", "name_with_namespace": "Diaspora / Diaspora Client", "path": "diaspora-client", "path_with_namespace": "diaspora/diaspora-client", "issues_enabled": true, "open_issues_count": 1, "merge_requests_enabled": true, "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, "can_create_merge_request_in": true, "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { "id": 3, "name": "Diaspora", "path": "diaspora", "kind": "group", "full_path": "diaspora" }, "import_status": "none", "archived": false, "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png", "shared_runners_enabled": true, "forks_count": 0, "star_count": 0, "runners_token": "b8547b1dc37721d05889db52fa2f02", "ci_default_git_depth": 50, "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", "autoclose_referenced_issues": true, "suggestion_commit_message": null, "marked_for_deletion_at": "2020-04-03", // Deprecated and will be removed in API v5 in favor of marked_for_deletion_on "marked_for_deletion_on": "2020-04-03", "statistics": { "commit_count": 37, "storage_size": 1038090, "repository_size": 1038090, "wiki_size" : 0, "lfs_objects_size": 0, "job_artifacts_size": 0, "packages_size": 0 }, "_links": { "self": "http://example.com/api/v4/projects", "issues": "http://example.com/api/v4/projects/1/issues", "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", "labels": "http://example.com/api/v4/projects/1/labels", "events": "http://example.com/api/v4/projects/1/events", "members": "http://example.com/api/v4/projects/1/members" } }, { "id": 6, "description": null, "default_branch": "master", "visibility": "private", "ssh_url_to_repo": "git@example.com:brightbox/puppet.git", "http_url_to_repo": "http://example.com/brightbox/puppet.git", "web_url": "http://example.com/brightbox/puppet", "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md", "tag_list": [ "example", "puppet" ], "owner": { "id": 4, "name": "Brightbox", "created_at": "2013-09-30T13:46:02Z" }, "name": "Puppet", "name_with_namespace": "Brightbox / Puppet", "path": "puppet", "path_with_namespace": "brightbox/puppet", "issues_enabled": true, "open_issues_count": 1, "merge_requests_enabled": true, "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, "can_create_merge_request_in": true, "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { "id": 4, "name": "Brightbox", "path": "brightbox", "kind": "group", "full_path": "brightbox" }, "import_status": "none", "import_error": null, "permissions": { "project_access": { "access_level": 10, "notification_level": 3 }, "group_access": { "access_level": 50, "notification_level": 3 } }, "archived": false, "avatar_url": null, "shared_runners_enabled": true, "forks_count": 0, "star_count": 0, "runners_token": "b8547b1dc37721d05889db52fa2f02", "ci_default_git_depth": 0, "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", "auto_devops_enabled": true, "auto_devops_deploy_strategy": "continuous", "repository_storage": "default", "approvals_before_merge": 0, "mirror": false, "mirror_user_id": 45, "mirror_trigger_builds": false, "only_mirror_protected_branches": false, "mirror_overwrites_diverged_branches": false, "external_authorization_classification_label": null, "packages_enabled": true, "service_desk_enabled": false, "service_desk_address": null, "autoclose_referenced_issues": true, "suggestion_commit_message": null, "statistics": { "commit_count": 12, "storage_size": 2066080, "repository_size": 2066080, "wiki_size" : 0, "lfs_objects_size": 0, "job_artifacts_size": 0, "packages_size": 0 }, "_links": { "self": "http://example.com/api/v4/projects", "issues": "http://example.com/api/v4/projects/1/issues", "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", "labels": "http://example.com/api/v4/projects/1/labels", "events": "http://example.com/api/v4/projects/1/events", "members": "http://example.com/api/v4/projects/1/members" } } ]

List projects starred by a user

获取给定用户拥有的可见项目的列表. 在未经身份验证的情况下访问时,仅返回公共项目.

  1. GET /users/:user_id/starred_projects
Attribute Type Required Description
user_id string yes 用户的 ID 或用户名.
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 仅返回每个项目的有限字段. 这是没有身份验证的无操作操作,因为返回简单字段.
owned boolean no 受当前用户明确拥有的项目限制.
membership boolean no 受当前用户所属项目的限制.
starred boolean no 受当前用户加注星标的项目限制.
statistics boolean no 包括项目统计信息.
with_custom_attributes boolean no 在响应中包括 (仅管理员).
with_issues_enabled boolean no 受启用的问题限制功能.
with_merge_requests_enabled boolean no 通过启用的合并请求限制功能.
min_access_level integer no 受当前用户的最小访问权限限制.
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/users/5/starred_projects"

响应示例:

  1. [ { "id": 4, "description": null, "default_branch": "master", "visibility": "private", "ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git", "web_url": "http://example.com/diaspora/diaspora-client", "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md", "tag_list": [ "example", "disapora client" ], "owner": { "id": 3, "name": "Diaspora", "created_at": "2013-09-30T13:46:02Z" }, "name": "Diaspora Client", "name_with_namespace": "Diaspora / Diaspora Client", "path": "diaspora-client", "path_with_namespace": "diaspora/diaspora-client", "issues_enabled": true, "open_issues_count": 1, "merge_requests_enabled": true, "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, "can_create_merge_request_in": true, "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { "id": 3, "name": "Diaspora", "path": "diaspora", "kind": "group", "full_path": "diaspora" }, "import_status": "none", "archived": false, "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png", "shared_runners_enabled": true, "forks_count": 0, "star_count": 0, "runners_token": "b8547b1dc37721d05889db52fa2f02", "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", "autoclose_referenced_issues": true, "suggestion_commit_message": null, "statistics": { "commit_count": 37, "storage_size": 1038090, "repository_size": 1038090, "lfs_objects_size": 0, "job_artifacts_size": 0 }, "_links": { "self": "http://example.com/api/v4/projects", "issues": "http://example.com/api/v4/projects/1/issues", "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", "labels": "http://example.com/api/v4/projects/1/labels", "events": "http://example.com/api/v4/projects/1/events", "members": "http://example.com/api/v4/projects/1/members" } }, { "id": 6, "description": null, "default_branch": "master", "visibility": "private", "ssh_url_to_repo": "git@example.com:brightbox/puppet.git", "http_url_to_repo": "http://example.com/brightbox/puppet.git", "web_url": "http://example.com/brightbox/puppet", "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md", "tag_list": [ "example", "puppet" ], "owner": { "id": 4, "name": "Brightbox", "created_at": "2013-09-30T13:46:02Z" }, "name": "Puppet", "name_with_namespace": "Brightbox / Puppet", "path": "puppet", "path_with_namespace": "brightbox/puppet", "issues_enabled": true, "open_issues_count": 1, "merge_requests_enabled": true, "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, "can_create_merge_request_in": true, "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { "id": 4, "name": "Brightbox", "path": "brightbox", "kind": "group", "full_path": "brightbox" }, "import_status": "none", "import_error": null, "permissions": { "project_access": { "access_level": 10, "notification_level": 3 }, "group_access": { "access_level": 50, "notification_level": 3 } }, "archived": false, "avatar_url": null, "shared_runners_enabled": true, "forks_count": 0, "star_count": 0, "runners_token": "b8547b1dc37721d05889db52fa2f02", "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", "auto_devops_enabled": true, "auto_devops_deploy_strategy": "continuous", "repository_storage": "default", "approvals_before_merge": 0, "mirror": false, "mirror_user_id": 45, "mirror_trigger_builds": false, "only_mirror_protected_branches": false, "mirror_overwrites_diverged_branches": false, "external_authorization_classification_label": null, "packages_enabled": true, "service_desk_enabled": false, "service_desk_address": null, "autoclose_referenced_issues": true, "suggestion_commit_message": null, "statistics": { "commit_count": 12, "storage_size": 2066080, "repository_size": 2066080, "lfs_objects_size": 0, "job_artifacts_size": 0 }, "_links": { "self": "http://example.com/api/v4/projects", "issues": "http://example.com/api/v4/projects/1/issues", "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", "labels": "http://example.com/api/v4/projects/1/labels", "events": "http://example.com/api/v4/projects/1/events", "members": "http://example.com/api/v4/projects/1/members" } } ]

Get single project

获取一个特定的项目. 如果可以公开访问该项目,则无需身份验证即可访问该端点.

  1. GET /projects/:id
Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径
statistics boolean no 包括项目统计
license boolean no 包括项目许可证数据
with_custom_attributes boolean no 在响应中包括 (仅管理员)

    在 GitLab 用户入门,青铜或更高还会看到approvals_before_merge参数:

    1. { "id": 3, "description": null, "approvals_before_merge": 0, ... }

    注意 :GitLab 11.11 中了namespace上的web_urlavatar_url属性.

    如果项目是 fork,并且您提供了有效的令牌进行身份验证,则forked_from_project字段将出现在响应中.

    1. { "id":3, ... "forked_from_project":{ "id":13083, "description":"GitLab Community Edition", "name":"GitLab Community Edition", "name_with_namespace":"GitLab.org / GitLab Community Edition", "path":"gitlab-foss", "path_with_namespace":"gitlab-org/gitlab-foss", "created_at":"2013-09-26T06:02:36.000Z", "default_branch":"master", "tag_list":[], "ssh_url_to_repo":"git@gitlab.com:gitlab-org/gitlab-foss.git", "http_url_to_repo":"https://gitlab.com/gitlab-org/gitlab-foss.git", "web_url":"https://gitlab.com/gitlab-org/gitlab-foss", "avatar_url":"https://assets.gitlab-static.net/uploads/-/system/project/avatar/13083/logo-extra-whitespace.png", "license_url": "https://gitlab.com/gitlab-org/gitlab/blob/master/LICENSE", "license": { "key": "mit", "name": "MIT License", "nickname": null, "html_url": "http://choosealicense.com/licenses/mit/", "source_url": "https://opensource.org/licenses/MIT", }, "star_count":3812, "forks_count":3561, "last_activity_at":"2018-01-02T11:40:26.570Z", "namespace": { "id": 72, "name": "GitLab.org", "path": "gitlab-org", "kind": "group", "full_path": "gitlab-org", "parent_id": null } } ... }

    Get project users

    获取项目的用户列表.

    1. GET /projects/:id/users
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或
    search string no 搜索特定用户
    skip_users 整数数组 no 筛选出具有指定 ID 的用户
    1. [ { "id": 1, "username": "john_smith", "name": "John Smith", "state": "active", "avatar_url": "http://localhost:3000/uploads/user/avatar/1/cd8.jpeg", "web_url": "http://localhost:3000/john_smith" }, { "id": 2, "username": "jack_smith", "name": "Jack Smith", "state": "blocked", "avatar_url": "http://gravatar.com/../e32131cd8.jpeg", "web_url": "http://localhost:3000/jack_smith" } ]

    Get project events

    请参考 .

    Create project

    创建一个经过身份验证的用户拥有的新项目.

    1. POST /projects
    Attribute Type Required Description
    name string 是,如果未提供路径 新项目的名称. 如果未提供,则等于路径.
    path string 是,如果未提供名称 新项目的存储库名称. 如果未提供,则根据名称生成(生成的小写字母加短划线).
    namespace_id integer no 新项目的命名空间(默认为当前用户的命名空间)
    default_branch string no master默认
    description string no 简短的项目说明
    issues_enabled boolean no (不建议使用)为此项目启用问题. 改用issues_access_level
    merge_requests_enabled boolean no (不建议使用)为此项目启用合并请求. 改用merge_requests_access_level
    jobs_enabled boolean no (不建议使用)为此项目启用作业. 改用builds_access_level
    wiki_enabled boolean no (已弃用)为此项目启用 Wiki. 改用wiki_access_level
    snippets_enabled boolean no (不建议使用)为此项目启用摘要. 请改用snippets_access_level
    issues_access_level string no disabledprivateenabled
    repository_access_level string no disabledprivateenabled
    merge_requests_access_level string no disabledprivateenabled
    forking_access_level string no disabledprivateenabled
    builds_access_level string no disabledprivateenabled
    wiki_access_level string no disabledprivateenabled
    snippets_access_level string no disabledprivateenabled
    pages_access_level string no disabledprivateenabledpublic
    emails_disabled boolean no 禁用电子邮件通知
    show_default_award_emojis boolean no 显示默认的奖励表情符号
    resolve_outdated_diff_discussions boolean no 自动解决合并请求差异讨论(通过推送更改)
    container_registry_enabled boolean no 为该项目启用容器注册表
    container_expiration_policy_attributes hash no 更新此项目的图像过期策略. 接受: cadence (字符串), keep_n (字符串), older_than (字符串), name_regex (字符串), name_regex_delete (字符串), name_regex_keep (字符串), enabled (布尔值)
    shared_runners_enabled boolean no 为此项目启用共享跑步者
    visibility string no See
    import_url string no 从中导入存储库的 URL
    public_builds boolean no 如果为true ,则非项目成员可以查看作业
    only_allow_merge_if_pipeline_succeeds boolean no 设置是否只能将合并请求与成功的作业合并
    allow_merge_on_skipped_pipeline boolean no 设置是否可以将合并请求与跳过的作业合并
    only_allow_merge_if_all_discussions_are_resolved boolean no 设置是否仅在所有讨论都解决后才能合并合并请求
    merge_method string no 设置使用的合并方法
    autoclose_referenced_issues boolean no 设置是否自动关闭默认分支上的引用问题
    remove_source_branch_after_merge boolean no 默认情况下,为所有新合并请求启用” Delete source branch选项
    lfs_enabled boolean no 启用 LFS
    request_access_enabled boolean no 允许用户请求成员访问
    tag_list array no 项目标签列表; 放置标签数组,这些标签应最终分配给项目
    avatar mixed no 项目头像的图像文件
    boolean no 从命令行推送时显示创建/查看合并请求的链接
    build_git_strategy string no Git 策略. 默认为fetch
    build_timeout integer no 作业可以运行的最长时间(以分钟为单位)(以秒为单位)
    auto_cancel_pending_pipelines string no 自动取消挂起的管道(注意:这不是布尔值,但已启用/禁用
    build_coverage_regex string no 测试覆盖率解析
    ci_config_path string no CI 配置文件的路径
    auto_devops_enabled boolean no 为该项目启用 Auto DevOps
    auto_devops_deploy_strategy string no 自动部署策略( continuousmanualtimed_incremental
    repository_storage string no 存储库位于哪个存储分片上. 仅适用于管理员
    approvals_before_merge integer no 默认情况下,应有多少个批准者批准合并请求
    external_authorization_classification_label string no 项目的分类标签
    mirror boolean no 在项目中启用拉镜像
    mirror_trigger_builds boolean no 拉镜像触发器构建
    initialize_with_readme boolean no 默认为false
    template_name string no 不使用use_custom_template ,为 . 与use_custom_template使用时,自定义项目模板的名称
    template_project_id integer no use_custom_template使用时,是自定义项目模板的项目 ID. 这比使用template_name更可取,因为template_name可能含糊.
    use_custom_template boolean no 使用自定义实例或 (带有group_with_project_templates_id )项目模板
    group_with_project_templates_id integer no 对于组级别的自定义模板,指定所有自定义项目模板所源自的组的 ID. 将实例级模板留空. 要求use_custom_template为 true
    packages_enabled boolean no 启用或禁用软件包存储库功能

    注意:如果您的 HTTP 存储库不可公开访问,请将身份验证信息添加到 URL: https://username:password@gitlab.company.com/group/project.git ,其中password是启用了api范围的公共访问密钥.

    Create project for user

    创建一个由指定用户拥有的新项目. 仅适用于管理员.

    1. POST /projects/user/:user_id
    Attribute Type Required Description
    user_id integer yes 项目所有者的用户标识
    name string yes 新项目的名称
    path string no 新项目的自定义存储库名称. 默认情况下根据名称生成
    namespace_id integer no Namespace for the new project (defaults to the current user’s namespace)
    description string no 简短的项目说明
    issues_enabled boolean no (不建议使用)为此项目启用问题. 改用issues_access_level
    merge_requests_enabled boolean no (不建议使用)为此项目启用合并请求. 改用merge_requests_access_level
    jobs_enabled boolean no (不建议使用)为此项目启用作业. 改用builds_access_level
    wiki_enabled boolean no (已弃用)为此项目启用 Wiki. 改用wiki_access_level
    snippets_enabled boolean no (不建议使用)为此项目启用摘要. 请改用snippets_access_level
    issues_access_level string no disabledprivateenabled
    repository_access_level string no disabledprivateenabled
    merge_requests_access_level string no disabledprivateenabled
    forking_access_level string no disabledprivateenabled
    builds_access_level string no disabledprivateenabled
    wiki_access_level string no disabledprivateenabled
    snippets_access_level string no disabledprivateenabled
    pages_access_level string no disabledprivateenabledpublic
    emails_disabled boolean no 禁用电子邮件通知
    show_default_award_emojis boolean no 显示默认的奖励表情符号
    resolve_outdated_diff_discussions boolean no 自动解决合并请求差异讨论(通过推送更改)
    container_registry_enabled boolean no 为该项目启用容器注册表
    shared_runners_enabled boolean no 为此项目启用共享跑步者
    visibility string no See
    import_url string no 从中导入存储库的 URL
    public_builds boolean no 如果为true ,则非项目成员可以查看作业
    only_allow_merge_if_pipeline_succeeds boolean no 设置是否只能将合并请求与成功的作业合并
    allow_merge_on_skipped_pipeline boolean no 设置是否可以将合并请求与跳过的作业合并
    only_allow_merge_if_all_discussions_are_resolved boolean no 设置是否仅在所有讨论都解决后才能合并合并请求
    merge_method string no 设置使用的合并方法
    autoclose_referenced_issues boolean no 设置是否自动关闭默认分支上的引用问题
    suggestion_commit_message string no 用于应用合并请求建议的提交消息
    remove_source_branch_after_merge boolean no 默认情况下,为所有新合并请求启用” Delete source branch选项
    lfs_enabled boolean no 启用 LFS
    request_access_enabled boolean no 允许用户请求成员访问
    tag_list array no 项目标签列表; 放置标签数组,这些标签应最终分配给项目
    avatar mixed no 项目头像的图像文件
    printing_merge_request_link_enabled boolean no 从命令行推送时显示创建/查看合并请求的链接
    build_git_strategy string no Git 策略. 默认为fetch
    build_timeout integer no 作业可以运行的最长时间(以分钟为单位)(以秒为单位)
    auto_cancel_pending_pipelines string no 自动取消挂起的管道(注意:这不是布尔值,但已启用/禁用
    build_coverage_regex string no 测试覆盖率解析
    ci_config_path string no CI 配置文件的路径
    auto_devops_enabled boolean no 为该项目启用 Auto DevOps
    auto_devops_deploy_strategy string no 自动部署策略( continuousmanualtimed_incremental
    repository_storage string no 存储库位于哪个存储分片上. 仅适用于管理员
    approvals_before_merge integer no 默认情况下,应有多少个批准者批准合并请求
    external_authorization_classification_label string no 项目的分类标签
    mirror boolean no 在项目中启用拉镜像
    mirror_trigger_builds boolean no 拉镜像触发器构建
    initialize_with_readme boolean no 默认为false
    template_name string no 不使用use_custom_template ,为 . 与use_custom_template使用时,自定义项目模板的名称
    use_custom_template boolean no Use either custom instance or (with group_with_project_templates_id) project template
    group_with_project_templates_id integer no 对于组级别的自定义模板,指定所有自定义项目模板所源自的组的 ID. 将实例级模板留空. 要求use_custom_template为 true
    packages_enabled boolean no 启用或禁用软件包存储库功能

    注意:如果您的 HTTP 存储库不可公开访问,请将身份验证信息添加到 URL: https://username:password@gitlab.company.com/group/project.git ,其中password是启用了api范围的公共访问密钥.

    Edit project

    1. PUT /projects/:id
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或
    name string no 项目名称
    path string no 项目的自定义存储库名称. 默认情况下根据名称生成
    default_branch string no master默认
    description string no 简短的项目说明
    issues_enabled boolean no (不建议使用)为此项目启用问题. 改用issues_access_level
    merge_requests_enabled boolean no (不建议使用)为此项目启用合并请求. 改用merge_requests_access_level
    jobs_enabled boolean no (不建议使用)为此项目启用作业. 改用builds_access_level
    wiki_enabled boolean no (已弃用)为此项目启用 Wiki. 改用wiki_access_level
    snippets_enabled boolean no (不建议使用)为此项目启用摘要. 请改用snippets_access_level
    issues_access_level string no disabledprivateenabled
    repository_access_level string no disabledprivateenabled
    merge_requests_access_level string no disabledprivateenabled
    forking_access_level string no disabledprivateenabled
    builds_access_level string no disabledprivateenabled
    wiki_access_level string no disabledprivateenabled
    snippets_access_level string no disabledprivateenabled
    pages_access_level string no disabledprivateenabledpublic
    emails_disabled boolean no 禁用电子邮件通知
    show_default_award_emojis boolean no 显示默认的奖励表情符号
    resolve_outdated_diff_discussions boolean no 自动解决合并请求差异讨论(通过推送更改)
    container_registry_enabled boolean no 为该项目启用容器注册表
    container_expiration_policy_attributes hash no 更新此项目的图像过期策略. 接受: cadence (字符串), keep_n (字符串), older_than (字符串), name_regex (字符串), name_regex_delete (字符串), name_regex_keep (字符串), enabled (布尔值)
    shared_runners_enabled boolean no 为此项目启用共享跑步者
    visibility string no See project visibility level
    import_url string no 从中导入存储库的 URL
    public_builds boolean no 如果为true ,则非项目成员可以查看作业
    only_allow_merge_if_pipeline_succeeds boolean no 设置是否只能将合并请求与成功的作业合并
    allow_merge_on_skipped_pipeline boolean no 设置是否可以将合并请求与跳过的作业合并
    only_allow_merge_if_all_discussions_are_resolved boolean no 设置是否仅在所有讨论都解决后才能合并合并请求
    merge_method string no 设置使用的
    autoclose_referenced_issues boolean no 设置是否自动关闭默认分支上的引用问题
    suggestion_commit_message string no 用于应用合并请求建议的提交消息
    remove_source_branch_after_merge boolean no 默认情况下,为所有新合并请求启用” Delete source branch选项
    lfs_enabled boolean no 启用 LFS
    request_access_enabled boolean no 允许用户请求成员访问
    tag_list array no 项目标签列表; 放置标签数组,这些标签应最终分配给项目
    avatar mixed no 项目头像的图像文件
    build_git_strategy string no Git 策略. 默认为fetch
    build_timeout integer no 作业可以运行的最长时间(以分钟为单位)(以秒为单位)
    auto_cancel_pending_pipelines string no 自动取消挂起的管道(注意:这不是布尔值,但已启用/禁用
    build_coverage_regex string no 测试覆盖率解析
    ci_config_path string no CI 配置文件的路径
    ci_default_git_depth integer no 浅克隆的默认修订版本数
    boolean no 为该项目启用 Auto DevOps
    auto_devops_deploy_strategy string no 自动部署策略( continuousmanualtimed_incremental
    repository_storage string no 存储库位于哪个存储分片上. 仅适用于管理员
    approvals_before_merge integer no How many approvers should approve merge request by default
    external_authorization_classification_label string no 项目的分类标签
    mirror boolean no 在项目中启用拉镜像
    mirror_user_id integer no 用户负责拉镜事件周围的所有活动. 只能由管理员设置.
    mirror_trigger_builds boolean no 拉镜像触发器构建
    only_mirror_protected_branches boolean no 仅镜像保护的分支
    mirror_overwrites_diverged_branches boolean no 拉镜将覆盖分散的分支
    packages_enabled boolean no 启用或禁用软件包存储库功能
    service_desk_enabled boolean no 启用或禁用服务台功能

    注意:如果您的 HTTP 存储库不可公开访问,请将身份验证信息添加到 URL: https://username:password@gitlab.company.com/group/project.git ,其中password是启用了api范围的公共访问密钥.

    Fork project

    将项目派生到已认证用户或提供的用户的用户名称空间中.

    项目的分叉操作是异步的,并在后台作业中完成. 该请求将立即返回. 要确定项目的分支是否已完成,请查询import_status以获取新项目.

    1. POST /projects/:id/fork
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    namespace integer/string no (不建议使用)项目将分叉到的名称空间的 ID 或路径
    namespace_id integer no 项目将分叉到的名称空间的 ID
    namespace_path string no 项目将分叉到的名称空间的路径
    path string no 分叉后将分配给结果项目的路径
    name string no 分叉后将分配给结果项目的名称

    注意:此功能是在 GitLab 10.1 中引入的.

    列出呼叫用户可访问的与指定项目具有已建立的分叉关系的项目

    1. GET /projects/:id/forks
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或
    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 仅返回每个项目的有限字段. 这是没有身份验证的无操作操作,因为这样只会返回简单的字段.
    owned boolean no 受当前用户明确拥有的项目限制
    membership boolean no 受当前用户是其成员的项目的限制
    starred boolean no 受当前用户加注星标的项目限制
    statistics boolean no 包括项目统计
    with_custom_attributes boolean no 在响应中包括自定义属性 (仅管理员)
    with_issues_enabled boolean no 受启用的问题限制功能
    with_merge_requests_enabled boolean no 通过启用的合并请求限制功能
    min_access_level integer no 受当前用户的最小限制
    1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/forks"

    响应示例:

    1. [ { "id": 3, "description": null, "default_branch": "master", "visibility": "internal", "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", "tag_list": [ "example", "disapora project" ], "name": "Diaspora Project Site", "name_with_namespace": "Diaspora / Diaspora Project Site", "path": "diaspora-project-site", "path_with_namespace": "diaspora/diaspora-project-site", "issues_enabled": true, "open_issues_count": 1, "merge_requests_enabled": true, "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, "can_create_merge_request_in": true, "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { "id": 3, "name": "Diaspora", "path": "diaspora", "kind": "group", "full_path": "diaspora" }, "import_status": "none", "archived": true, "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png", "shared_runners_enabled": true, "forks_count": 0, "star_count": 1, "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", "autoclose_referenced_issues": true, "suggestion_commit_message": null, "_links": { "self": "http://example.com/api/v4/projects", "issues": "http://example.com/api/v4/projects/1/issues", "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", "labels": "http://example.com/api/v4/projects/1/labels", "events": "http://example.com/api/v4/projects/1/events", "members": "http://example.com/api/v4/projects/1/members" } } ]

    Star a project

    明星给定的项目. 如果项目已加星标,则返回状态码304 .

    Attribute Type Required Description
    id integer/string yes 项目的 ID 或
    1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/star"

    响应示例:

    1. { "id": 3, "description": null, "default_branch": "master", "visibility": "internal", "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", "tag_list": [ "example", "disapora project" ], "name": "Diaspora Project Site", "name_with_namespace": "Diaspora / Diaspora Project Site", "path": "diaspora-project-site", "path_with_namespace": "diaspora/diaspora-project-site", "issues_enabled": true, "open_issues_count": 1, "merge_requests_enabled": true, "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, "can_create_merge_request_in": true, "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { "id": 3, "name": "Diaspora", "path": "diaspora", "kind": "group", "full_path": "diaspora" }, "import_status": "none", "archived": true, "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png", "license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE", "license": { "key": "lgpl-3.0", "name": "GNU Lesser General Public License v3.0", "nickname": "GNU LGPLv3", "html_url": "http://choosealicense.com/licenses/lgpl-3.0/", "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt" }, "shared_runners_enabled": true, "forks_count": 0, "star_count": 1, "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", "autoclose_referenced_issues": true, "suggestion_commit_message": null, "_links": { "self": "http://example.com/api/v4/projects", "issues": "http://example.com/api/v4/projects/1/issues", "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", "labels": "http://example.com/api/v4/projects/1/labels", "events": "http://example.com/api/v4/projects/1/events", "members": "http://example.com/api/v4/projects/1/members" } }

    Unstar a project

    取消给定项目的星标. 如果项目未加星标,则返回状态码304 .

    1. POST /projects/:id/unstar
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或
    1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/unstar"

    响应示例:

    1. { "id": 3, "description": null, "default_branch": "master", "visibility": "internal", "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", "tag_list": [ "example", "disapora project" ], "name": "Diaspora Project Site", "name_with_namespace": "Diaspora / Diaspora Project Site", "path": "diaspora-project-site", "path_with_namespace": "diaspora/diaspora-project-site", "issues_enabled": true, "open_issues_count": 1, "merge_requests_enabled": true, "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, "can_create_merge_request_in": true, "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { "id": 3, "name": "Diaspora", "path": "diaspora", "kind": "group", "full_path": "diaspora" }, "import_status": "none", "archived": true, "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png", "license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE", "license": { "key": "lgpl-3.0", "name": "GNU Lesser General Public License v3.0", "nickname": "GNU LGPLv3", "html_url": "http://choosealicense.com/licenses/lgpl-3.0/", "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt" }, "shared_runners_enabled": true, "forks_count": 0, "star_count": 0, "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", "autoclose_referenced_issues": true, "suggestion_commit_message": null, "_links": { "self": "http://example.com/api/v4/projects", "issues": "http://example.com/api/v4/projects/1/issues", "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", "labels": "http://example.com/api/v4/projects/1/labels", "events": "http://example.com/api/v4/projects/1/events", "members": "http://example.com/api/v4/projects/1/members" } }

    List Starrers of a project

    列出为指定项目加注星标的用户.

    1. GET /projects/:id/starrers
    1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/starrers"

    响应示例:

    1. [ { "starred_since": "2019-01-28T14:47:30.642Z", "user": { "id": 1, "username": "jane_smith", "name": "Jane Smith", "state": "active", "avatar_url": "http://localhost:3000/uploads/user/avatar/1/cd8.jpeg", "web_url": "http://localhost:3000/jane_smith" } }, "starred_since": "2018-01-02T11:40:26.570Z", "user": { "id": 2, "username": "janine_smith", "name": "Janine Smith", "state": "blocked", "avatar_url": "http://gravatar.com/../e32131cd8.jpeg", "web_url": "http://localhost:3000/janine_smith" } ]

    Languages

    获取具有百分比值的项目中使用的语言.

    1. GET /projects/:id/languages
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/languages"

    响应示例:

    1. { "Ruby": 66.69, "JavaScript": 22.98, "HTML": 7.91, "CoffeeScript": 2.42 }

    Archive a project

    如果用户是该项目的管理员或项目所有者,则归档该项目. 此操作是幂等的,因此归档已归档的项目不会更改该项目.

    1. POST /projects/:id/archive
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/archive"

    响应示例:

    1. { "id": 3, "description": null, "default_branch": "master", "visibility": "private", "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", "tag_list": [ "example", "disapora project" ], "owner": { "id": 3, "name": "Diaspora", "created_at": "2013-09-30T13:46:02Z" }, "name": "Diaspora Project Site", "name_with_namespace": "Diaspora / Diaspora Project Site", "path": "diaspora-project-site", "path_with_namespace": "diaspora/diaspora-project-site", "issues_enabled": true, "open_issues_count": 1, "merge_requests_enabled": true, "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, "can_create_merge_request_in": true, "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { "id": 3, "name": "Diaspora", "path": "diaspora", "kind": "group", "full_path": "diaspora" }, "import_status": "none", "import_error": null, "permissions": { "project_access": { "access_level": 10, "notification_level": 3 }, "group_access": { "access_level": 50, "notification_level": 3 } }, "archived": true, "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png", "license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE", "license": { "key": "lgpl-3.0", "name": "GNU Lesser General Public License v3.0", "nickname": "GNU LGPLv3", "html_url": "http://choosealicense.com/licenses/lgpl-3.0/", "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt" }, "shared_runners_enabled": true, "forks_count": 0, "star_count": 0, "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b", "ci_default_git_depth": 50, "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", "autoclose_referenced_issues": true, "suggestion_commit_message": null, "_links": { "self": "http://example.com/api/v4/projects", "issues": "http://example.com/api/v4/projects/1/issues", "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", "labels": "http://example.com/api/v4/projects/1/labels", "events": "http://example.com/api/v4/projects/1/events", "members": "http://example.com/api/v4/projects/1/members" } }

    Unarchive a project

    如果用户是该项目的管理员或项目所有者,则取消归档该项目. 此操作是幂等的,因此取消存档未存档的项目不会更改该项目.

    1. POST /projects/:id/unarchive
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/unarchive"

    响应示例:

    1. { "id": 3, "description": null, "default_branch": "master", "visibility": "private", "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", "tag_list": [ "example", "disapora project" ], "owner": { "id": 3, "name": "Diaspora", "created_at": "2013-09-30T13:46:02Z" }, "name": "Diaspora Project Site", "name_with_namespace": "Diaspora / Diaspora Project Site", "path": "diaspora-project-site", "path_with_namespace": "diaspora/diaspora-project-site", "issues_enabled": true, "open_issues_count": 1, "merge_requests_enabled": true, "jobs_enabled": true, "wiki_enabled": true, "snippets_enabled": false, "can_create_merge_request_in": true, "resolve_outdated_diff_discussions": false, "container_registry_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { "id": 3, "name": "Diaspora", "path": "diaspora", "kind": "group", "full_path": "diaspora" }, "import_status": "none", "import_error": null, "permissions": { "project_access": { "access_level": 10, "notification_level": 3 }, "group_access": { "access_level": 50, "notification_level": 3 } }, "archived": false, "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png", "license_url": "http://example.com/diaspora/diaspora-client/blob/master/LICENSE", "license": { "key": "lgpl-3.0", "name": "GNU Lesser General Public License v3.0", "nickname": "GNU LGPLv3", "html_url": "http://choosealicense.com/licenses/lgpl-3.0/", "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt" }, "shared_runners_enabled": true, "forks_count": 0, "star_count": 0, "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b", "ci_default_git_depth": 50, "public_jobs": true, "shared_with_groups": [], "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "request_access_enabled": false, "merge_method": "merge", "autoclose_referenced_issues": true, "suggestion_commit_message": null, "_links": { "self": "http://example.com/api/v4/projects", "issues": "http://example.com/api/v4/projects/1/issues", "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", "labels": "http://example.com/api/v4/projects/1/labels", "events": "http://example.com/api/v4/projects/1/events", "members": "http://example.com/api/v4/projects/1/members" } }

    Remove project

    该端点:

    • 删除包含所有相关资源(问题,合并请求等)的项目.
    • Premium 或 Silver或更高级别的开始,将项目标记为删除. 实际删除发生在实例设置中指定的天数之后.
    1. DELETE /projects/:id
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或

    Restore project marked for deletion

    在 GitLab 12.6 中 .

    恢复标记为删除的项目.

    1. POST /projects/:id/restore
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径

    Upload a file

    将文件上载到指定的项目,以在发布或合并请求描述或注释中使用.

    1. POST /projects/:id/uploads
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    file string yes 要上传的文件

    要从文件系统上载文件,请使用--form参数. 这将导致 cURL 使用标题Content-Type: multipart/form-data . file=参数必须指向文件系统上的文件,并以@开头. 例如:

    1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form "file=@dk.png" "https://gitlab.example.com/api/v4/projects/5/uploads"

    Returned object:

    1. { "alt": "dk", "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png", "full_path": "/namespace1/project1/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png", "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)" }

    注意 :返回的url是相对于项目路径的. 返回的full_path是文件的绝对路径. 在 Markdown 上下文中,当使用markdown的格式时,链接会自动展开.

    Share project with group

    允许与小组共享项目.

    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    group_id integer yes 与之共享的组的 ID
    group_access integer yes 授予组的
    expires_at string no ISO 8601 格式的股份到期日:2016-09-26

    Delete a shared project link within a group

    1. DELETE /projects/:id/share/:group_id
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或
    group_id integer yes 组的 ID
    1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/share/17"

    也称为 Project Hooks 和 Webhooks. 对于系统范围的系统挂钩 ,这些是不同的.

    List project hooks

    获取项目挂钩的列表.

    1. GET /projects/:id/hooks
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径

    Get project hook

    获取项目的特定挂钩.

    1. GET /projects/:id/hooks/:hook_id
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    hook_id integer yes 项目挂钩的 ID
    1. { "id": 1, "url": "http://example.com/hook", "project_id": 3, "push_events": true, "push_events_branch_filter": "", "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, "enable_ssl_verification": true, "created_at": "2012-10-12T17:04:47Z" }

    Add project hook

    将钩子添加到指定项目.

    1. POST /projects/:id/hooks
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    url string yes 挂钩网址
    push_events boolean no 在推送事件上触发钩子
    push_events_branch_filter string 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 事件的钩子
    enable_ssl_verification boolean no 触发挂钩时执行 SSL 验证
    token string no 用于验证收到的有效载荷的秘密令牌; 这将不会在响应中返回

    Edits a hook for a specified project.

    1. PUT /projects/:id/hooks/:hook_id

    Delete project hook

    从项目中删除一个钩子. 这是幂等方法,可以多次调用. 挂钩是否可用.

    1. DELETE /projects/:id/hooks/:hook_id
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    hook_id integer yes 项目挂钩的 ID

    请注意,无论挂钩是否可用,JSON 响应都会有所不同. 如果项目挂钩在 JSON 响应中返回之前可用,或者返回空响应.

    Fork relationship

    允许修改现有项目之间的分支关系. 仅适用于项目所有者和管理员.

    Create a forked from/to relation between existing projects

    1. POST /projects/:id/fork/:forked_from_id
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或
    forked_from_id ID yes 分叉的项目的 ID

    Delete an existing forked from relationship

    1. DELETE /projects/:id/fork
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或

    Search for projects by name

    通过名称搜索可通过身份验证的用户访问的项目. 如果可以公开访问该项目,则无需身份验证即可访问该端点.

    1. GET /projects
    Attribute Type Required Description
    search string yes 项目名称中包含的字符串
    order_by string no 返回按idnamecreated_atlast_activity_at字段排序的请求
    sort string no 返回请求按ascdesc排序
    1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects?search=test"

    Start the Housekeeping task for a Project

    在 GitLab 9.0 中引入.

    1. POST /projects/:id/housekeeping
    Attribute Type Required Description
    id integer/string yes 项目或 NAMESPACE / PROJECT_NAME 的 ID

    Push Rules

    获取项目的推送规则.

    1. GET /projects/:id/push_rule
    Attribute Type Required Description
    id integer/string yes 项目或 NAMESPACE / PROJECT_NAME 的 ID
    1. { "id": 1, "project_id": 3, "commit_message_regex": "Fixes \d+\..*", "commit_message_negative_regex": "ssh\:\/\/", "branch_name_regex": "", "deny_delete_tag": false, "created_at": "2012-10-12T17:04:47Z", "member_check": false, "prevent_secrets": false, "author_email_regex": "", "file_name_regex": "", "max_file_size": 5, "commit_committer_check": false, "reject_unsigned_commits": false }

    使用 GitLab 还将看到commit_committer_checkreject_unsigned_commits参数:

    1. { "id": 1, "project_id": 3, "commit_committer_check": false, "reject_unsigned_commits": false ... }

    Add project push rule

    将推送规则添加到指定项目.

    1. POST /projects/:id/push_rule
    Attribute Type Required Description
    id integer/string yes 项目或 NAMESPACE / PROJECT_NAME 的 ID
    deny_delete_tag boolean no 拒绝删除标签
    member_check boolean no 限制作者(电子邮件)对现有 GitLab 用户的提交
    prevent_secrets boolean no GitLab 将拒绝任何可能包含机密的文件
    commit_message_regex string no 所有提交消息都必须与此匹配,例如Fixed \d+\..*
    commit_message_negative_regex string no 不允许任何提交消息与此匹配,例如ssh\:\/\/
    branch_name_regex string no 所有分支名称必须与此匹配,例如(feature&#124;hotfix)\/*
    author_email_regex string no 所有提交作者的电子邮件都必须与此匹配,例如@my-company.com$
    file_name_regex string no 所有提交的文件名都不能与此匹配,例如(jar&#124;exe)$
    max_file_size integer no 档案大小上限(MB)
    commit_committer_check boolean no 用户只能将使用自己的已验证电子邮件之一提交的提交推送到该存储库.
    reject_unsigned_commits boolean no 如果未通过 GPG 签名,则拒绝提交.

    Edit project push rule

    编辑指定项目的推送规则.

    1. PUT /projects/:id/push_rule
    Attribute Type Required Description
    id integer/string yes 项目或 NAMESPACE / PROJECT_NAME 的 ID
    deny_delete_tag boolean no 拒绝删除标签
    member_check boolean no 限制作者(电子邮件)对现有 GitLab 用户的提交
    prevent_secrets boolean no GitLab will reject any files that are likely to contain secrets
    commit_message_regex string no 所有提交消息都必须与此匹配,例如Fixed \d+\..*
    commit_message_negative_regex string no 不允许任何提交消息与此匹配,例如ssh\:\/\/
    branch_name_regex string no 所有分支名称必须与此匹配,例如(feature&#124;hotfix)\/*
    author_email_regex string no 所有提交作者的电子邮件都必须与此匹配,例如@my-company.com$
    file_name_regex string no 所有提交的文件名都不能与此匹配,例如(jar&#124;exe)$
    max_file_size integer no 档案大小上限(MB)
    commit_committer_check boolean no 用户只能将使用自己的已验证电子邮件之一提交的提交推送到该存储库.
    reject_unsigned_commits boolean no 没有 GPG 签名时拒绝提交.

    Delete project push rule

    在 9.0 中引入.

    从项目中删除推送规则. 这是幂等方法,可以多次调用. 推送规则是否可用.

    1. DELETE /projects/:id/push_rule
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径

    Transfer a project to a new namespace

    在 GitLab 11.1 中引入.

    1. PUT /projects/:id/transfer
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或URL 编码的路径
    namespace integer/string yes 要转移到项目的名称空间的 ID 或路径

    Branches

    在” 分支机构”文档中了解更多信息.

    Project Import/Export

    项目导入/导出文档中了解更多信息.

    Project members

    项目成员文档中了解更多信息.

    Start the pull mirroring process for a Project

    GitLab Starter 10.3 中引入.

    1. POST /projects/:id/mirror/pull
    Attribute Type Required Description
    id integer/string yes 项目的 ID 或
    1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/:id/mirror/pull"

    Project badges

    在文档中了解更多信息.

    Issue and merge request description templates

    非默认的在项目的存储库中进行管理. 因此,您可以通过Repositories API和通过 API 管理它们.

    在 GitLab 10.7 中引入

    该端点只能由管理用户访问.

    下载项目(或 Wiki,如果需要)Git 存储库的快照. 该快照始终为未压缩的tar)格式.