极狐 GitLab

项目 API

Tier: 基础版,专业版,旗舰版

Offering: JihuLab.com,私有化部署

使用此 API 管理极狐GitLab 项目及其关联设置。项目是协作的中心枢纽,您可以在其中存储代码、跟踪议题并组织团队活动。 有关更多信息,请参见创建项目

项目 API 包含以下端点:

  • 检索项目信息和元数据
  • 创建、编辑和删除项目
  • 控制项目可见性、访问权限和安全设置
  • 管理项目功能,如议题跟踪、合并请求和 CI/CD
  • 归档和取消归档项目
  • 在命名空间之间转移项目
  • 管理部署和容器镜像仓库设置

先决条件#

  • 项目上的任何默认角色均可读取项目属性。
  • 需要项目上的所有者或维护者角色才能编辑项目属性。

项目可见性级别#

极狐GitLab 中的项目可以具有以下可见性级别之一:

  • 私有
  • 内部
  • 公开

可见性级别由项目中的 visibility 字段确定。

有关更多信息,请参见项目可见性

响应中返回的字段因认证用户的权限而异。

项目功能可见性级别#

您可以在创建或编辑项目时控制项目设置的可用性。 例如,要禁用现有项目的 forking_access_level

shell
curl --request PUT \ --header "PRIVATE-TOKEN: <your_access_token>" \ --header "Content-Type: application/json" \ --data '{"forking_access_level": "disabled"}' \ --url "https://gitlab.example.com/api/v4/projects/<project_id>"

每个设置都可以独立定义,并接受以下值:

  • disabled:禁用该功能。
  • private:启用并将功能设置为 仅项目成员
  • enabled:启用并将功能设置为 所有有访问权限的人
  • public:启用并将功能设置为 所有人。仅适用于 pages_access_level

有关更多信息,请参见更改项目中单个功能的可见性

属性类型必需描述
analytics_access_levelstringNo设置分析的可见性。
builds_access_levelstringNo设置流水线的可见性。
container_registry_access_levelstringNo设置容器镜像仓库的可见性。
environments_access_levelstringNo设置环境的可见性。
feature_flags_access_levelstringNo设置功能标志的可见性。
forking_access_levelstringNo设置fork的可见性。
infrastructure_access_levelstringNo设置基础设施管理的可见性。
issues_access_levelstringNo设置议题的可见性。
merge_requests_access_levelstringNo设置合并请求的可见性。
model_experiments_access_levelstringNo设置机器学习模型实验的可见性。
model_registry_access_levelstringNo设置机器学习模型注册表的可见性。
monitor_access_levelstringNo设置应用性能监控的可见性。
pages_access_levelstringNo设置极狐GitLab Pages的可见性。
releases_access_levelstringNo设置发布的可见性。
repository_access_levelstringNo设置仓库的可见性。
requirements_access_levelstringNo设置需求管理的可见性。
security_and_compliance_access_levelstringNo设置安全与合规的可见性。
snippets_access_levelstringNo设置代码片段的可见性。
wiki_access_levelstringNo设置Wiki的可见性。

已弃用属性#

这些属性已弃用,可能在 REST API 的未来版本中移除。 请改用替代属性。

已弃用属性替代方案
tag_list改用 topics
marked_for_deletion_at改用 marked_for_deletion_on。仅限专业版和旗舰版。
approvals_before_merge在极狐GitLab 16.0 中[已弃用]。改用合并请求批准 API。仅限专业版和旗舰版。
packages_enabled在极狐GitLab 17.10 中[已弃用]。改用 package_registry_access_level
container_registry_enabled改用 container_registry_access_level
public_builds改用 public_jobs
emails_disabled改用 emails_enabled
issues_enabled改用 issues_access_level
jobs_enabled改用 builds_access_level
merge_requests_enabled改用 merge_request_access_level
snippets_enabled改用 snippets_access_level
wiki_enabled改用 wiki_access_level
restrict_user_defined_variables在极狐GitLab 17.7 中[已弃用]。改用 ci_pipeline_variables_minimum_override_role

获取项目#

版本历史
  • mr_default_title_template 在极狐GitLab 18.11 中[引入],并带有一个名为 mr_default_title_template功能标志。默认禁用。

检索指定项目。如果项目可公开访问,则无需身份验证即可访问此端点。

plaintext
GET /projects/:id

支持的属性:

属性类型必需描述
idinteger or stringYesID 或项目的URL 编码路径
licensebooleanNo包含项目许可证数据。
statisticsbooleanNo包含项目统计信息。仅适用于具有报告者、开发者、维护者或所有者角色的用户。
with_custom_attributesbooleanNo在响应中包含自定义属性。需要管理员访问权限。

如果成功,返回 200 OK 和以下响应属性:

属性类型描述
idinteger项目 ID。
descriptionstring项目描述。
description_htmlstring项目的 HTML 格式描述。
namestring项目名称。
name_with_namespacestring带命名空间的项目名称。
pathstring项目路径。
path_with_namespacestring带命名空间的项目路径。
created_atdatetime项目创建时间戳。
default_branchstring项目默认分支。
tag_listarray of strings已弃用。改用 topics。项目的标签列表。
topicsarray of strings项目的主题列表。
ssh_url_to_repostring用于克隆仓库的 SSH URL。
http_url_to_repostring用于克隆仓库的 HTTP URL。
web_urlstring在浏览器中访问项目的 URL。
readme_urlstring项目 README 文件的 URL。
forks_countinteger项目的 fork 数量。
avatar_urlstring项目头像图片的 URL。
star_countinteger项目获得的星标数量。
last_activity_atdatetime项目最后活动的时间戳。
visibilitystring项目的可见性级别。可能的值:privateinternalpublic
namespaceobject项目的命名空间信息。
namespace.idinteger命名空间 ID。
namespace.namestring命名空间名称。
namespace.pathstring命名空间路径。
namespace.kindstring命名空间类型。可能的值:usergroup
namespace.full_pathstring命名空间完整路径。
namespace.parent_idinteger父命名空间 ID(如果适用)。
namespace.avatar_urlstring命名空间头像图片的 URL。
namespace.web_urlstring在浏览器中访问命名空间的 URL。
container_registry_image_prefixstring容器镜像仓库镜像前缀。
_linksobject与项目相关的 API 端点链接集合。
_links.selfstring项目资源的 URL。
_links.issuesstring项目议题的 URL。
_links.merge_requestsstring项目合并请求的 URL。
_links.repo_branchesstring项目仓库分支的 URL。
_links.labelsstring项目标签的 URL。
_links.eventsstring项目事件的 URL。
_links.membersstring项目成员的 URL。
_links.cluster_agentsstring项目集群代理的 URL。
marked_for_deletion_atdate已弃用。改用 marked_for_deletion_on。项目计划删除的日期。
marked_for_deletion_ondate项目计划删除的日期。
packages_enabledboolean是否为项目启用了软件包仓库。
empty_repoboolean仓库是否为空。
archivedboolean项目是否已归档。
ownerobject项目所有者的信息。
owner.idinteger项目所有者 ID。
owner.usernamestring所有者用户名。
owner.public_emailstring所有者的公开电子邮件地址。
owner.namestring项目所有者名称。
owner.statestring所有者帐户的当前状态。
owner.lockedboolean指示所有者帐户是否已锁定。
owner.avatar_urlstring所有者头像图片的 URL。
owner.web_urlstring所有者个人资料的 Web URL。
owner.created_atdatetime所有者创建时间戳。
resolve_outdated_diff_discussionsboolean是否自动解决过时的差异讨论。
container_expiration_policyobject容器镜像过期策略的设置。
container_expiration_policy.cadencestring容器过期策略的运行频率。
container_expiration_policy.enabledboolean是否启用了容器过期策略。
container_expiration_policy.keep_ninteger要保留的容器镜像数量。
container_expiration_policy.older_thanstring删除早于此值的容器镜像。
container_expiration_policy.name_regexstring已弃用。改用 name_regex_delete。用于匹配容器镜像名称的正则表达式。
container_expiration_policy.name_regex_deletestring用于匹配要删除的容器镜像名称的正则表达式。
container_expiration_policy.name_regex_keepstring用于匹配要保留的容器镜像名称的正则表达式。
container_expiration_policy.next_run_atdatetime下次计划策略运行的时间戳。
repository_object_formatstring仓库使用的对象格式。可能的值:sha1sha256
issues_enabledboolean是否为项目启用了议题。
merge_requests_enabledboolean是否为项目启用了合并请求。
wiki_enabledboolean是否为项目启用了 Wiki。
jobs_enabledboolean是否为项目启用了作业。
snippets_enabledboolean是否为项目启用了代码片段。
container_registry_enabledboolean已弃用。改用 container_registry_access_level。是否启用了容器镜像仓库。
service_desk_enabledboolean是否为项目启用了服务台。
service_desk_addressstring服务台的电子邮件地址。
can_create_merge_request_inboolean当前用户是否可以在项目中创建合并请求。
issues_access_levelstring议题功能的访问级别。可能的值:disabledprivateenabled
repository_access_levelstring仓库功能的访问级别。可能的值:disabledprivateenabled
merge_requests_access_levelstring合并请求功能的访问级别。可能的值:disabledprivateenabled
forking_access_levelstringfork 项目的访问级别。可能的值:disabledprivateenabled
wiki_access_levelstringWiki 功能的访问级别。可能的值:disabledprivateenabled
builds_access_levelstringCI/CD 构建功能的访问级别。可能的值:disabledprivateenabled
snippets_access_levelstring代码片段功能的访问级别。可能的值:disabledprivateenabled
pages_access_levelstring极狐GitLab Pages 的访问级别。可能的值:disabledprivateenabledpublic
analytics_access_levelstring分析功能的访问级别。可能的值:disabledprivateenabled
container_registry_access_levelstring容器镜像仓库的访问级别。可能的值:disabledprivateenabled
security_and_compliance_access_levelstring安全与合规功能的访问级别。可能的值:disabledprivateenabled
releases_access_levelstring发布功能的访问级别。可能的值:disabledprivateenabled
environments_access_levelstring环境功能的访问级别。可能的值:disabledprivateenabled
feature_flags_access_levelstring功能标志功能的访问级别。可能的值:disabledprivateenabled
infrastructure_access_levelstring基础设施功能的访问级别。可能的值:disabledprivateenabled
monitor_access_levelstring监控功能的访问级别。可能的值:disabledprivateenabled
model_experiments_access_levelstring模型实验功能的访问级别。可能的值:disabledprivateenabled
model_registry_access_levelstring模型注册表功能的访问级别。可能的值:disabledprivateenabled
package_registry_access_levelstring软件包仓库功能的访问级别。可能的值:disabledprivateenabled
emails_disabledboolean指示是否为项目禁用了电子邮件。
emails_enabledboolean指示是否为项目启用了电子邮件。
show_diff_preview_in_emailboolean指示是否在电子邮件通知中显示差异预览。
shared_runners_enabledboolean是否为项目启用了共享 Runner。
lfs_enabledboolean指示是否为项目启用了 Git LFS。
creator_idinteger创建项目的用户 ID。
import_urlstring项目导入来源的 URL。
import_typestring项目使用的导入类型。
import_statusstring项目导入状态。
import_errorstring如果导入失败,显示错误消息。
open_issues_countinteger未关闭议题数量。
updated_atdatetime项目上次更新时间戳。
ci_default_git_depthintegerCI/CD 流水线的默认 Git 深度。仅当您拥有管理员访问权限或项目所有者角色时可见。
ci_delete_pipelines_in_secondsinteger删除旧流水线之前的时间(秒)。
ci_forward_deployment_enabledboolean是否启用了前向部署。仅当您拥有管理员访问权限或项目所有者角色时可见。
ci_forward_deployment_rollback_allowedboolean是否允许前向部署的回滚。
ci_job_token_scope_enabledboolean指示是否启用了 CI/CD 作业令牌范围。仅当您拥有管理员访问权限或项目所有者角色时可见。
ci_separated_cachesbooleanCI/CD 缓存是否按分支分隔。仅当您拥有管理员访问权限或项目所有者角色时可见。
ci_allow_fork_pipelines_to_run_in_parent_projectboolean是否允许 fork 流水线在父项目中运行。仅当您拥有管理员访问权限或项目所有者角色时可见。
ci_id_token_sub_claim_componentsarray of stringsCI/CD ID 令牌主题声明中包含的组件。
build_git_strategystringCI/CD 构建使用的 Git 策略(fetch 或 clone)。仅当您拥有管理员访问权限或项目所有者角色时可见。
keep_latest_artifactboolean指示在创建新产物时是否保留最新产物。仅当您拥有管理员访问权限或项目所有者角色时可见。
restrict_user_defined_variablesboolean是否限制用户定义的变量。仅当您拥有管理员访问权限或项目所有者角色时可见。
ci_pipeline_variables_minimum_override_rolestring覆盖流水线变量所需的最低角色。
runner_token_expiration_intervalintegerRunner 令牌的过期时间间隔(秒)。仅当您拥有管理员访问权限或项目所有者角色时可见。
group_runners_enabledboolean是否为项目启用了群组 Runner。仅当您拥有管理员访问权限或项目所有者角色时可见。
resource_group_default_process_modestring资源组的默认处理模式。
auto_cancel_pending_pipelinesstring自动取消待处理流水线的设置。仅当您拥有管理员访问权限或项目所有者角色时可见。
build_timeoutintegerCI/CD 作业的超时时间(秒)。仅当您拥有管理员访问权限或项目所有者角色时可见。
auto_devops_enabledboolean是否为项目启用了 Auto DevOps。仅当您拥有管理员访问权限或项目所有者角色时可见。
auto_devops_deploy_strategystringAuto DevOps 的部署策略。仅当您拥有管理员访问权限或项目所有者角色时可见。
ci_push_repository_for_job_token_allowedboolean是否允许使用作业令牌推送到仓库。
runners_tokenstring用于向项目注册 Runner 的令牌。仅当您拥有管理员访问权限或项目所有者角色时可见。
ci_config_pathstringCI/CD 配置文件的路径。
public_jobsboolean作业日志是否可公开访问。
shared_with_groupsarray of objects与项目共享的群组列表。
shared_with_groups[].group_idinteger与项目共享的群组 ID。
shared_with_groups[].group_namestring与项目共享的群组名称。
shared_with_groups[].group_full_pathstring与项目共享的群组的完整路径。
shared_with_groups[].group_access_levelinteger授予群组的访问级别。
only_allow_merge_if_pipeline_succeedsboolean是否仅当流水线成功时才允许合并。
allow_merge_on_skipped_pipelineboolean是否在流水线被跳过时允许合并。
request_access_enabledboolean用户是否可以请求访问项目。
only_allow_merge_if_all_discussions_are_resolvedboolean是否仅当所有讨论都已解决时才允许合并。
remove_source_branch_after_mergeboolean合并后是否自动删除源分支。
printing_merge_request_link_enabledboolean指示推送后是否打印合并请求链接。
printing_merge_requests_link_enabledboolean推送后是否打印合并请求链接。
merge_methodstring项目使用的合并方法。可能的值:mergerebase_mergeff
merge_request_title_regexstring用于验证合并请求标题的正则表达式模式。
merge_request_title_regex_descriptionstring合并请求标题正则表达式验证的描述。
squash_optionstring合并请求的压缩选项。
enforce_auth_checks_on_uploadsboolean是否对上传强制执行身份验证检查。
suggestion_commit_messagestring建议的自定义提交消息。
merge_commit_templatestring合并提交消息的模板。
mr_default_title_templatestring合并请求标题的模板。
squash_commit_templatestring压缩提交消息的模板。
issue_branch_templatestring从议题创建的分支名称的模板。
warn_about_potentially_unwanted_charactersboolean是否警告可能不需要的字符。
autoclose_referenced_issuesboolean是否自动关闭引用的议题。
max_artifacts_sizeintegerCI/CD 产物的最大大小(MB)。
approvals_before_mergeinteger已弃用。改用合并请求批准 API。合并前所需的批准数量。
mirrorboolean项目是否为镜像。
external_authorization_classification_labelstring外部授权分类标签。
requirements_enabledboolean指示是否启用了需求管理。
requirements_access_levelstring需求功能的访问级别。
security_and_compliance_enabledboolean指示是否启用了安全与合规功能。
secret_push_protection_enabledboolean是否启用了密钥推送保护。
pre_receive_secret_detection_enabledboolean指示是否启用了预接收密钥检测。
compliance_frameworksarray of strings应用于项目的合规框架。
issues_templatestring议题的默认描述。描述使用极狐GitLab Flavored Markdown 解析。仅限专业版和旗舰版。
merge_requests_templatestring合并请求描述的模板。

重新发送群组钩子事件#

版本历史
  • 在极狐GitLab 17.4 中[引入]。

重新发送特定的钩子事件。

此端点对每个钩子和认证用户有每分钟 5 个请求的速率限制。 要在私有化部署上禁用 }}"description_html": "<p data-sourcepos="1:1-1:56" dir="auto">Lorem ipsum dolor sit amet, consectetur adipiscing elit.

", "default_branch": "main", "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/main/README.md", "tag_list": [ //已废弃,请使用 topics 代替 "example", "disapora project" ], "topics": [ "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, // 已废弃,请使用 container_registry_access_level 代替 "container_registry_access_level": "disabled", "security_and_compliance_access_level": "disabled", "container_expiration_policy": { "cadence": "7d", "enabled": false, "keep_n": null, "older_than": null, "name_regex": null, // 将在极狐GitLab 13.0 中废弃,由 name_regex_delete 替代 "name_regex_delete": null, "name_regex_keep": null, "next_run_at": "2020-01-07T21:42:58.658Z" }, "created_at": "2013-09-30T13:46:02Z", "updated_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", "avatar_url": "http://localhost:3000/uploads/group/avatar/3/foo.jpg", "web_url": "http://localhost:3000/groups/diaspora" }, "import_url": null, "import_type": null, "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/main/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, "group_runners_enabled": true, "forks_count": 0, "star_count": 0, "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b", "ci_default_git_depth": 50, "ci_forward_deployment_enabled": true, "ci_forward_deployment_rollback_allowed": true, "ci_allow_fork_pipelines_to_run_in_parent_project": true, "ci_id_token_sub_claim_components": ["project_path", "ref_type", "ref"], "ci_separated_caches": true, "ci_restrict_pipeline_cancellation_role": "developer", "ci_pipeline_variables_minimum_override_role": "maintainer", "ci_push_repository_for_job_token_allowed": false, "ci_display_pipeline_variables": false, "protect_merge_request_pipelines": true, "public_jobs": true, "shared_with_groups": [ { "group_id": 4, "group_name": "Twitter", "group_full_path": "twitter", "group_access_level": 30 }, { "group_id": 3, "group_name": "Gitlab Org", "group_full_path": "gitlab-org", "group_access_level": 10 } ], "repository_storage": "default", "only_allow_merge_if_pipeline_succeeds": false, "allow_merge_on_skipped_pipeline": false, "allow_pipeline_trigger_approve_deployment": false, "restrict_user_defined_variables": false, "only_allow_merge_if_all_discussions_are_resolved": false, "remove_source_branch_after_merge": false, "printing_merge_requests_link_enabled": true, "request_access_enabled": false, "merge_method": "merge", "squash_option": "default_on", "auto_devops_enabled": true, "auto_devops_deploy_strategy": "continuous", "approvals_before_merge": 0, // 已废弃。请改用合并请求审批 API。 "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, "empty_repo": false, "service_desk_enabled": false, "service_desk_address": null, "autoclose_referenced_issues": true, "suggestion_commit_message": null, "enforce_auth_checks_on_uploads": true, "merge_commit_template": null, "mr_default_title_template": null, "squash_commit_template": null, "issue_branch_template": "gitlab/%{id}-%{title}", "marked_for_deletion_at": "2020-04-03", // 已废弃,由 marked_for_deletion_on 替代。计划在未来版本的 REST API 中移除。 "marked_for_deletion_on": "2020-04-03", "compliance_frameworks": [ "sox" ], "warn_about_potentially_unwanted_characters": true, "secret_push_protection_enabled": false, "statistics": { "commit_count": 37, "storage_size": 1038090, "repository_size": 1038090, "wiki_size" : 0, "lfs_objects_size": 0, "job_artifacts_size": 0, "pipeline_artifacts_size": 0, "packages_size": 0, "snippets_size": 0, "uploads_size": 0, "container_registry_size": 0 }, "container_registry_image_prefix": "registry.example.com/diaspora/diaspora-client", "_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", "cluster_agents": "http://example.com/api/v4/projects/1/cluster_agents" }, "spp_repository_pipeline_access": false // 仅在 security_orchestration_policies 功能可用时可见 }

text
1 2## 列出项目 {#list-projects} 3 4列出项目及项目属性。 5 6### 列出所有项目 {#list-all-projects} 7 8<div class="history"> 9 10- `web_based_commit_signing_enabled` 在极狐GitLab 18.2 中[引入](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/194650),[带有功能标志](../administration/feature_flags/_index.md) `use_web_based_commit_signing_enabled`。默认禁用。 11- `mr_default_title_template` 在极狐GitLab 18.11 中[引入](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/228442),[带有功能标志](../administration/feature_flags/_index.md) `mr_default_title_template`。默认禁用。 12 13</div> 14 15> [!flag] 16> `web_based_commit_signing_enabled` 和 `mr_default_title_template` 属性的可用性由功能标志控制。 17> 更多信息,请参阅历史记录。 18> 此功能可用于测试,但尚未准备好用于生产环境。 19 20列出实例上经过身份验证的用户可以访问的所有项目。未经身份验证的请求仅返回包含有限属性子集的公开项目。 21 22你可以通过[自定义属性](custom_attributes.md)过滤响应。 23 24此端点支持分页: 25 26- 使用基于偏移的分页可访问多达 50,000 个项目。 27- 使用基于键集的分页可列出超过 50,000 个项目。 28 29更多信息,请参见[分页](rest/_index.md#pagination)。 30 31```plaintext 32GET /projects

支持的属性:

属性类型是否必需描述
archivedboolean按归档状态限制。
id_afterinteger将结果限制为 ID 大于指定 ID 的项目。
id_beforeinteger将结果限制为 ID 小于指定 ID 的项目。
importedboolean将结果限制为由当前用户从外部系统导入的项目。
include_hiddenboolean包括隐藏项目。(仅管理员) 仅限专业版和旗舰版。
include_pending_deleteboolean包括待删除项目。(仅管理员)
last_activity_afterdatetime将结果限制为最后活动时间在指定时间之后的活动。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ)
last_activity_beforedatetime将结果限制为最后活动时间在指定时间之前的活动。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ)
membershipboolean限制为当前用户是其成员的项目。
min_access_levelinteger限制为当前用户至少具有指定访问级别的项目。可能的值:5(最低访问权限),10(访客),15(计划者),20(报告者),25(安全经理),30(开发者),40(维护者),或 50(所有者)。
order_bystring返回按 idnamepathcreated_atupdated_atstar_countlast_activity_atsimilarity 字段排序的项目。repository_sizestorage_sizepackages_sizewiki_size 字段仅允许管理员使用。similarity 仅在搜索时可用,并且仅限于当前用户是其成员的项目。默认为 created_at
ownedboolean限制为当前用户明确拥有的项目。
repository_checksum_failedboolean限制为仓库校验和计算失败的项目。仅限专业版和旗舰版。
repository_storagestring将结果限制为存储在 repository_storage 上的项目。(仅管理员)
search_namespacesboolean在匹配搜索条件时包括祖先命名空间。默认为 false
searchstring返回 pathnamedescription 与搜索条件匹配的项目列表(不区分大小写,子字符串匹配)。可以提供多个术语,用转义空格(+%20)分隔,并将进行 AND 运算。示例:one+two 将匹配子字符串 onetwo(顺序不限)。
simpleboolean如果为 true,则仅返回每个项目的有限字段。未经身份验证的请求仅返回具有有限字段的公开项目,即使未设置 simple 也是如此。
sortstring返回按 ascdesc 顺序排序的项目。默认为 desc
starredboolean限制为当前用户收藏的项目。
statisticsboolean包括项目统计信息。仅适用于具有报告者、开发者、维护者或所有者角色的用户。
topic_idinteger将结果限制为具有由话题 ID 指定的已分配话题的项目。
topicstring逗号分隔的话题名称。将结果限制为匹配所有给定话题的项目。参见 topics 属性。
updated_afterdatetime将结果限制为在指定时间后最后更新的项目。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ)。在极狐GitLab 15.10 中引入。要使此过滤器生效,你还必须提供 updated_at 作为 order_by 属性。
updated_beforedatetime将结果限制为在指定时间前最后更新的项目。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ)。在极狐GitLab 15.10 中引入。要使此过滤器生效,你还必须提供 updated_at 作为 order_by 属性。
visibilitystring按可见性 publicinternalprivate 限制。
wiki_checksum_failedboolean限制为 Wiki 校验和计算失败的项目。仅限专业版和旗舰版。
with_custom_attributesboolean在响应中包含自定义属性(仅管理员)
with_issues_enabledboolean按已启用议题功能限制。
with_merge_requests_enabledboolean按已启用合并请求功能限制。
with_programming_languagestring限制为使用指定编程语言的项目。
marked_for_deletion_ondate按项目标记为待删除的日期过滤。在极狐GitLab 17.1 中引入。仅限专业版和旗舰版。
activeboolean限制为未归档且未标记为待删除的项目。

{.condensed}

如果成功,返回 200 OK 和以下响应属性:

属性类型描述
idinteger项目 ID。
descriptionstring项目描述。
namestring项目名称。
name_with_namespacestring项目带命名空间的名称。
pathstring项目路径。
path_with_namespacestring项目带命名空间的路径。
created_atdatetime项目创建时的时间戳。
default_branchstring项目的默认分支。
tag_listarray of strings已弃用。请改用 topics。项目的标签列表。
topicsarray of strings项目的话题列表。
ssh_url_to_repostring克隆仓库的 SSH URL。
http_url_to_repostring克隆仓库的 HTTP URL。
web_urlstring在浏览器中访问项目的 URL。
readme_urlstring项目的 README 文件 URL。
forks_countinteger项目的派生数。
avatar_urlstring项目头像图片的 URL。
star_countinteger项目获得的星标数。
last_activity_atdatetime项目最后活动的时间戳。
visibilitystring项目的可见性级别。可选值:privateinternalpublic
namespaceobject项目的命名空间信息。
namespace.idinteger命名空间的 ID。
namespace.namestring命名空间的名称。
namespace.pathstring命名空间的路径。
namespace.kindstring命名空间的类型。可选值:usergroup
namespace.full_pathstring命名空间的完整路径。
namespace.parent_idinteger父命名空间的 ID(如果适用)。
namespace.avatar_urlstring命名空间头像图片的 URL。
namespace.web_urlstring在浏览器中访问命名空间的 URL。
container_registry_image_prefixstring容器镜像仓库镜像的前缀。
_linksobject与项目相关的 API 端点链接集合。
_links.selfstring项目资源的 URL。
_links.issuesstring项目议题的 URL。
_links.merge_requestsstring项目合并请求的 URL。
_links.repo_branchesstring项目仓库分支的 URL。
_links.labelsstring项目标签的 URL。
_links.eventsstring项目事件的 URL。
_links.membersstring项目成员的 URL。
_links.cluster_agentsstring项目集群代理的 URL。
marked_for_deletion_atdate已弃用。请改用 marked_for_deletion_on。项目计划删除的日期。
marked_for_deletion_ondate项目计划删除的日期。
packages_enabledboolean是否为项目启用了软件包仓库。
empty_repoboolean仓库是否为空。
archivedboolean项目是否已归档。
resolve_outdated_diff_discussionsboolean是否自动解决过期的差异讨论。
container_expiration_policyobject容器镜像过期策略的设置。
container_expiration_policy.cadencestring容器过期策略的运行频率。
container_expiration_policy.enabledboolean是否启用了容器过期策略。
container_expiration_policy.keep_ninteger要保留的容器镜像数量。
container_expiration_policy.older_thanstring移除早于此值的容器镜像。
container_expiration_policy.name_regexstring已弃用。请改用 name_regex_delete。用于匹配容器镜像名称的正则表达式。
container_expiration_policy.name_regex_keepstring用于匹配要保留的容器镜像名称的正则表达式。
container_expiration_policy.next_run_atdatetime下次计划策略运行的时间戳。
repository_object_formatstring仓库使用的对象格式(sha1 或 sha256)。
issues_enabledboolean是否为项目启用了议题。
merge_requests_enabledboolean是否为项目启用了合并请求。
wiki_enabledboolean是否为项目启用了 Wiki。
jobs_enabledboolean是否为项目启用了作业。
snippets_enabledboolean是否为项目启用了代码片段。
container_registry_enabledboolean已弃用。请改用 container_registry_access_level。是否启用了容器镜像仓库。
service_desk_enabledboolean是否为项目启用了服务台。
can_create_merge_request_inboolean当前用户是否可以在项目中创建合并请求。
issues_access_levelstring议题功能的访问级别。可选值:disabledprivateenabled
repository_access_levelstring仓库功能的访问级别。可选值:disabledprivateenabled
merge_requests_access_levelstring合并请求功能的访问级别。可选值:disabledprivateenabled
forking_access_levelstring派生项目的访问级别。可选值:disabledprivateenabled
wiki_access_levelstringWiki 功能的访问级别。可选值:disabledprivateenabled
builds_access_levelstringCI/CD 构建功能的访问级别。可选值:disabledprivateenabled
snippets_access_levelstring代码片段功能的访问级别。可选值:disabledprivateenabled
pages_access_levelstring极狐GitLab Pages 的访问级别。可选值:disabledprivateenabledpublic
analytics_access_levelstring分析功能的访问级别。可选值:disabledprivateenabled
container_registry_access_levelstring容器镜像仓库的访问级别。可选值:disabledprivateenabled
security_and_compliance_access_levelstring安全与合规功能的访问级别。可选值:disabledprivateenabled
releases_access_levelstring发布功能的访问级别。可选值:disabledprivateenabled
environments_access_levelstring环境功能的访问级别。可选值:disabledprivateenabled
feature_flags_access_levelstring功能标志功能的访问级别。可选值:disabledprivateenabled
infrastructure_access_levelstring基础设施功能的访问级别。可选值:disabledprivateenabled
monitor_access_levelstring监控功能的访问级别。可选值:disabledprivateenabled
model_experiments_access_levelstring模型实验功能的访问级别。可选值:disabledprivateenabled
model_registry_access_levelstring模型注册表功能的访问级别。可选值:disabledprivateenabled
package_registry_access_levelstring软件包仓库功能的访问级别。可选值:disabledprivateenabled
emails_disabledboolean指示项目是否已禁用电子邮件。
emails_enabledboolean指示项目是否已启用电子邮件。
show_diff_preview_in_emailboolean指示是否在电子邮件通知中显示差异预览。
shared_runners_enabledboolean是否为项目启用了共享 runner。
lfs_enabledboolean指示项目是否已启用 Git LFS。
creator_idinteger创建项目的用户 ID。
import_statusstring项目导入状态。
open_issues_countinteger打开的议题数量。
description_htmlstringHTML 格式的项目描述。
updated_atdatetime项目上次更新的时间戳。
ci_config_pathstringCI/CD 配置文件的路径。
public_jobsboolean作业日志是否可公开访问。
shared_with_groupsarray of objects项目共享给的群组列表。
only_allow_merge_if_pipeline_succeedsboolean是否仅当流水线成功时才允许合并。
allow_merge_on_skipped_pipelineboolean是否当流水线被跳过时允许合并。
request_access_enabledboolean用户是否可以请求访问项目。
only_allow_merge_if_all_discussions_are_resolvedboolean是否仅当所有讨论都已解决时才允许合并。
remove_source_branch_after_mergeboolean是否在合并后自动移除源分支。
printing_merge_request_link_enabledboolean指示在推送后是否打印合并请求链接。
merge_methodstring项目使用的合并方法。可选值:mergerebase_mergeff
merge_request_title_regexstring用于验证合并请求标题的正则表达式模式。
merge_request_title_regex_descriptionstring合并请求标题正则验证的描述。
squash_optionstring合并请求的压缩选项。
enforce_auth_checks_on_uploadsboolean是否对上传文件强制执行身份验证检查。
suggestion_commit_messagestring建议的自定义提交信息。
merge_commit_templatestring合并提交信息的模板。
mr_default_title_templatestring合并请求标题的模板。
squash_commit_templatestring压缩提交信息的模板。
issue_branch_templatestring从议题创建的分支名称模板。
warn_about_potentially_unwanted_charactersboolean是否就潜在的不需要的字符发出警告。
autoclose_referenced_issuesboolean是否自动关闭引用的议题。
max_artifacts_sizeintegerCI/CD 产物的最大大小(MB)。
approvals_before_mergeinteger已弃用。请改用合并请求审批 API。合并前所需的审批数量。
mirrorboolean项目是否为镜像。
external_authorization_classification_labelstring外部授权分类标签。
requirements_enabledboolean指示是否启用了需求管理。
requirements_access_levelstring需求功能的访问级别。
security_and_compliance_enabledboolean指示是否启用了安全与合规功能。
compliance_frameworksarray of strings应用于项目的合规框架。
issues_templatestring议题的默认描述。描述使用极狐GitLab Flavored Markdown 解析。仅专业版和旗舰版。
merge_requests_templatestring合并请求描述的模板。仅专业版和旗舰版。
merge_pipelines_enabledboolean指示是否启用了合并流水线。
merge_trains_enabledboolean指示是否启用了合并队列。
merge_trains_skip_train_allowedboolean指示是否允许跳过合并队列。
only_allow_merge_if_all_status_checks_passedboolean是否仅当所有状态检查通过后才允许合并。仅旗舰版。
allow_pipeline_trigger_approve_deploymentboolean是否允许通过流水线触发器批准部署。
prevent_merge_without_jira_issueboolean指示合并是否需要关联 Jira 议题。
duo_remote_flows_enabledboolean指示是否启用了极狐GitLab Duo 远程流。
duo_foundational_flows_enabledboolean指示是否启用了极狐GitLab Duo 基础流。
duo_sast_fp_detection_enabledboolean指示是否启用了极狐GitLab Duo SAST 误报检测。
duo_sast_vr_workflow_enabledboolean指示是否启用了极狐GitLab Duo SAST 漏洞修复工作流。
spp_repository_pipeline_accessboolean安全策略的仓库流水线访问权限。仅当安全编排策略功能可用时可见。
permissionsobject用户对项目的权限。
permissions.project_accessobject用户的项目访问权限。
permissions.group_accessobject用户的群组访问权限。

{.condensed}

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --header "Accept: application/json" \ --url "https://gitlab.example.com/api/v4/projects"

示例响应:

json
1[ 2 { 3 "id": 4, 4 "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 5 "description_html": "<p data-sourcepos=\"1:1-1:56\" dir=\"auto\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>", 6 "name": "Diaspora Client", 7 "name_with_namespace": "Diaspora / Diaspora Client", 8 "path": "diaspora-client", 9 "path_with_namespace": "diaspora/diaspora-client", 10 "created_at": "2013-09-30T13:46:02Z", 11 "updated_at": "2013-09-30T13:46:02Z", 12 "default_branch": "main", 13 "tag_list": [ //已弃用,请改用 `topics` 14 "example", 15 "disapora client" 16 ], 17 "topics": [ 18 "example", 19 "disapora client" 20 ], 21 "ssh_url_to_repo": "git@gitlab.example.com:diaspora/diaspora-client.git", 22 "http_url_to_repo": "https://gitlab.example.com/diaspora/diaspora-client.git", 23 "web_url": "https://gitlab.example.com/diaspora/diaspora-client", 24 "readme_url": "https://gitlab.example.com/diaspora/diaspora-client/blob/main/README.md", 25 "avatar_url": "https://gitlab.example.com/uploads/project/avatar/4/uploads/avatar.png", 26 "forks_count": 0, 27 "star_count": 0, 28 "last_activity_at": "2022-06-24T17:11:26.841Z", 29 "namespace": { 30 "id": 3, 31 "name": "Diaspora", 32 "path": "diaspora", 33 "kind": "group", 34 "full_path": "diaspora", 35 "parent_id": null, 36 "avatar_url": "https://gitlab.example.com/uploads/project/avatar/6/uploads/avatar.png", 37 "web_url": "https://gitlab.example.com/diaspora" 38 }, 39 "container_registry_image_prefix": "registry.gitlab.example.com/diaspora/diaspora-client", 40 "_links": { 41 "self": "https://gitlab.example.com/api/v4/projects/4", 42 "issues": "https://gitlab.example.com/api/v4/projects/4/issues", 43 "merge_requests": "https://gitlab.example.com/api/v4/projects/4/merge_requests", 44 "repo_branches": "https://gitlab.example.com/api/v4/projects/4/repository/branches", 45 "labels": "https://gitlab.example.com/api/v4/projects/4/labels", 46 "events": "https://gitlab.example.com/api/v4/projects/4/events", 47 "members": "https://gitlab.example.com/api/v4/projects/4/members", 48 "cluster_agents": "https://gitlab.example.com/api/v4/projects/4/cluster_agents" 49 }, 50 "packages_enabled": true, // 已弃用,请改用 `package_registry_access_level` 51 "package_registry_access_level": "enabled", 52 "empty_repo": false, 53 "archived": false, 54 "visibility": "public", 55 "resolve_outdated_diff_discussions": false, 56 "container_expiration_policy": { 57 "cadence": "1month", 58 "enabled": true, 59 "keep_n": 1, 60 "older_than": "14d", 61 "name_regex": "", 62 "name_regex_keep": ".*-main", 63 "next_run_at": "2022-06-25T17:11:26.865Z" 64 }, 65 "issues_enabled": true, 66 "merge_requests_enabled": true, 67 "wiki_enabled": true, 68 "jobs_enabled": true, 69 "snippets_enabled": true, 70 "container_registry_enabled": true, 71 "service_desk_enabled": true, 72 "can_create_merge_request_in": true, 73 "issues_access_level": "enabled", 74 "repository_access_level": "enabled", 75 "merge_requests_access_level": "enabled", 76 "forking_access_level": "enabled", 77 "wiki_access_level": "enabled", 78 "builds_access_level": "enabled", 79 "snippets_access_level": "enabled", 80 "pages_access_level": "enabled", 81 "analytics_access_level": "enabled", 82 "container_registry_access_level": "enabled", 83 "security_and_compliance_access_level": "private", 84 "emails_disabled": null, 85 "emails_enabled": null, 86 "shared_runners_enabled": true, 87 "group_runners_enabled": true, 88 "lfs_enabled": true, 89 "creator_id": 1, 90 "import_url": null, 91 "import_type": null, 92 "import_status": "none", 93 "import_error": null, 94 "open_issues_count": 0, 95 "ci_default_git_depth": 20, 96 "ci_forward_deployment_enabled": true, 97 "ci_forward_deployment_rollback_allowed": true, 98 "ci_allow_fork_pipelines_to_run_in_parent_project": true, 99 "ci_id_token_sub_claim_components": ["project_path", "ref_type", "ref"], 100 "ci_job_token_scope_enabled": false, 101 "ci_separated_caches": true, 102 "ci_restrict_pipeline_cancellation_role": "developer", 103 "ci_pipeline_variables_minimum_override_role": "maintainer", 104 "ci_push_repository_for_job_token_allowed": false, 105 "ci_display_pipeline_variables": false, 106 "protect_merge_request_pipelines": true, 107 "public_jobs": true, 108 "build_timeout": 3600, 109 "auto_cancel_pending_pipelines": "enabled", 110 "ci_config_path": "", 111 "shared_with_groups": [], 112 "only_allow_merge_if_pipeline_succeeds": false, 113 "allow_merge_on_skipped_pipeline": null, 114 "allow_pipeline_trigger_approve_deployment": false, 115 "restrict_user_defined_variables": false, 116 "request_access_enabled": true, 117 "only_allow_merge_if_all_discussions_are_resolved": false, 118 "remove_source_branch_after_merge": true, 119 "printing_merge_request_link_enabled": true, 120 "merge_method": "merge", 121 "squash_option": "default_off", 122 "enforce_auth_checks_on_uploads": true, 123 "suggestion_commit_message": null, 124 "merge_commit_template": null, 125 "mr_default_title_template": null, 126 "squash_commit_template": null, 127 "issue_branch_template": "gitlab/%{id}-%{title}", 128 "auto_devops_enabled": false, 129 "auto_devops_deploy_strategy": "continuous", 130 "autoclose_referenced_issues": true, 131 "keep_latest_artifact": true, 132 "runner_token_expiration_interval": null, 133 "external_authorization_classification_label": "", 134 "requirements_enabled": false, 135 "requirements_access_level": "enabled", 136 "security_and_compliance_enabled": false, 137 "secret_push_protection_enabled": false, 138 "compliance_frameworks": [], 139 "warn_about_potentially_unwanted_characters": true, 140 "permissions": { 141 "project_access": null, 142 "group_access": null 143 } 144 }, 145 { 146 ... 147 } 148]

last_activity_at 根据项目活动项目事件更新。为了优化数据库性能,该字段每小时最多更新一次。 在上次更新后一小时内发生的事件不会更新时间戳。 因此,last_activity_at 最多可能滞后一小时。 updated_at 会在数据库中项目记录发生更改时更新。

列出用户的所有个人项目#

版本历史
  • 在 极狐GitLab 18.11 中引入,带有一个名为 mr_default_title_template 的功能标志。默认禁用。

列出指定用户的所有个人项目。以下限制适用:

  • 仅返回用户个人命名空间中的项目,不包括群组或子群组项目。
  • 如果用户配置文件为私有,则返回空列表。
  • 未认证的请求仅返回公开项目。

此端点支持分页:

  • 使用基于偏移量的分页可访问最多 50,000 个项目。
  • 使用基于键集的分页可列出超过 50,000 个项目。

更多信息,请参见分页

plaintext
GET /users/:user_id/projects

支持的属性:

属性类型必需描述
user_idstring用户的 ID 或用户名。
archivedboolean按归档状态限制。
id_afterinteger将结果限制为 ID 大于指定 ID 的项目。
id_beforeinteger将结果限制为 ID 小于指定 ID 的项目。
membershipboolean按当前用户是其成员的项目进行限制。
min_access_levelinteger限制为当前用户至少具有指定访问级别的项目。可选值:5(最低访问权限)、10(访客)、15(计划者)、20(报告者)、25(安全管理者)、30(开发者)、40(维护者)或 50(所有者)。
order_bystring返回按 idnamepathcreated_atupdated_atstar_countlast_activity_at 字段排序的项目。默认为 created_at
ownedboolean按当前用户明确拥有的项目进行限制。
searchstring返回与搜索条件匹配的项目列表。
simpleboolean如果为 true,仅为每个项目返回有限字段。未认证的请求即使未设置 simple,也仅返回具有有限字段的公开项目。
sortstring返回按 ascdesc 顺序排序的项目。默认为 desc
starredboolean按当前用户星标的项目进行限制。
statisticsboolean包含项目统计信息。仅对具有报告者、开发者、维护者或所有者角色的用户可用。
updated_afterdatetime将结果限制为在指定时间之后最后更新的项目。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ)。
updated_beforedatetime将结果限制为在指定时间之前最后更新的项目。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ)。
visibilitystring按可见性限制。可选值:publicinternalprivate
with_custom_attributesboolean在响应中包含自定义属性。需要管理员访问权限。
with_issues_enabledboolean按已启用议题功能进行限制。
with_merge_requests_enabledboolean按已启用合并请求功能进行限制。
with_programming_languagestring按使用指定编程语言的项目进行限制。

如果成功,返回 200 OK 和以下响应属性:

属性类型描述
id整数项目的 ID。
description字符串项目的描述。
name字符串项目的名称。
name_with_namespace字符串项目及其命名空间的名称。
path字符串项目的路径。
path_with_namespace字符串项目及其命名空间的路径。
created_at日期时间创建项目时的时间戳。
default_branch字符串项目的默认分支。
tag_list字符串数组已弃用。改用 topics。项目的标签列表。
topics字符串数组项目的主题列表。
ssh_url_to_repo字符串克隆仓库的 SSH URL。
http_url_to_repo字符串克隆仓库的 HTTP URL。
web_url字符串在浏览器中访问项目的 URL。
readme_url字符串项目 README 文件的 URL。
forks_count整数项目派生的数量。
avatar_url字符串项目头像图片的 URL。
star_count整数项目获得的星标数。
last_activity_at日期时间项目最后一次活动的时间戳。
visibility字符串项目的可见性级别。可能的值:privateinternalpublic
namespace对象项目的命名空间信息。
namespace.id整数命名空间的 ID。
namespace.name字符串命名空间的名称。
namespace.path字符串命名空间的路径。
namespace.kind字符串命名空间的类型。可能的值:usergroup
namespace.full_path字符串命名空间的完整路径。
namespace.parent_id整数父命名空间的 ID(如适用)。
namespace.avatar_url字符串命名空间头像图片的 URL。
namespace.web_url字符串在浏览器中访问命名空间的 URL。
container_registry_image_prefix字符串容器镜像仓库镜像的前缀。
_links对象与项目相关的 API 端点链接集合。
_links.self字符串项目资源的 URL。
_links.issues字符串项目议题的 URL。
_links.merge_requests字符串项目合并请求的 URL。
_links.repo_branches字符串项目仓库分支的 URL。
_links.labels字符串项目标签的 URL。
_links.events字符串项目事件的 URL。
_links.members字符串项目成员的 URL。
_links.cluster_agents字符串项目集群代理的 URL。
marked_for_deletion_at日期已弃用。改用 marked_for_deletion_on。项目计划删除的日期。
marked_for_deletion_on日期项目计划删除的日期。
packages_enabled布尔值是否为此项目启用了软件包仓库。
empty_repo布尔值仓库是否为空。
archived布尔值项目是否已归档。
resolve_outdated_diff_discussions布尔值是否自动解决过时的 diff 讨论。
container_expiration_policy对象容器镜像过期策略的设置。
container_expiration_policy.cadence字符串容器过期策略的运行频率。
container_expiration_policy.enabled布尔值是否启用容器过期策略。
container_expiration_policy.keep_n整数要保留的容器镜像数量。
container_expiration_policy.older_than字符串移除早于该值的容器镜像。
container_expiration_policy.name_regex字符串已弃用。改用 name_regex_delete。用于匹配容器镜像名称的正则表达式。
container_expiration_policy.name_regex_keep字符串用于匹配要保留的容器镜像名称的正则表达式。
container_expiration_policy.next_run_at日期时间下次计划策略运行的时间戳。
repository_object_format字符串仓库使用的对象格式(sha1 或 sha256)。
issues_enabled布尔值是否为此项目启用了议题。
merge_requests_enabled布尔值是否为此项目启用了合并请求。
wiki_enabled布尔值是否为此项目启用了 Wiki。
jobs_enabled布尔值是否为此项目启用了作业。
snippets_enabled布尔值是否为此项目启用了代码片段。
container_registry_enabled布尔值已弃用。改用 container_registry_access_level。是否启用了容器镜像仓库。
service_desk_enabled布尔值是否为此项目启用了服务台。
can_create_merge_request_in布尔值当前用户是否可以在此项目中创建合并请求。
issues_access_level字符串议题功能的访问级别。可能的值:disabledprivateenabled
repository_access_level字符串仓库功能的访问级别。可能的值:disabledprivateenabled
merge_requests_access_level字符串合并请求功能的访问级别。可能的值:disabledprivateenabled
forking_access_level字符串派生项目的访问级别。可能的值:disabledprivateenabled
wiki_access_level字符串Wiki 功能的访问级别。可能的值:disabledprivateenabled
builds_access_level字符串CI/CD 构建功能的访问级别。可能的值:disabledprivateenabled
snippets_access_level字符串代码片段功能的访问级别。可能的值:disabledprivateenabled
pages_access_level字符串极狐GitLab Pages 的访问级别。可能的值:disabledprivateenabledpublic
analytics_access_level字符串分析功能的访问级别。可能的值:disabledprivateenabled
container_registry_access_level字符串容器镜像仓库的访问级别。可能的值:disabledprivateenabled
security_and_compliance_access_level字符串安全与合规功能的访问级别。可能的值:disabledprivateenabled
releases_access_level字符串发布功能的访问级别。可能的值:disabledprivateenabled
environments_access_level字符串环境功能的访问级别。可能的值:disabledprivateenabled
feature_flags_access_level字符串特性标志功能的访问级别。可能的值:disabledprivateenabled
infrastructure_access_level字符串基础设施功能的访问级别。可能的值:disabledprivateenabled
monitor_access_level字符串监控功能的访问级别。可能的值:disabledprivateenabled
model_experiments_access_level字符串模型实验功能的访问级别。可能的值:disabledprivateenabled
model_registry_access_level字符串模型注册表功能的访问级别。可能的值:disabledprivateenabled
package_registry_access_level字符串软件包仓库功能的访问级别。可能的值:disabledprivateenabled
emails_disabled布尔值指示是否为此项目禁用了电子邮件。
emails_enabled布尔值指示是否为此项目启用了电子邮件。
show_diff_preview_in_email布尔值指示是否在邮件通知中显示 diff 预览。
shared_runners_enabled布尔值是否为此项目启用了共享 Runners。
lfs_enabled布尔值指示是否为此项目启用了 Git LFS。
creator_id整数创建该项目的用户 ID。
import_status字符串项目导入的状态。
open_issues_count整数未关闭议题数量。
description_html字符串项目描述的 HTML 格式。
updated_at日期时间项目最后更新的时间戳。
ci_default_git_depth整数CI/CD 流水线的默认 Git 深度。仅当你拥有管理员权限或项目的所有者角色时可见。
ci_forward_deployment_enabled布尔值是否启用了前向部署。仅当你拥有管理员权限或项目的所有者角色时可见。
ci_job_token_scope_enabled布尔值指示是否启用了 CI/CD 作业令牌范围。仅当你拥有管理员权限或项目的所有者角色时可见。
ci_separated_caches布尔值是否按分支隔开 CI/CD 缓存。仅当你拥有管理员权限或项目的所有者角色时可见。
ci_allow_fork_pipelines_to_run_in_parent_project布尔值是否允许派生流水线在父项目中运行。仅当你拥有管理员权限或项目的所有者角色时可见。
build_git_strategy字符串用于 CI/CD 构建的 Git 策略(fetch 或 clone)。仅当你拥有管理员权限或项目的所有者角色时可见。
keep_latest_artifact布尔值指示是否在创建新产物时保留最新产物。仅当你拥有管理员权限或项目的所有者角色时可见。
restrict_user_defined_variables布尔值是否限制了用户自定义变量。仅当你拥有管理员权限或项目的所有者角色时可见。
runners_token字符串用于向项目注册 Runners 的令牌。仅当你拥有管理员权限或项目的所有者角色时可见。
runner_token_expiration_interval整数Runner 令牌的过期时间间隔(秒)。仅当你拥有管理员权限或项目的所有者角色时可见。
group_runners_enabled布尔值是否为此项目启用了群组 Runners。仅当你拥有管理员权限或项目的所有者角色时可见。
auto_cancel_pending_pipelines字符串自动取消待处理流水线的设置。仅当你拥有管理员权限或项目的所有者角色时可见。
build_timeout整数CI/CD 作业的超时时间(秒)。仅当你拥有管理员权限或项目的所有者角色时可见。
auto_devops_enabled布尔值是否为此项目启用了自动 DevOps。仅当你拥有管理员权限或项目的所有者角色时可见。
auto_devops_deploy_strategy字符串自动 DevOps 的部署策略。仅当你拥有管理员权限或项目的所有者角色时可见。
ci_config_path字符串CI/CD 配置文件的路径。
public_jobs布尔值作业日志是否可公开访问。
shared_with_groups对象数组与之共享该项目的群组列表。
only_allow_merge_if_pipeline_succeeds布尔值是否仅当流水线成功时才允许合并。
allow_merge_on_skipped_pipeline布尔值是否在流水线被跳过时允许合并。
request_access_enabled布尔值是否允许用户请求访问项目。
only_allow_merge_if_all_discussions_are_resolved布尔值是否仅当所有讨论都已解决时才允许合并。
remove_source_branch_after_merge布尔值是否在合并后自动移除源分支。
printing_merge_request_link_enabled布尔值指示是否在推送后打印合并请求链接。
merge_method字符串用于项目的合并方法。可能的值:mergerebase_mergeff
merge_request_title_regex字符串用于验证合并请求标题的正则表达式。
merge_request_title_regex_description字符串合并请求标题校验的描述。
squash_option字符串合并请求的压缩选项。
enforce_auth_checks_on_uploads布尔值是否对上传实施认证检查。
suggestion_commit_message字符串建议的自定义提交消息。
merge_commit_template字符串合并提交消息的模板。
mr_default_title_template字符串合并请求标题的模板。
squash_commit_template字符串压缩提交消息的模板。
issue_branch_template字符串从议题创建分支名称的模板。
warn_about_potentially_unwanted_characters布尔值是否对潜在不期望的字符发出警告。
autoclose_referenced_issues布尔值是否自动关闭被引用的议题。
max_artifacts_size整数CI/CD 产物的最大大小(MB)。
approvals_before_merge整数已弃用。请改用合并请求批准 API。合并前所需的批准数量。
mirror布尔值项目是否为镜像。
external_authorization_classification_label字符串外部授权分类标签。
requirements_enabled布尔值指示是否启用了需求管理。
requirements_access_level字符串需求功能的访问级别。
security_and_compliance_enabled布尔值指示是否启用了安全与合规功能。
compliance_frameworks字符串数组应用于项目的合规框架。
issues_template字符串议题的默认描述。描述使用极狐GitLab Flavored Markdown 解析。仅专业版和旗舰版可用。
merge_requests_template字符串合并请求描述的模板。仅专业版和旗舰版可用。
merge_pipelines_enabled布尔值指示是否启用了合并流水线。
merge_trains_enabled布尔值指示是否启用了合并队列。
merge_trains_skip_train_allowed布尔值指示是否允许跳过合并队列。
only_allow_merge_if_all_status_checks_passed布尔值是否仅当所有状态检查都已通过时才允许合并。仅旗舰版可用。
allow_pipeline_trigger_approve_deployment布尔值是否允许流水线触发器批准部署。
prevent_merge_without_jira_issue布尔值指示合并是否需要关联的 Jira 议题。
duo_remote_flows_enabled布尔值指示是否启用了极狐GitLab Duo 远程流。
duo_foundational_flows_enabled布尔值指示是否启用了极狐GitLab Duo 基础流。
duo_sast_fp_detection_enabled布尔值指示是否启用了极狐GitLab Duo SAST 误报检测。
duo_sast_vr_workflow_enabled布尔值指示是否启用了极狐GitLab Duo SAST 漏洞修复工作流。
spp_repository_pipeline_access布尔值安全策略的仓库流水线访问权限。仅当安全编排策略功能可用时可见。
permissions对象用户对项目的权限。
permissions.project_access对象用户的项目访问权限。
permissions.group_access对象用户的群组访问权限。

{.condensed}

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --header "Accept: application/json" \ --url "https://gitlab.example.com/api/v4/users/:user_id/projects

示例响应:

json
1[ 2 { 3 "id": 4, 4 "description": "示例项目描述文本。", 5 "description_html": "<p data-sourcepos=\"1:1-1:56\" dir=\"auto\">示例项目描述文本。</p>", 6 "default_branch": "main", 7 "visibility": "private", 8 "ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git", 9 "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git", 10 "web_url": "http://example.com/diaspora/diaspora-client", 11 "readme_url": "http://example.com/diaspora/diaspora-client/blob/main/README.md", 12 "tag_list": [ // 已弃用,请使用 `topics` 13 "example", 14 "disapora client" 15 ], 16 "topics": [ 17 "example", 18 "disapora client" 19 ], 20 "owner": { 21 "id": 3, 22 "name": "Diaspora", 23 "created_at": "2013-09-30T13:46:02Z" 24 }, 25 "name": "Diaspora Client", 26 "name_with_namespace": "Diaspora / Diaspora Client", 27 "path": "diaspora-client", 28 "path_with_namespace": "diaspora/diaspora-client", 29 "issues_enabled": true, 30 "open_issues_count": 1, 31 "merge_requests_enabled": true, 32 "jobs_enabled": true, 33 "wiki_enabled": true, 34 "snippets_enabled": false, 35 "can_create_merge_request_in": true, 36 "resolve_outdated_diff_discussions": false, 37 "container_registry_enabled": false, // 已弃用,请使用 container_registry_access_level 38 "container_registry_access_level": "disabled", 39 "security_and_compliance_access_level": "disabled", 40 "created_at": "2013-09-30T13:46:02Z", 41 "updated_at": "2013-09-30T13:46:02Z", 42 "last_activity_at": "2013-09-30T13:46:02Z", 43 "creator_id": 3, 44 "import_url": null, 45 "import_type": null, 46 "import_status": "none", 47 "import_error": null, 48 "namespace": { 49 "id": 3, 50 "name": "Diaspora", 51 "path": "diaspora", 52 "kind": "group", 53 "full_path": "diaspora" 54 }, 55 "import_status": "none", 56 "archived": false, 57 "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png", 58 "shared_runners_enabled": true, 59 "group_runners_enabled": true, 60 "forks_count": 0, 61 "star_count": 0, 62 "runners_token": "b8547b1dc37721d05889db52fa2f02", 63 "ci_default_git_depth": 50, 64 "ci_forward_deployment_enabled": true, 65 "ci_forward_deployment_rollback_allowed": true, 66 "ci_allow_fork_pipelines_to_run_in_parent_project": true, 67 "ci_id_token_sub_claim_components": ["project_path", "ref_type", "ref"], 68 "ci_separated_caches": true, 69 "ci_restrict_pipeline_cancellation_role": "developer", 70 "ci_pipeline_variables_minimum_override_role": "maintainer", 71 "ci_push_repository_for_job_token_allowed": false, 72 "ci_display_pipeline_variables": false, 73 "protect_merge_request_pipelines": true, 74 "public_jobs": true, 75 "shared_with_groups": [], 76 "only_allow_merge_if_pipeline_succeeds": false, 77 "allow_merge_on_skipped_pipeline": false, 78 "allow_pipeline_trigger_approve_deployment": false, 79 "restrict_user_defined_variables": false, 80 "only_allow_merge_if_all_discussions_are_resolved": false, 81 "remove_source_branch_after_merge": false, 82 "request_access_enabled": false, 83 "merge_method": "merge", 84 "squash_option": "default_on", 85 "autoclose_referenced_issues": true, 86 "enforce_auth_checks_on_uploads": true, 87 "suggestion_commit_message": null, 88 "merge_commit_template": null, 89 "mr_default_title_template": null, 90 "squash_commit_template": null, 91 "secret_push_protection_enabled": false, 92 "issue_branch_template": "gitlab/%{id}-%{title}", 93 "marked_for_deletion_at": "2020-04-03", // 已弃用,改用 marked_for_deletion_on。计划在未来的 REST API 版本中移除。 94 "marked_for_deletion_on": "2020-04-03", 95 "statistics": { 96 "commit_count": 37, 97 "storage_size": 1038090, 98 "repository_size": 1038090, 99 "wiki_size" : 0, 100 "lfs_objects_size": 0, 101 "job_artifacts_size": 0, 102 "pipeline_artifacts_size": 0, 103 "packages_size": 0, 104 "snippets_size": 0, 105 "uploads_size": 0, 106 "container_registry_size": 0 107 }, 108 "container_registry_image_prefix": "registry.example.com/diaspora/diaspora-client", 109 "_links": { 110 "self": "http://example.com/api/v4/projects", 111 "issues": "http://example.com/api/v4/projects/1/issues", 112 "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", 113 "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", 114 "labels": "http://example.com/api/v4/projects/1/labels", 115 "events": "http://example.com/api/v4/projects/1/events", 116 "members": "http://example.com/api/v4/projects/1/members", 117 "cluster_agents": "http://example.com/api/v4/projects/1/cluster_agents" 118 } 119 }, 120 { 121 "id": 6, 122 "description": "示例项目描述文本。", 123 "description_html": "<p data-sourcepos=\"1:1-1:56\" dir=\"auto\">示例项目描述文本。</p>", 124 "default_branch": "main", 125 "visibility": "private", 126 "ssh_url_to_repo": "git@example.com:brightbox/puppet.git", 127 "http_url_to_repo": "http://example.com/brightbox/puppet.git", 128 "web_url": "http://example.com/brightbox/puppet", 129 "readme_url": "http://example.com/brightbox/puppet/blob/main/README.md", 130 "tag_list": [ // 已弃用,请使用 `topics` 131 "example", 132 "puppet" 133 ], 134 "topics": [ 135 "example", 136 "puppet" 137 ], 138 "owner": { 139 "id": 4, 140 "name": "Brightbox", 141 "created_at": "2013-09-30T13:46:02Z" 142 }, 143 "name": "Puppet", 144 "name_with_namespace": "Brightbox / Puppet", 145 "path": "puppet", 146 "path_with_namespace": "brightbox/puppet", 147 "issues_enabled": true, 148 "open_issues_count": 1, 149 "merge_requests_enabled": true, 150 "jobs_enabled": true, 151 "wiki_enabled": true, 152 "snippets_enabled": false, 153 "can_create_merge_request_in": true, 154 "resolve_outdated_diff_discussions": false, 155 "container_registry_enabled": false, // 已弃用,请使用 container_registry_access_level 156 "container_registry_access_level": "disabled", 157 "security_and_compliance_access_level": "disabled", 158 "created_at": "2013-09-30T13:46:02Z", 159 "updated_at": "2013-09-30T13:46:02Z", 160 "last_activity_at": "2013-09-30T13:46:02Z", 161 "creator_id": 3, 162 "import_url": null, 163 "import_type": null, 164 "import_status": "none", 165 "import_error": null, 166 "namespace": { 167 "id": 4, 168 "name": "Brightbox", 169 "path": "brightbox", 170 "kind": "group", 171 "full_path": "brightbox" 172 }, 173 "import_status": "none", 174 "import_error": null, 175 "permissions": { 176 "project_access": { 177 "access_level": 10, 178 "notification_level": 3 179 }, 180 "group_access": { 181 "access_level": 50, 182 "notification_level": 3 183 } 184 }, 185 "archived": false, 186 "avatar_url": null, 187 "shared_runners_enabled": true, 188 "group_runners_enabled": true, 189 "forks_count": 0, 190 "star_count": 0, 191 "runners_token": "b8547b1dc37721d05889db52fa2f02", 192 "ci_default_git_depth": 0, 193 "ci_forward_deployment_enabled": true, 194 "ci_forward_deployment_rollback_allowed": true, 195 "ci_allow_fork_pipelines_to_run_in_parent_project": true, 196 "ci_id_token_sub_claim_components": ["project_path", "ref_type", "ref"], 197 "ci_separated_caches": true, 198 "ci_restrict_pipeline_cancellation_role": "developer", 199 "ci_pipeline_variables_minimum_override_role": "maintainer", 200 "ci_push_repository_for_job_token_allowed": false, 201 "ci_display_pipeline_variables": false, 202 "protect_merge_request_pipelines": true, 203 "public_jobs": true, 204 "shared_with_groups": [], 205 "only_allow_merge_if_pipeline_succeeds": false, 206 "allow_merge_on_skipped_pipeline": false, 207 "allow_pipeline_trigger_approve_deployment": false, 208 "restrict_user_defined_variables": false, 209 "only_allow_merge_if_all_discussions_are_resolved": false, 210 "remove_source_branch_after_merge": false, 211 "request_access_enabled": false, 212 "merge_method": "merge", 213 "squash_option": "default_on", 214 "auto_devops_enabled": true, 215 "auto_devops_deploy_strategy": "continuous", 216 "repository_storage": "default", 217 "approvals_before_merge": 0, // 已弃用。请改用合并请求审批 API。 218 "mirror": false, 219 "mirror_user_id": 45, 220 "mirror_trigger_builds": false, 221 "only_mirror_protected_branches": false, 222 "mirror_overwrites_diverged_branches": false, 223 "external_authorization_classification_label": null, 224 "packages_enabled": true, // 已弃用,请使用 package_registry_access_level 225 "empty_repo": false, 226 "package_registry_access_level": "enabled", 227 "service_desk_enabled": false, 228 "service_desk_address": null, 229 "autoclose_referenced_issues": true, 230 "enforce_auth_checks_on_uploads": true, 231 "suggestion_commit_message": null, 232 "merge_commit_template": null, 233 "mr_default_title_template": null, 234 "squash_commit_template": null, 235 "secret_push_protection_enabled": false, 236 "issue_branch_template": "gitlab/%{id}-%{title}", 237 "statistics": { 238 "commit_count": 12, 239 "storage_size": 2066080, 240 "repository_size": 2066080, 241 "wiki_size" : 0, 242 "lfs_objects_size": 0, 243 "job_artifacts_size": 0, 244 "pipeline_artifacts_size": 0, 245 "packages_size": 0, 246 "snippets_size": 0, 247 "uploads_size": 0, 248 "container_registry_size": 0 249 }, 250 "container_registry_image_prefix": "registry.example.com/brightbox/puppet", 251 "_links": { 252 "self": "http://example.com/api/v4/projects", 253 "issues": "http://example.com/api/v4/projects/1/issues", 254 "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", 255 "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", 256 "labels": "http://example.com/api/v4/projects/1/labels", 257 "events": "http://example.com/api/v4/projects/1/events", 258 "members": "http://example.com/api/v4/projects/1/members", 259 "cluster_agents": "http://example.com/api/v4/projects/1/cluster_agents" 260 } 261 } 262]

列出用户的所有项目贡献#

版本历史
  • mr_default_title_template 在极狐GitLab 18.11 中引入,带有一个功能标志 名为 mr_default_title_template。默认禁用。

列出指定用户对所有可见项目的贡献。仅返回过去一年的贡献。有关什么算作贡献的更多信息,请参见查看您所参与的项目

plaintext
GET /users/:user_id/contributed_projects

支持的属性:

属性类型是否必需描述
user_id字符串用户的 ID 或用户名。
order_by字符串idnamepathcreated_atupdated_atstar_countlast_activity_at 字段排序返回项目。默认为 created_at
simple布尔值如果为 true,则每个项目仅返回有限的字段。未认证的请求即使未设置 simple,也仅返回具有有限字段的公开项目。
sort字符串ascdesc 顺序排序返回项目。默认为 desc

如果成功,返回 200 OK 和以下响应属性:

属性类型描述
id整数项目的 ID。
description字符串项目的描述。
name字符串项目的名称。
name_with_namespace字符串包含命名空间的项目名称。
path字符串项目的路径。
path_with_namespace字符串包含命名空间的项目路径。
created_at日期时间项目的创建时间戳。
default_branch字符串项目的默认分支。
tag_list字符串数组已弃用。请改用 topics。项目的标签列表。
topics字符串数组项目的主题列表。
ssh_url_to_repo字符串用于克隆仓库的 SSH URL。
http_url_to_repo字符串用于克隆仓库的 HTTP URL。
web_url字符串在浏览器中访问项目的 URL。
readme_url字符串项目 README 文件的 URL。
forks_count整数项目的 Fork 数量。
avatar_url字符串项目头像图片的 URL。
star_count整数项目获得的星标数。
last_activity_at日期时间项目最近活动的时间戳。
visibility字符串项目的可见性级别。可能的值:privateinternalpublic
namespace对象项目的命名空间信息。
namespace.id整数命名空间的 ID。
namespace.name字符串命名空间的名称。
namespace.path字符串命名空间的路径。
namespace.kind字符串命名空间的类型。可能的值:usergroup
namespace.full_path字符串命名空间的完整路径。
namespace.parent_id整数父命名空间的 ID(如果适用)。
namespace.avatar_url字符串命名空间头像图片的 URL。
namespace.web_url字符串在浏览器中访问命名空间的 URL。
container_registry_image_prefix字符串容器镜像仓库镜像的前缀。
_links对象与项目相关的 API 端点链接集合。
_links.self字符串项目资源的 URL。
_links.issues字符串项目议题的 URL。
_links.merge_requests字符串项目合并请求的 URL。
_links.repo_branches字符串项目仓库分支的 URL。
_links.labels字符串项目标签的 URL。
_links.events字符串项目事件的 URL。
_links.members字符串项目成员的 URL。
_links.cluster_agents字符串项目集群代理的 URL。
marked_for_deletion_at日期已弃用。请改用 marked_for_deletion_on。项目计划删除的日期。
marked_for_deletion_on日期项目计划删除的日期。
packages_enabled布尔值是否为项目启用了软件包仓库。
empty_repo布尔值仓库是否为空。
archived布尔值项目是否已归档。
resolve_outdated_diff_discussions布尔值是否自动解决过时的差异讨论。
container_expiration_policy对象容器镜像过期策略的设置。
container_expiration_policy.cadence字符串容器过期策略的执行频率。
container_expiration_policy.enabled布尔值是否启用了容器过期策略。
container_expiration_policy.keep_n整数要保留的容器镜像数量。
container_expiration_policy.older_than字符串删除比此值更旧的容器镜像。
container_expiration_policy.name_regex字符串已弃用。请改用 name_regex_delete。用于匹配容器镜像名称的正则表达式。
container_expiration_policy.name_regex_keep字符串用于匹配要保留的容器镜像名称的正则表达式。
container_expiration_policy.next_run_at日期时间下次策略计划运行的时间戳。
repository_object_format字符串仓库使用的对象格式(sha1 或 sha256)。
issues_enabled布尔值是否为项目启用了议题。
merge_requests_enabled布尔值是否为项目启用了合并请求。
wiki_enabled布尔值是否为项目启用了 Wiki。
jobs_enabled布尔值是否为项目启用了作业。
snippets_enabled布尔值是否为项目启用了代码片段。
container_registry_enabled布尔值已弃用。请改用 container_registry_access_level。是否启用了容器镜像仓库。
service_desk_enabled布尔值是否为项目启用了服务台。
can_create_merge_request_in布尔值当前用户是否可以在项目中创建合并请求。
issues_access_level字符串议题功能的访问级别。可能的值:disabledprivateenabled
repository_access_level字符串仓库功能的访问级别。可能的值:disabledprivateenabled
merge_requests_access_level字符串合并请求功能的访问级别。可能的值:disabledprivateenabled
forking_access_level字符串Fork 项目的访问级别。可能的值:disabledprivateenabled
wiki_access_level字符串Wiki 功能的访问级别。可能的值:disabledprivateenabled
builds_access_level字符串CI/CD 构建功能的访问级别。可能的值:disabledprivateenabled
snippets_access_level字符串代码片段功能的访问级别。可能的值:disabledprivateenabled
pages_access_level字符串极狐GitLab Pages 的访问级别。可能的值:disabledprivateenabledpublic
analytics_access_level字符串分析功能的访问级别。可能的值:disabledprivateenabled
container_registry_access_level字符串容器镜像仓库的访问级别。可能的值:disabledprivateenabled
security_and_compliance_access_level字符串安全与合规功能的访问级别。可能的值:disabledprivateenabled
releases_access_level字符串发布功能的访问级别。可能的值:disabledprivateenabled
environments_access_level字符串环境功能的访问级别。可能的值:disabledprivateenabled
feature_flags_access_level字符串功能标志功能的访问级别。可能的值:disabledprivateenabled
infrastructure_access_level字符串基础设施功能的访问级别。可能的值:disabledprivateenabled
monitor_access_level字符串监控功能的访问级别。可能的值:disabledprivateenabled
model_experiments_access_level字符串模型实验功能的访问级别。可能的值:disabledprivateenabled
model_registry_access_level字符串模型仓库功能的访问级别。可能的值:disabledprivateenabled
package_registry_access_level字符串软件包仓库功能的访问级别。可能的值:disabledprivateenabled
emails_disabled布尔值表示是否为项目禁用电子邮件。
emails_enabled布尔值表示是否为项目启用电子邮件。
show_diff_preview_in_email布尔值表示是否在电子邮件通知中显示差异预览。
shared_runners_enabled布尔值是否为项目启用了共享 Runner。
lfs_enabled布尔值表示是否为项目启用了 Git LFS。
creator_id整数创建项目的用户 ID。
import_status字符串项目导入的状态。
open_issues_count整数打开的议题数量。
description_html字符串HTML 格式的项目描述。
updated_at日期时间项目最后更新的时间戳。
ci_default_git_depth整数CI/CD 流水线的默认 Git 深度。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
ci_forward_deployment_enabled布尔值是否启用了前向部署。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
ci_job_token_scope_enabled布尔值表示是否启用了 CI/CD 作业令牌作用域。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
ci_separated_caches布尔值是否按分支分离 CI/CD 缓存。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
ci_allow_fork_pipelines_to_run_in_parent_project布尔值是否允许 Fork 流水线在父项目中运行。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
build_git_strategy字符串CI/CD 构建使用的 Git 策略(fetch 或 clone)。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
keep_latest_artifact布尔值表示创建新产物时是否保留最新产物。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
restrict_user_defined_variables布尔值是否限制了用户定义的变量。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
runners_token字符串用于为项目注册 Runner 的令牌。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
runner_token_expiration_interval整数Runner 令牌的过期时间间隔(以秒为单位)。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
group_runners_enabled布尔值是否为项目启用了群组 Runner。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
auto_cancel_pending_pipelines字符串自动取消待处理流水线的设置。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
build_timeout整数CI/CD 作业的超时时间(以秒为单位)。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
auto_devops_enabled布尔值是否为项目启用了 Auto DevOps。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
auto_devops_deploy_strategy字符串Auto DevOps 的部署策略。仅当您拥有管理员访问权限或项目的所有者角色时才可见。
ci_config_path字符串CI/CD 配置文件的路径。
public_jobs布尔值作业日志是否可公开访问。
shared_with_groups对象数组与项目共享的群组列表。
only_allow_merge_if_pipeline_succeeds布尔值是否仅在流水线成功时才允许合并。
allow_merge_on_skipped_pipeline布尔值是否在流水线被跳过时允许合并。
request_access_enabled布尔值用户是否可以请求访问项目。
only_allow_merge_if_all_discussions_are_resolved布尔值是否仅在所有讨论都已解决时才允许合并。
remove_source_branch_after_merge布尔值合并后是否自动删除源分支。
printing_merge_request_link_enabled布尔值表示推送后是否打印合并请求链接。
merge_method字符串项目使用的合并方法。可能的值:mergerebase_mergeff
merge_request_title_regex字符串用于验证合并请求标题的正则表达式模式。
merge_request_title_regex_description字符串合并请求标题正则表达式验证的描述。
squash_option字符串合并请求的压缩选项。
enforce_auth_checks_on_uploads布尔值是否对上传强制执行身份验证检查。
suggestion_commit_message字符串建议的自定义提交消息。
merge_commit_template字符串合并提交消息的模板。
mr_default_title_template字符串合并请求标题的模板。
squash_commit_template字符串压缩提交消息的模板。
issue_branch_template字符串从议题创建的分支名称模板。
warn_about_potentially_unwanted_characters布尔值是否对潜在不需要的字符发出警告。
autoclose_referenced_issues布尔值是否自动关闭引用的议题。
max_artifacts_size整数CI/CD 产物的最大大小(以 MB 为单位)。
approvals_before_merge整数已弃用。请改用合并请求审批 API。合并前所需的审批数量。
mirror布尔值项目是否被镜像。
mirror_user_id整数配置镜像的用户 ID。
mirror_trigger_builds布尔值镜像更新是否触发构建。
only_mirror_protected_branches布尔值是否仅镜像受保护的分支。
mirror_overwrites_diverged_branches布尔值是否用源覆盖已偏离的分支。
external_authorization_classification_label字符串外部授权分类标签。
package_registry_access_level字符串软件包仓库功能的访问级别。可能的值:disabledprivateenabled
service_desk_address字符串服务台的入站电子邮件地址。
autoclose_referenced_issues布尔值是否自动关闭引用的议题。
secret_push_protection_enabled布尔值是否启用了密钥推送保护。
text
1| `external_authorization_classification_label` | 字符串 | 外部授权分类标签。 | 2| `requirements_enabled` | 布尔值 | 是否启用了需求管理。 | 3| `requirements_access_level` | 字符串 | 需求功能的访问级别。 | 4| `security_and_compliance_enabled` | 布尔值 | 是否启用了安全与合规功能。 | 5| `compliance_frameworks` | 字符串数组 | 应用到项目的合规框架。 | 6| `issues_template` | 字符串 | 议题的默认描述。描述使用极狐GitLab Flavored Markdown 进行解析。仅专业版和旗舰版可用。 | 7| `merge_requests_template` | 字符串 | 合并请求描述的模板。仅专业版和旗舰版可用。 | 8| `merge_pipelines_enabled` | 布尔值 | 是否启用了合并流水线。 | 9| `merge_trains_enabled` | 布尔值 | 是否启用了合并队列。 | 10| `merge_trains_skip_train_allowed` | 布尔值 | 是否允许跳过合并队列。 | 11| `only_allow_merge_if_all_status_checks_passed` | 布尔值 | 是否仅在所有状态检查通过后才允许合并。仅旗舰版可用。 | 12| `allow_pipeline_trigger_approve_deployment` | 布尔值 | 是否允许流水线触发器审批部署。 | 13| `prevent_merge_without_jira_issue` | 布尔值 | 是否合并需要关联 Jira 议题。 | 14| `duo_remote_flows_enabled` | 布尔值 | 是否启用了极狐GitLab Duo 远程流程。 | 15| `duo_foundational_flows_enabled` | 布尔值 | 是否启用了极狐GitLab Duo 基础流程。 | 16| `duo_sast_fp_detection_enabled` | 布尔值 | 是否启用了极狐GitLab Duo SAST 误报检测。 | 17| `duo_sast_vr_workflow_enabled` | 布尔值 | 是否启用了极狐GitLab Duo SAST 漏洞修复工作流。 | 18| `spp_repository_pipeline_access` | 布尔值 | 安全策略的代码仓流水线访问权限。仅当安全编排策略功能可用时可见。 | 19| `permissions` | 对象 | 用户的项目权限。 | 20| `permissions.project_access` | 对象 | 用户的项目访问权限。 | 21| `permissions.group_access` | 对象 | 用户的群组访问权限。 | 22<!-- markdownlint-disable-next-line MD055 MD056 --> 23{.condensed} 24 25示例请求: 26 27```shell 28curl --header "PRIVATE-TOKEN: <your_access_token>" \ 29 --url "https://gitlab.example.com/api/v4/users/5/contributed_projects"

示例响应:

json
1[ 2 { 3 "id": 4, 4 "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 5 "description_html": "<p data-sourcepos=\"1:1-1:56\" dir=\"auto\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>", 6 "default_branch": "main", 7 "visibility": "private", 8 "ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git", 9 "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git", 10 "web_url": "http://example.com/diaspora/diaspora-client", 11 "readme_url": "http://example.com/diaspora/diaspora-client/blob/main/README.md", 12 "tag_list": [ // 已弃用,改用 `topics` 13 "example", 14 "disapora client" 15 ], 16 "topics": [ 17 "example", 18 "disapora client" 19 ], 20 "owner": { 21 "id": 3, 22 "name": "Diaspora", 23 "created_at": "2013-09-30T13:46:02Z" 24 }, 25 "name": "Diaspora Client", 26 "name_with_namespace": "Diaspora / Diaspora Client", 27 "path": "diaspora-client", 28 "path_with_namespace": "diaspora/diaspora-client", 29 "issues_enabled": true, 30 "open_issues_count": 1, 31 "merge_requests_enabled": true, 32 "jobs_enabled": true, 33 "wiki_enabled": true, 34 "snippets_enabled": false, 35 "can_create_merge_request_in": true, 36 "resolve_outdated_diff_discussions": false, 37 "container_registry_enabled": false, // 已弃用,改用 container_registry_access_level 38 "container_registry_access_level": "disabled", 39 "security_and_compliance_access_level": "disabled", 40 "created_at": "2013-09-30T13:46:02Z", 41 "updated_at": "2013-09-30T13:46:02Z", 42 "last_activity_at": "2013-09-30T13:46:02Z", 43 "creator_id": 3, 44 "namespace": { 45 "id": 3, 46 "name": "Diaspora", 47 "path": "diaspora", 48 "kind": "group", 49 "full_path": "diaspora" 50 }, 51 "import_status": "none", 52 "archived": false, 53 "avatar_url": "http://example.com/uploads/project/avatar/4/uploads/avatar.png", 54 "shared_runners_enabled": true, 55 "group_runners_enabled": true, 56 "forks_count": 0, 57 "star_count": 0, 58 "runners_token": "b8547b1dc37721d05889db52fa2f02", 59 "public_jobs": true, 60 "shared_with_groups": [], 61 "only_allow_merge_if_pipeline_succeeds": false, 62 "allow_merge_on_skipped_pipeline": false, 63 "allow_pipeline_trigger_approve_deployment": false, 64 "restrict_user_defined_variables": false, 65 "only_allow_merge_if_all_discussions_are_resolved": false, 66 "remove_source_branch_after_merge": false, 67 "request_access_enabled": false, 68 "merge_method": "merge", 69 "squash_option": "default_on", 70 "autoclose_referenced_issues": true, 71 "enforce_auth_checks_on_uploads": true, 72 "suggestion_commit_message": null, 73 "merge_commit_template": null, 74 "mr_default_title_template": null, 75 "squash_commit_template": null, 76 "secret_push_protection_enabled": false, 77 "issue_branch_template": "gitlab/%{id}-%{title}", 78 "statistics": { 79 "commit_count": 37, 80 "storage_size": 1038090, 81 "repository_size": 1038090, 82 "lfs_objects_size": 0, 83 "job_artifacts_size": 0, 84 "pipeline_artifacts_size": 0, 85 "packages_size": 0, 86 "snippets_size": 0, 87 "uploads_size": 0, 88 "container_registry_size": 0 89 }, 90 "container_registry_image_prefix": "registry.example.com/diaspora/diaspora-client", 91 "_links": { 92 "self": "http://example.com/api/v4/projects", 93 "issues": "http://example.com/api/v4/projects/1/issues", 94 "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", 95 "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", 96 "labels": "http://example.com/api/v4/projects/1/labels", 97 "events": "http://example.com/api/v4/projects/1/events", 98 "members": "http://example.com/api/v4/projects/1/members", 99 "cluster_agents": "http://example.com/api/v4/projects/1/cluster_agents" 100 } 101 }, 102 { 103 "id": 6, 104 "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 105 "description_html": "<p data-sourcepos=\"1:1-1:56\" dir=\"auto\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>", 106 "default_branch": "main", 107 "visibility": "private", 108 "ssh_url_to_repo": "git@example.com:brightbox/puppet.git", 109 "http_url_to_repo": "http://example.com/brightbox/puppet.git", 110 "web_url": "http://example.com/brightbox/puppet", 111 "readme_url": "http://example.com/brightbox/puppet/blob/main/README.md", 112 "tag_list": [ // 已弃用,改用 `topics` 113 "example", 114 "puppet" 115 ], 116 "topics": [ 117 "example", 118 "puppet" 119 ], 120 "owner": { 121 "id": 4, 122 "name": "Brightbox", 123 "created_at": "2013-09-30T13:46:02Z" 124 }, 125 "name": "Puppet", 126 "name_with_namespace": "Brightbox / Puppet", 127 "path": "puppet", 128 "path_with_namespace": "brightbox/puppet", 129 "issues_enabled": true, 130 "open_issues_count": 1, 131 "merge_requests_enabled": true, 132 "jobs_enabled": true, 133 "wiki_enabled": true, 134 "snippets_enabled": false, 135 "can_create_merge_request_in": true, 136 "resolve_outdated_diff_discussions": false, 137 "container_registry_enabled": false, // 已弃用,改用 container_registry_access_level 138 "container_registry_access_level": "disabled", 139 "security_and_compliance_access_level": "disabled", 140 "created_at": "2013-09-30T13:46:02Z", 141 "updated_at": "2013-09-30T13:46:02Z", 142 "last_activity_at": "2013-09-30T13:46:02Z", 143 "creator_id": 3, 144 "namespace": { 145 "id": 4, 146 "name": "Brightbox", 147 "path": "brightbox", 148 "kind": "group", 149 "full_path": "brightbox" 150 }, 151 "import_status": "none", 152 "import_error": null, 153 "permissions": { 154 "project_access": { 155 "access_level": 10, 156 "notification_level": 3 157 }, 158 "group_access": { 159 "access_level": 50, 160 "notification_level": 3 161 } 162 }, 163 "archived": false, 164 "avatar_url": null, 165 "shared_runners_enabled": true, 166 "group_runners_enabled": true, 167 "forks_count": 0, 168 "star_count": 0, 169 "runners_token": "b8547b1dc37721d05889db52fa2f02", 170 "public_jobs": true, 171 "shared_with_groups": [], 172 "only_allow_merge_if_pipeline_succeeds": false, 173 "allow_merge_on_skipped_pipeline": false, 174 "allow_pipeline_trigger_approve_deployment": false, 175 "restrict_user_defined_variables": false, 176 "only_allow_merge_if_all_discussions_are_resolved": false, 177 "remove_source_branch_after_merge": false, 178 "request_access_enabled": false, 179 "merge_method": "merge", 180 "squash_option": "default_on", 181 "auto_devops_enabled": true, 182 "auto_devops_deploy_strategy": "continuous", 183 "repository_storage": "default", 184 "approvals_before_merge": 0, // 已弃用。改用合并请求审批 API。 185 "mirror": false, 186 "mirror_user_id": 45, 187 "mirror_trigger_builds": false, 188 "only_mirror_protected_branches": false, 189 "mirror_overwrites_diverged_branches": false, 190 "external_authorization_classification_label": null, 191 "packages_enabled": true, // 已弃用,改用 package_registry_access_level 192 "empty_repo": false, 193 "package_registry_access_level": "enabled", 194 "service_desk_enabled": false, 195 "service_desk_address": null, 196 "autoclose_referenced_issues": true, 197 "enforce_auth_checks_on_uploads": true, 198 "suggestion_commit_message": null, 199 "merge_commit_template": null, 200 "mr_default_title_template": null, 201 "squash_commit_template": null, 202 "secret_push_protection_enabled": false, 203 "issue_branch_template": "gitlab/%{id}-%{title}", 204 "statistics": { 205 "commit_count": 12, 206 "storage_size": 2066080, 207 "repository_size": 2066080, 208 "lfs_objects_size": 0, 209 "job_artifacts_size": 0, 210 "pipeline_artifacts_size": 0, 211 "packages_size": 0, 212 "snippets_size": 0, 213 "uploads_size": 0, 214 "container_registry_size": 0 215 }, 216 "container_registry_image_prefix": "registry.example.com/brightbox/puppet", 217 "_links": { 218 "self": "http://example.com/api/v4/projects", 219 "issues": "http://example.com/api/v4/projects/1/issues", 220 "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", 221 "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", 222 "labels": "http://example.com/api/v4/projects/1/labels", 223 "events": "http://example.com/api/v4/projects/1/events", 224 "members": "http://example.com/api/v4/projects/1/members", 225 "cluster_agents": "http://example.com/api/v4/projects/1/cluster_agents" 226 } 227 } 228]

列出属性#

列出项目的属性。

列出项目的所有成员#

列出所有可以访问指定项目的成员。

plaintext
GET /projects/:id/users

支持的属性:

属性类型是否必需描述
id整数或字符串项目的 ID 或 URL 编码路径
search字符串usernamename 搜索特定成员。
skip_users整数数组排除指定 ID 的成员。

如果成功,返回 200 OK 以及以下响应属性:

属性类型描述
id整数用户的 ID。
username字符串用户的用户名。
name字符串用户的全名。
state字符串用户账户状态。可能的值:activeblocked
avatar_url字符串用户头像图片的 URL。
web_url字符串在浏览器中访问用户个人资料的 URL。

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://jihulab.com/api/v4/projects/<project_id>/users" \

示例响应:

json
1[ 2 { 3 "id": 1, 4 "username": "john_smith", 5 "name": "John Smith", 6 "state": "active", 7 "avatar_url": "http://localhost:3000/uploads/user/avatar/1/cd8.jpeg", 8 "web_url": "http://localhost:3000/john_smith" 9 }, 10 { 11 "id": 2, 12 "username": "jack_smith", 13 "name": "Jack Smith", 14 "state": "blocked", 15 "avatar_url": "http://gravatar.com/../e32131cd8.jpeg", 16 "web_url": "http://localhost:3000/jack_smith" 17 } 18]

列出所有祖先群组#

列出指定项目的所有祖先群组。

plaintext
GET /projects/:id/groups

支持的属性:

属性类型是否必需描述
id整数或字符串项目的 ID 或 URL 编码路径
search字符串按群组 ID 搜索特定群组。
shared_min_access_level整数仅返回至少具有指定访问级别的共享群组。可能的值:5(最小权限)、10(访客)、15(计划者)、20(报告者)、25(安全经理)、30(开发者)、40(维护者)或 50(所有者)。
shared_visible_only布尔值如果为 true,仅返回已认证用户可访问的共享群组。
skip_groups整数数组跳过传入的群组 ID。
with_shared布尔值包括与此群组共享的项目。默认为 false

如果成功,返回 200 OK 以及以下响应属性:

属性类型描述
id整数群组的 ID。
name字符串群组名称。
avatar_url字符串群组头像图片的 URL。
web_url字符串在浏览器中访问群组的 URL。
full_name字符串群组全名。
full_path字符串群组完整路径。

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/<project_id>/groups"

示例响应:

json
1[ 2 { 3 "id": 1, 4 "name": "Foobar Group", 5 "avatar_url": "http://localhost:3000/uploads/group/avatar/1/foo.jpg", 6 "web_url": "http://localhost:3000/groups/foo-bar", 7 "full_name": "Foobar Group", 8 "full_path": "foo-bar" 9 }, 10 { 11 "id": 2, 12 "name": "Shared Group", 13 "avatar_url": "http://gitlab.example.com/uploads/group/avatar/1/bar.jpg", 14 "web_url": "http://gitlab.example.com/groups/foo/bar", 15 "full_name": "Shared Group", 16 "full_path": "foo/shared" 17 } 18]

列出可邀请到项目的所有群组#

列出所有可以邀请到项目的群组。

plaintext
GET /projects/:id/share_locations

支持的属性:

属性类型是否必需描述
id整数或字符串项目的 ID 或 URL 编码路径
search字符串按群组 ID 搜索特定群组。

如果成功,返回 200 OK 以及以下响应属性:

属性类型描述
id整数群组的 ID。
web_url字符串在浏览器中访问群组的 URL。
name字符串群组名称。
avatar_url字符串群组头像图片的 URL。
full_name字符串群组全名。
full_path字符串群组完整路径。

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/<project_id>/share_locations"

示例响应:

json
1[ 2 { 3 "id": 22, 4 "web_url": "http://127.0.0.1:3000/groups/gitlab-org", 5 "name": "Gitlab Org", 6 "avatar_url": null, 7 "full_name": "Gitlab Org", 8 "full_path": "gitlab-org" 9 }, 10 { 11 "id": 25, 12 "web_url": "http://127.0.0.1:3000/groups/gnuwget", 13 "name": "Gnuwget", 14 "avatar_url": null, 15 "full_name": "Gnuwget", 16 "full_path": "gnuwget" 17 } 18]

列出项目中所有被邀请的群组#

列出项目中所有被邀请的群组。当未认证访问时,仅返回公开的被邀请群组。 此端点速率限制为每分钟 60 个请求,限制依据:

  • 对于已认证用户,按用户限制
  • 对于未认证用户,按 IP 地址限制

此端点支持分页:

  • 使用基于偏移量的分页可访问最多 50,000 个项目。
  • 使用基于键集的分页可列出超过 50,000 个项目。

更多信息,参见分页

plaintext
GET /projects/:id/invited_groups

支持的属性:

属性类型是否必需描述
id整数或字符串群组的 ID 或 URL 编码路径
search字符串返回与搜索条件匹配的授权群组列表。
min_access_level整数限制为当前用户至少具有指定访问级别的群组。可能的值:5(最小权限)、10(访客)、15(计划者)、20(报告者)、25(安全经理)、30(开发者)、40(维护者)或 50(所有者)。
relation字符串数组按关系过滤群组。可能的值:directinherited
with_custom_attributes布尔值如果为 true,在响应中返回自定义属性。需要管理员权限。

如果成功,返回 200 OK 以及以下响应属性:

属性类型描述
id整数群组的 ID。
web_url字符串在浏览器中访问群组的 URL。
name字符串群组名称。
avatar_url字符串群组头像图片的 URL。
full_name字符串群组全名。
full_path字符串群组完整路径。

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/<project_id>/invited_groups"

示例响应:

json
1[ 2 { 3 "id": 35, 4 "web_url": "https://gitlab.example.com/groups/twitter", 5 "name": "Twitter", 6 "avatar_url": null, 7 "full_name": "Twitter", 8 "full_path": "twitter" 9 } 10]

获取编程语言使用信息#

获取指定项目中使用的所有编程语言的信息。

plaintext
GET /projects/:id/languages

支持的属性:

属性类型是否必需描述
id整数或字符串项目的 ID 或 URL 编码路径

如果成功,返回 200 OK 以及编程语言及其使用百分比的列表。

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/5/languages"

示例响应:

json
1{ 2 "Ruby": 66.69, 3 "JavaScript": 22.98, 4 "HTML": 7.91, 5 "CoffeeScript": 2.42 6}

管理项目#

管理项目,包括创建、删除和归档。

创建项目#

版本历史
  • operations_access_level 在极狐GitLab 16.0 移除。
  • model_registry_access_level 在极狐GitLab 16.7 引入。
  • packages_enabled 在极狐GitLab 17.10 弃用。
  • package_registry_access_level 在极狐GitLab 18.5 引入。

创建一个属于已认证用户的项目。

如果你的 HTTP 代码仓并非公共可访问,可将身份验证信息添加到 URL https://username:password@gitlab.company.com/group/project.git 中,其中 password 是一个启用了 api 范围的公开访问密钥。

plaintext
POST /projects

支持的通用项目属性:

属性类型是否必填描述
namestring是(如果未提供 path 则必填)新项目的名称。如果未提供 name,则与 path 相同。
pathstring是(如果未提供 name 则必填)新项目的代码仓库名称。如果未提供 name,则根据名称自动生成(生成为小写带连字符的格式)。路径不能以特殊字符开头或结尾,也不能包含连续的特殊字符。
allow_merge_on_skipped_pipelineboolean设置合并请求是否可以在流水线作业被跳过时合并。
approvals_before_mergeinteger默认需要多少审批者批准合并请求。要配置审批规则,请参阅合并请求审批 API。在极狐GitLab 16.0 中已弃用。仅限专业版和旗舰版。
auto_cancel_pending_pipelinesstring自动取消待处理的流水线。此操作将在启用和禁用状态之间切换;不是布尔值。
auto_devops_deploy_strategystring自动部署策略(continuousmanualtimed_incremental)。
auto_devops_enabledboolean为此项目启用 Auto DevOps。
autoclose_referenced_issuesboolean设置是否在默认分支上自动关闭引用的议题。
avatarmixed项目的头像图片文件。
build_git_strategystringGit 策略。默认为 fetch
build_timeoutinteger作业可以运行的最长时间,以秒为单位。
ci_config_pathstringCI 配置文件的路径。
container_expiration_policy_attributeshash更新此项目的镜像清理策略。接受:cadence(string)、keep_n(integer)、older_than(string)、name_regex(string)、name_regex_delete(string)、name_regex_keep(string)、enabled(boolean)。请参阅容器镜像仓库文档了解 cadencekeep_nolder_than 值的更多信息。
container_registry_enabledboolean(已弃用)为此项目启用容器镜像仓库。改用 container_registry_access_level
default_branchstring默认分支名称。接受分支名称(例如 main)或完全限定的引用(例如 refs/heads/main)。如果提供了完全限定的引用,API 会去除 refs/heads/ 前缀。要求 initialize_with_readmetrue
descriptionstring项目的简短描述。
emails_disabledboolean(已弃用)禁用邮件通知。改用 emails_enabled
emails_enabledboolean启用邮件通知。
external_authorization_classification_labelstring项目的分类标签。仅限专业版和旗舰版。
group_runners_enabledboolean为此项目启用群组 Runner。
group_with_project_templates_idinteger对于群组级别的自定义模板,指定从中获取所有自定义项目模板的群组 ID。留空则使用实例级别的模板。要求 use_custom_template 为 true。仅限专业版和旗舰版。
import_urlstring从中导入代码仓库的 URL。当 URL 值非空时,不得将 initialize_with_readme 设置为 true。这样做可能会导致以下错误not a git repository
initialize_with_readmeboolean是否创建一个仅包含 README.md 文件的 Git 仓库。默认为 false。当此布尔值为 true 时,不得传递 import_url 或其他指定仓库替代内容的端点属性。这样做可能会导致以下错误not a git repository
issues_enabledboolean(已弃用)为此项目启用议题。改用 issues_access_level
jobs_enabledboolean(已弃用)为此项目启用作业。改用 builds_access_level
lfs_enabledboolean启用 LFS。
merge_methodstring设置项目的合并方法。可以是 merge(合并提交)、rebase_merge(带半线性历史的合并提交)或 ff(快进合并)。
merge_pipelines_enabledboolean启用或禁用合并结果流水线。
merge_requests_enabledboolean(已弃用)为此项目启用合并请求。改用 merge_requests_access_level
merge_trains_enabledboolean启用或禁用合并队列。
merge_trains_skip_train_allowedboolean允许合并队列中的合并请求在流水线完成之前合并。
mirror_trigger_buildsboolean拉取镜像触发构建。仅限专业版和旗舰版。
mirrorboolean在项目中启用拉取镜像。仅限专业版和旗舰版。
namespace_idinteger新项目的命名空间。指定群组 ID 或子群组 ID。如果未提供,默认为当前用户的个人命名空间。
only_allow_merge_if_all_discussions_are_resolvedboolean设置是否只有在所有讨论都解决后才能合并合并请求。
only_allow_merge_if_all_status_checks_passedboolean指示除非所有状态检查通过,否则应阻止合并请求的合并。默认为 false。引入于极狐GitLab 15.5,带有一个默认禁用的功能标志 only_allow_merge_if_all_status_checks_passed。仅限旗舰版。
only_allow_merge_if_pipeline_succeedsboolean设置合并请求是否只能在流水线成功时合并。此设置在项目设置中称为流水线必须成功
packages_enabledboolean在极狐GitLab 17.10 中已弃用。启用或禁用软件包仓库功能。改用 package_registry_access_level
package_registry_access_levelstring启用或禁用软件包仓库功能。
printing_merge_request_link_enabledboolean在命令行推送时显示创建/查看合并请求的链接。
public_buildsboolean(已弃用)如果为 true,则非项目成员也可以查看作业。改用 public_jobs
public_jobsboolean如果为 true,则非项目成员也可以查看作业。
repository_object_formatstring仓库对象格式。默认为 sha1引入于极狐GitLab 16.9。
remove_source_branch_after_mergeboolean为所有新的合并请求默认启用“删除源分支”选项。
repository_storagestring代码仓库所在的存储分片。(仅限管理员)
request_access_enabledboolean允许用户请求成员访问权限。
resolve_outdated_diff_discussionsboolean自动解决推送后行变更上过时的合并请求差异讨论。
shared_runners_enabledboolean为此项目启用实例 Runner。
show_default_award_emojisboolean显示默认表情反应。
snippets_enabledboolean(已弃用)为此项目启用代码片段。改用 snippets_access_level
squash_optionstring可以是 neveralwaysdefault_ondefault_off
tag_listarray项目的标签列表;输入应最终分配给项目的标签数组。在极狐GitLab 14.0 中已弃用。改用 topics
template_namestring当不与 use_custom_template 一起使用时,为内置项目模板的名称。当与 use_custom_template 一起使用时,为自定义项目模板的名称。
template_project_idinteger当与 use_custom_template 一起使用时,为自定义项目模板的项目 ID。使用项目 ID 优于使用 template_name,因为 template_name 可能不明确。仅限专业版和旗舰版。
topicsarray项目的主题列表;输入应最终分配给项目的主题数组。
use_custom_templateboolean使用自定义实例群组(结合 group_with_project_templates_id)项目模板。仅限专业版和旗舰版。
visibilitystring请参阅项目可见性级别
warn_about_potentially_unwanted_charactersboolean启用对此项目中潜在不受欢迎字符的警告。
wiki_enabledboolean(已弃用)为此项目启用 Wiki。改用 wiki_access_level

示例请求:

shell
curl --request POST --header "PRIVATE-TOKEN: <your-token>" \ --header "Content-Type: application/json" --data '{ "name": "new_project", "description": "New Project", "path": "new_project", "namespace_id": "42", "initialize_with_readme": "true"}' \ --url "https://gitlab.example.com/api/v4/projects/"

要设置单个项目功能的可见性级别,请参阅项目功能可见性级别

为用户创建项目#

版本历史
  • operations_access_level 在极狐GitLab 16.0 中移除。
  • model_registry_access_level 在极狐GitLab 16.7 中引入。
  • packages_enabled 在极狐GitLab 17.10 中弃用。
  • package_registry_access_level 在极狐GitLab 18.5 中引入。
  • mr_default_title_template 在极狐GitLab 18.11 中引入,带有一个名为 mr_default_title_template功能标志。默认禁用。

为用户创建一个项目。

前提条件:

  • 您必须是管理员。

如果您的 HTTP 仓库无法公开访问,请在 URL 中添加认证信息。例如, https://username:password@gitlab.company.com/group/project.git,其中 password 是一个已启用 api 范围的公共访问密钥。

plaintext
POST /projects/user/:user_id

支持的通用项目属性:

属性类型是否必填描述
name字符串新项目的名称。
user_id整数项目所有者的用户 ID。
allow_merge_on_skipped_pipeline布尔值设置是否允许在跳过作业的情况下合并合并请求。
approvals_before_merge整数默认情况下合并请求需要多少审批人。在极狐GitLab 16.0 中已弃用。要配置审批规则,请参阅合并请求审批 API。仅限专业版和旗舰版。
auto_cancel_pending_pipelines字符串自动取消待处理的流水线。此操作在启用和禁用状态之间切换,不是布尔值。
auto_devops_deploy_strategy字符串自动部署策略(continuousmanualtimed_incremental)。
auto_devops_enabled布尔值为此项目启用 Auto DevOps。
autoclose_referenced_issues布尔值设置是否在默认分支上自动关闭引用的议题。
avatar混合类型项目头像的图片文件。
build_git_strategy字符串Git 策略。默认为 fetch
build_timeout整数作业可以运行的最长时间(以秒为单位)。
ci_config_path字符串CI 配置文件的路径。
container_registry_enabled布尔值(已弃用) 启用项目的容器镜像仓库。请改用 container_registry_access_level
default_branch字符串默认分支名称。要求 initialize_with_readmetrue
description字符串简短的项目描述。
emails_disabled布尔值(已弃用) 禁用邮件通知。请改用 emails_enabled
emails_enabled布尔值启用邮件通知。
enforce_auth_checks_on_uploads布尔值对上传文件强制执行身份验证检查。
external_authorization_classification_label字符串项目的分类标签。仅限专业版和旗舰版。
group_runners_enabled布尔值为此项目启用群组 Runner。
group_with_project_templates_id整数对于群组级别的自定义模板,指定从中获取所有自定义项目模板的群组 ID。对于实例级模板,留空。要求 use_custom_template 为 true。仅限专业版和旗舰版。
import_url字符串要导入的仓库的 URL。
initialize_with_readme布尔值默认为 false
issue_branch_template字符串用于为从议题创建的分支建议名称的模板。(在极狐GitLab 15.6 中引入)
issues_enabled布尔值(已弃用) 启用此项目的议题。请改用 issues_access_level
jobs_enabled布尔值(已弃用) 启用此项目的作业。请改用 builds_access_level
lfs_enabled布尔值启用 LFS。
merge_commit_template字符串用于在合并请求中创建合并提交消息的模板。
merge_method字符串设置项目的合并方法。可以是 merge(合并提交)、rebase_merge(具有半线性历史的合并提交)或 ff(快进合并)。
merge_requests_enabled布尔值(已弃用) 启用此项目的合并请求。请改用 merge_requests_access_level
mr_default_title_template字符串用于设置默认合并请求标题的模板。
mirror_trigger_builds布尔值拉取镜像触发构建。仅限专业版和旗舰版。
mirror布尔值在项目中启用拉取镜像。仅限专业版和旗舰版。
namespace_id整数新项目的命名空间(默认为当前用户的命名空间)。
only_allow_merge_if_all_discussions_are_resolved布尔值设置是否仅在所有讨论都解决后才能合并合并请求。
only_allow_merge_if_all_status_checks_passed布尔值指示是否应阻止合并合并请求,除非所有状态检查都已通过。默认为 false。在极狐GitLab 15.5 中引入,功能标志为 only_allow_merge_if_all_status_checks_passed,默认禁用。仅限旗舰版。
only_allow_merge_if_pipeline_succeeds布尔值设置是否仅在作业成功后才能合并合并请求。
packages_enabled布尔值在极狐GitLab 17.10 中已弃用。启用或禁用软件包仓库功能。请改用 package_registry_access_level
package_registry_access_level字符串启用或禁用软件包仓库功能。
path字符串新项目的自定义仓库名称。默认根据名称生成。
printing_merge_request_link_enabled布尔值在从命令行推送时显示创建/查看合并请求的链接。
public_builds布尔值(已弃用) 如果为 true,非项目成员也可以查看作业。请改用 public_jobs
public_jobs布尔值如果为 true,非项目成员也可以查看作业。
repository_object_format字符串仓库对象格式。默认为 sha1。在极狐GitLab 16.9 中引入。
remove_source_branch_after_merge布尔值对所有新合并请求默认启用删除源分支选项。
repository_storage字符串仓库所在的存储分片。(仅管理员)
request_access_enabled布尔值允许用户请求成员访问权限。
resolve_outdated_diff_discussions布尔值在推送更改行后自动解决合并请求差异讨论。
shared_runners_enabled布尔值为此项目启用实例 Runner。
show_default_award_emojis布尔值显示默认表情符号反应。
snippets_enabled布尔值(已弃用) 启用此项目的代码片段。请改用 snippets_access_level
squash_commit_template字符串用于在合并请求中创建压缩提交消息的模板。
squash_option字符串可以是 neveralwaysdefault_ondefault_off
suggestion_commit_message字符串用于应用合并请求建议的提交消息。
tag_list数组(在极狐GitLab 14.0 中已弃用) 项目的标签列表;放入一个标签数组,这些标签最终将分配给项目。请改用 topics
template_name字符串当不使用 use_custom_template 时,内置项目模板的名称。当与 use_custom_template 一起使用时,自定义项目模板的名称。
topics数组项目的主题列表。
use_custom_template布尔值使用自定义实例或群组(使用 group_with_project_templates_id)项目模板。仅限专业版和旗舰版。
visibility字符串参阅项目可见性级别。
warn_about_potentially_unwanted_characters布尔值在此项目中启用关于使用可能不需要的字符的警告。
wiki_enabled布尔值(已弃用) 启用此项目的 Wiki。请改用 wiki_access_level

要设置单个项目功能的可见性级别,请参阅项目功能可见性级别。

更新项目#

版本历史
  • operations_access_level 在极狐GitLab 16.0 中已移除。
  • model_registry_access_level 在极狐GitLab 16.7 中引入。
  • packages_enabled 在极狐GitLab 17.10 中已弃用。
  • package_registry_access_level 在极狐GitLab 18.5 中引入。
  • protect_merge_request_pipelinesci_display_pipeline_variables 在极狐GitLab 18.10 中引入。
  • mr_default_title_template 在极狐GitLab 18.11 中引入,带有功能标志 mr_default_title_template,默认禁用。

更新现有项目。

如果你的 HTTP 仓库不公开访问,请向 URL https://username:password@gitlab.company.com/group/project.git 添加身份验证信息,其中 password 是具有 api 范围的公共访问密钥。

plaintext
PUT /projects/:id

支持的通用项目属性:

属性类型是否必填描述
id整数或字符串项目的 ID 或 URL 编码路径。
allow_merge_on_skipped_pipeline布尔值设置是否允许在跳过作业的情况下合并合并请求。
allow_pipeline_trigger_approve_deployment布尔值设置是否允许流水线触发者批准部署。仅限专业版和旗舰版。
only_allow_merge_if_all_status_checks_passed布尔值指示是否应阻止合并合并请求,除非所有状态检查都已通过。默认为 false。

在极狐GitLab 15.5 中引入,功能标志为 only_allow_merge_if_all_status_checks_passed,默认禁用。功能标志在极狐GitLab 15.9 中默认启用。仅限旗舰版。
approvals_before_merge整数默认情况下合并请求需要多少审批人。在极狐GitLab 16.0 中已弃用。要配置审批规则,请参阅合并请求审批 API。仅限专业版和旗舰版。
auto_cancel_pending_pipelines字符串自动取消待处理的流水线。此操作在启用和禁用状态之间切换,不是布尔值。
auto_devops_deploy_strategy字符串自动部署策略(continuousmanualtimed_incremental)。
auto_devops_enabled布尔值为此项目启用 Auto DevOps。
auto_duo_code_review_enabled布尔值启用极狐GitLab Duo 对合并请求的自动审查。请参阅合并请求中的极狐GitLab Duo。仅限旗舰版。
autoclose_referenced_issues布尔值设置是否在默认分支上自动关闭引用的议题。
avatar混合类型项目头像的图片文件。
build_git_strategy字符串Git 策略。默认为 fetch
build_timeout整数作业可以运行的最长时间(以秒为单位)。
ci_config_path字符串CI 配置文件的路径。
ci_default_git_depth整数浅克隆的默认修订版本数量。
ci_delete_pipelines_in_seconds整数删除早于配置时间的流水线。
ci_display_pipeline_variables布尔值在手动运行流水线后,在流水线详情页显示所有手动定义的变量。
ci_forward_deployment_enabled布尔值启用或禁用阻止过时的部署作业。
ci_forward_deployment_rollback_allowed布尔值启用或禁用允许回滚部署的作业重试。
ci_allow_fork_pipelines_to_run_in_parent_project布尔值启用或禁用来自分支的合并请求在父项目中运行流水线。(在极狐GitLab 15.3 中引入)
ci_id_token_sub_claim_components数组包含在 ID 令牌的 sub 声明中的字段。接受一个以 project_path 开头的数组。该数组还可以包括 ref_typerefref_protectedenvironment_protecteddeployment_tier。默认为 ["project_path", "ref_type", "ref"]。在极狐GitLab 17.10 中引入。environment_protecteddeployment_tier 的支持在极狐GitLab 18.7 中引入。
ci_separated_caches布尔值设置是否应根据分支保护状态分离缓存。
ci_restrict_pipeline_cancellation_role字符串设置取消流水线或作业所需的角色。可以是 developermaintainerno_one。在极狐GitLab 16.8 中引入。仅限专业版和旗舰版。
ci_pipeline_variables_minimum_override_role字符串可以指定哪个角色可以覆盖变量。可以是 ownermaintainerdeveloperno_one_allowed。在极狐GitLab 17.1 中引入。在极狐GitLab 17.1 到 17.7 中,必须启用 restrict_user_defined_variables
ci_push_repository_for_job_token_allowed布尔值启用或禁用使用作业令牌推送到项目仓库的能力。在极狐GitLab 17.2 中引入。
container_expiration_policy_attributes哈希更新此项目的镜像清理策略。接受:cadence(字符串)、keep_n(整数)、older_than(字符串)、name_regex(字符串)、name_regex_delete(字符串)、name_regex_keep(字符串)、enabled(布尔值)。
container_registry_enabled布尔值(已弃用) 启用项目的容器镜像仓库。请改用 container_registry_access_level
default_branch字符串默认分支名称。
description字符串简短的项目描述。
duo_remote_flows_enabled布尔值确定是否可以在项目中运行流。
duo_sast_fp_detection_enabled布尔值启用或禁用 SAST 误报检测。请参阅为项目开启 SAST 误报检测。
duo_sast_vr_workflow_enabled布尔值启用或禁用 SAST 漏洞修复工作流。请参阅为项目开启 SAST 漏洞修复工作流。
emails_disabled布尔值(已弃用) 禁用邮件通知。请改用 emails_enabled
emails_enabled布尔值启用邮件通知。
enforce_auth_checks_on_uploads布尔值对上传文件强制执行身份验证检查。
external_authorization_classification_label字符串项目的分类标签。仅限专业版和旗舰版。
group_runners_enabled布尔值为此项目启用群组 Runner。
import_url字符串仓库从中导入的 URL。
issues_enabled布尔值(已弃用) 启用此项目的议题。请改用 issues_access_level
issues_template字符串新议题的默认描述。格式为极狐GitLab Flavored Markdown。仅限专业版和旗舰版。
merge_requests_template字符串新合并请求的默认描述。格式为极狐GitLab Flavored Markdown。仅限专业版和旗舰版。
jobs_enabled布尔值(已弃用) 启用此项目的作业。请改用 builds_access_level
keep_latest_artifact布尔值禁用或启用为此项目保留最新产物。
lfs_enabled布尔值启用 LFS。
max_artifacts_size整数单个作业产物的最大文件大小(兆字节)。
merge_commit_template字符串用于在合并请求中创建合并提交消息的模板。
merge_method字符串设置项目的合并方法。可以是 merge(合并提交)、rebase_merge(具有半线性历史的合并提交)或 ff(快进合并)。
merge_pipelines_enabled布尔值启用或禁用合并结果流水线。
merge_requests_enabled布尔值(已弃用) 启用此项目的合并请求。请改用 merge_requests_access_level
mr_default_title_template字符串用于设置默认合并请求标题的模板。
merge_trains_enabled布尔值启用或禁用合并队列。
merge_trains_skip_train_allowed布尔值允许合并队列的合并请求在不等待流水线完成的情况下合并。
mirror_overwrites_diverged_branches布尔值拉取镜像覆盖已分化的分支。仅限专业版和旗舰版。
mirror_trigger_builds布尔值拉取镜像触发构建。仅限专业版和旗舰版。
mirror_user_id整数负责拉取镜像事件所有活动的用户。(仅管理员) 仅限专业版和旗舰版。
mirror布尔值在项目中启用拉取镜像。仅限专业版和旗舰版。
mr_default_target_self布尔值对于派生的项目,将合并请求的目标指向此项目。如果为 false,则目标为上游项目。
name字符串项目的名称。
only_allow_merge_if_all_discussions_are_resolved布尔值设置是否仅在所有讨论都解决后才能合并合并请求。
only_allow_merge_if_pipeline_succeeds布尔值设置是否仅在作业成功后才能合并合并请求。
only_mirror_protected_branches布尔值仅镜像受保护的分支。仅限专业版和旗舰版。
packages_enabled布尔值在极狐GitLab 17.10 中已弃用。启用或禁用软件包仓库功能。请改用 package_registry_access_level
package_registry_access_level字符串启用或禁用软件包仓库功能。
path字符串项目的自定义仓库名称。默认根据名称生成。
prevent_merge_without_jira_issue布尔值设置合并请求是否要求关联的议题。

注意:最后一行 prevent_merge_without_jira_issue 的描述被截断,原文可能还有更多内容,我们按看到的翻译。| 属性 | 类型 | 是否必填 | 描述 | |:---------------------------------------------------|:--------|:---------|:------------| | name | 字符串 | 是 | 新项目的名称。 | | user_id | 整数 | 是 | 项目所有者的用户 ID。 | | allow_merge_on_skipped_pipeline | 布尔值 | 否 | 设置是否允许在跳过作业的情况下合并合并请求。 | | approvals_before_merge | 整数 | 否 | 默认情况下合并请求需要多少审批人。在极狐GitLab 16.0 中已弃用。要配置审批规则,请参阅合并请求审批 API。仅限专业版和旗舰版。 | | auto_cancel_pending_pipelines | 字符串 | 否 | 自动取消待处理的流水线。此操作在启用和禁用状态之间切换,不是布尔值。 | | auto_devops_deploy_strategy | 字符串 | 否 | 自动部署策略(continuousmanualtimed_incremental)。 | | auto_devops_enabled | 布尔值 | 否 | 为此项目启用 Auto DevOps。 | | autoclose_referenced_issues | 布尔值 | 否 | 设置是否在默认分支上自动关闭引用的议题。 | | avatar | 混合类型 | 否 | 项目头像的图片文件。 | | build_git_strategy | 字符串 | 否 | Git 策略。默认为 fetch。 | | build_timeout | 整数 | 否 | 作业可以运行的最长时间(以秒为单位)。 | | ci_config_path | 字符串 | 否 | CI 配置文件的路径。 | | container_registry_enabled | 布尔值 | 否 | (已弃用) 启用项目的容器镜像仓库。请改用 container_registry_access_level。 | | default_branch | 字符串 | 否 | 默认分支名称。要求 initialize_with_readmetrue。 | | description | 字符串 | 否 | 简短的项目描述。 | | emails_disabled | 布尔值 | 否 | (已弃用) 禁用邮件通知。请改用 emails_enabled。 | | emails_enabled | 布尔值 | 否 | 启用邮件通知。 | | enforce_auth_checks_on_uploads | 布尔值 | 否 | 对上传文件强制执行身份验证检查。 | | external_authorization_classification_label | 字符串 | 否 | 项目的分类标签。仅限专业版和旗舰版。 | | group_runners_enabled | 布尔值 | 否 | 为此项目启用群组 Runner。 | | group_with_project_templates_id | 整数 | 否 | 对于群组级别的自定义模板,指定从中获取所有自定义项目模板的群组 ID。对于实例级模板,留空。要求 use_custom_template 为 true。仅限专业版和旗舰版。 | | import_url | 字符串 | 否 | 要导入的仓库的 URL。 | | initialize_with_readme | 布尔值 | 否 | 默认为 false。 | | issue_branch_template | 字符串 | 否 | 用于为从议题创建的分支建议名称的模板。(在极狐GitLab 15.6 中引入) | | issues_enabled | 布尔值 | 否 | (已弃用) 启用此项目的议题。请改用 issues_access_level。 | | jobs_enabled | 布尔值 | 否 | (已弃用) 启用此项目的作业。请改用 builds_access_level。 | | lfs_enabled | 布尔值 | 否 | 启用 LFS。 | | merge_commit_template | 字符串 | 否 | 用于在合并请求中创建合并提交消息的模板。 | | merge_method | 字符串 | 否 | 设置项目的合并方法。可以是 merge(合并提交)、rebase_merge(具有半线性历史的合并提交)或 ff(快进合并)。 | | merge_requests_enabled | 布尔值 | 否 | (已弃用) 启用此项目的合并请求。请改用 merge_requests_access_level。 | | mr_default_title_template | 字符串 | 否 | 用于设置默认合并请求标题的模板。 | | mirror_trigger_builds | 布尔值 | 否 | 拉取镜像触发构建。仅限专业版和旗舰版。 | | mirror | 布尔值 | 否 | 在项目中启用拉取镜像。仅限专业版和旗舰版。 | | namespace_id | 整数 | 否 | 新项目的命名空间(默认为当前用户的命名空间)。 | | only_allow_merge_if_all_discussions_are_resolved | 布尔值 | 否 | 设置是否仅在所有讨论都解决后才能合并合并请求。 | | only_allow_merge_if_all_status_checks_passed | 布尔值 | 否 | 指示是否应阻止合并合并请求,除非所有状态检查都已通过。默认为 false。在极狐GitLab 15.5 中引入,功能标志为 only_allow_merge_if_all_status_checks_passed,默认禁用。仅限旗舰版。 | | only_allow_merge_if_pipeline_succeeds | 布尔值 | 否 | 设置是否仅在作业成功后才能合并合并请求。 | | packages_enabled | 布尔值 | 否 | 在极狐GitLab 17.10 中已弃用。启用或禁用软件包仓库功能。请改用 package_registry_access_level。 | | package_registry_access_level | 字符串 | 否 | 启用或禁用软件包仓库功能。 | | path | 字符串 | 否 | 新项目的自定义仓库名称。默认根据名称生成。 | | printing_merge_request_link_enabled | 布尔值 | 否 | 在从命令行推送时显示创建/查看合并请求的链接。 | | public_builds | 布尔值 | 否 | (已弃用) 如果为 true,非项目成员也可以查看作业。请改用 public_jobs。 | | public_jobs | 布尔值 | 否 | 如果为 true,非项目成员也可以查看作业。 | | repository_object_format | 字符串 | 否 | 仓库对象格式。默认为 sha1。在极狐GitLab 16.9 中引入。 | | remove_source_branch_after_merge | 布尔值 | 否 | 对所有新合并请求默认启用删除源分支选项。 | | repository_storage | 字符串 | 否 | 仓库所在的存储分片。(仅管理员) | | request_access_enabled | 布尔值 | 否 | 允许用户请求成员访问权限。 | | resolve_outdated_diff_discussions | 布尔值 | 否 | 在推送更改行后自动解决合并请求差异讨论。 | | shared_runners_enabled | 布尔值 | 否 | 为此项目启用实例 Runner。 | | show_default_award_emojis | 布尔值 | 否 | 显示默认表情符号反应。 | | snippets_enabled | 布尔值 | 否 | (已弃用) 启用此项目的代码片段。请改用 snippets_access_level。 | | squash_commit_template | 字符串 | 否 | 用于在合并请求中创建压缩提交消息的模板。 | | squash_option | 字符串 | 否 | 可以是 neveralwaysdefault_ondefault_off。 | | suggestion_commit_message | 字符串 | 否 | 用于应用合并请求建议的提交消息。 | | tag_list | 数组 | 否 | (在极狐GitLab 14.0 中已弃用) 项目的标签列表;放入一个标签数组,这些标签最终将分配给项目。请改用 topics。 | | template_name | 字符串 | 否 | 当不使用 use_custom_template 时,内置项目模板的名称。当与 use_custom_template 一起使用时,自定义项目模板的名称。 | | topics | 数组 | 否 | 项目的主题列表。 | | use_custom_template | 布尔值 | 否 | 使用自定义实例或群组(使用 group_with_project_templates_id)项目模板。仅限专业版和旗舰版。 | | visibility | 字符串 | 否 | 参阅项目可见性级别。 | | warn_about_potentially_unwanted_characters | 布尔值 | 否 | 在此项目中启用关于使用可能不需要的字符的警告。 | | wiki_enabled | 布尔值 | 否 | (已弃用) 启用此项目的 Wiki。请改用 wiki_access_level。 |

要设置单个项目功能的可见性级别,请参阅项目功能可见性级别。

Update a project#

版本历史
  • operations_access_level 在极狐GitLab 16.0 中已移除。
  • model_registry_access_level 在极狐GitLab 16.7 中引入。
  • packages_enabled 在极狐GitLab 17.10 中已弃用。
  • package_registry_access_level 在极狐GitLab 18.5 中引入。
  • protect_merge_request_pipelinesci_display_pipeline_variables 在极狐GitLab 18.10 中引入。
  • mr_default_title_template 在极狐GitLab 18.11 中引入,带有功能标志 mr_default_title_template,默认禁用。

更新现有项目。

如果你的 HTTP 仓库不公开访问,请向 URL https://username:password@gitlab.company.com/group/project.git 添加身份验证信息,其中 password 是具有 api 范围的公共访问密钥。

plaintext
PUT /projects/:id

支持的通用项目属性:

属性类型是否必填描述
id整数或字符串项目的 ID 或 URL 编码路径。
allow_merge_on_skipped_pipeline布尔值设置是否允许在跳过作业的情况下合并合并请求。
allow_pipeline_trigger_approve_deployment布尔值设置是否允许流水线触发者批准部署。仅限专业版和旗舰版。
only_allow_merge_if_all_status_checks_passed布尔值指示是否应阻止合并合并请求,除非所有状态检查都已通过。默认为 false。

在极狐GitLab 15.5 中引入,功能标志为 only_allow_merge_if_all_status_checks_passed,默认禁用。功能标志在极狐GitLab 15.9 中默认启用。仅限旗舰版。
approvals_before_merge整数默认情况下合并请求需要多少审批人。在极狐GitLab 16.0 中已弃用。要配置审批规则,请参阅合并请求审批 API。仅限专业版和旗舰版。
auto_cancel_pending_pipelines字符串自动取消待处理的流水线。此操作在启用和禁用状态之间切换,不是布尔值。
auto_devops_deploy_strategy字符串自动部署策略(continuousmanualtimed_incremental)。
auto_devops_enabled布尔值为此项目启用 Auto DevOps。
auto_duo_code_review_enabled布尔值启用极狐GitLab Duo 对合并请求的自动审查。请参阅合并请求中的极狐GitLab Duo。仅限旗舰版。
autoclose_referenced_issues布尔值设置是否在默认分支上自动关闭引用的议题。
avatar混合类型项目头像的图片文件。
build_git_strategy字符串Git 策略。默认为 fetch
build_timeout整数作业可以运行的最长时间(以秒为单位)。
ci_config_path字符串CI 配置文件的路径。
ci_default_git_depth整数浅克隆的默认修订版本数量。
ci_delete_pipelines_in_seconds整数删除早于配置时间的流水线。
ci_display_pipeline_variables布尔值在手动运行流水线后,在流水线详情页显示所有手动定义的变量。
ci_forward_deployment_enabled布尔值启用或禁用阻止过时的部署作业。
ci_forward_deployment_rollback_allowed布尔值启用或禁用允许回滚部署的作业重试。
ci_allow_fork_pipelines_to_run_in_parent_project布尔值启用或禁用来自分支的合并请求在父项目中运行流水线。(在极狐GitLab 15.3 中引入)
ci_id_token_sub_claim_components数组包含在 ID 令牌的 sub 声明中的字段。接受一个以 project_path 开头的数组。该数组还可以包括 ref_typerefref_protectedenvironment_protecteddeployment_tier。默认为 ["project_path", "ref_type", "ref"]。在极狐GitLab 17.10 中引入。environment_protecteddeployment_tier 的支持在极狐GitLab 18.7 中引入。
ci_separated_caches布尔值设置是否应根据分支保护状态分离缓存。
ci_restrict_pipeline_cancellation_role字符串设置取消流水线或作业所需的角色。可以是 developermaintainerno_one。在极狐GitLab 16.8 中引入。仅限专业版和旗舰版。
ci_pipeline_variables_minimum_override_role字符串可以指定哪个角色可以覆盖变量。可以是 ownermaintainerdeveloperno_one_allowed。在极狐GitLab 17.1 中引入。在极狐GitLab 17.1 到 17.7 中,必须启用 restrict_user_defined_variables
ci_push_repository_for_job_token_allowed布尔值启用或禁用使用作业令牌推送到项目仓库的能力。在极狐GitLab 17.2 中引入。
container_expiration_policy_attributes哈希更新此项目的镜像清理策略。接受:cadence(字符串)、keep_n(整数)、older_than(字符串)、name_regex(字符串)、name_regex_delete(字符串)、name_regex_keep(字符串)、enabled(布尔值)。
container_registry_enabled布尔值(已弃用) 启用项目的容器镜像仓库。请改用 container_registry_access_level
default_branch字符串默认分支名称。
description字符串简短的项目描述。
duo_remote_flows_enabled布尔值确定是否可以在项目中运行流。
duo_sast_fp_detection_enabled布尔值启用或禁用 SAST 误报检测。请参阅为项目开启 SAST 误报检测。
duo_sast_vr_workflow_enabled布尔值启用或禁用 SAST 漏洞修复工作流。请参阅为项目开启 SAST 漏洞修复工作流。
emails_disabled布尔值(已弃用) 禁用邮件通知。请改用 emails_enabled
emails_enabled布尔值启用邮件通知。
enforce_auth_checks_on_uploads布尔值对上传文件强制执行身份验证检查。
external_authorization_classification_label字符串项目的分类标签。仅限专业版和旗舰版。
group_runners_enabled布尔值为此项目启用群组 Runner。
import_url字符串仓库从中导入的 URL。
issues_enabled布尔值(已弃用) 启用此项目的议题。请改用 issues_access_level
issues_template字符串新议题的默认描述。格式为极狐GitLab Flavored Markdown。仅限专业版和旗舰版。
merge_requests_template字符串新合并请求的默认描述。格式为极狐GitLab Flavored Markdown。仅限专业版和旗舰版。
jobs_enabled布尔值(已弃用) 启用此项目的作业。请改用 builds_access_level
keep_latest_artifact布尔值禁用或启用为此项目保留最新产物。
lfs_enabled布尔值启用 LFS。
max_artifacts_size整数单个作业产物的最大文件大小(兆字节)。
merge_commit_template字符串用于在合并请求中创建合并提交消息的模板。
merge_method字符串设置项目的合并方法。可以是 merge(合并提交)、rebase_merge(具有半线性历史的合并提交)或 ff(快进合并)。
merge_pipelines_enabled布尔值启用或禁用合并结果流水线。
merge_requests_enabled布尔值(已弃用) 启用此项目的合并请求。请改用 merge_requests_access_level
mr_default_title_template字符串用于设置默认合并请求标题的模板。
merge_trains_enabled布尔值启用或禁用合并队列。
merge_trains_skip_train_allowed布尔值允许合并队列的合并请求在不等待流水线完成的情况下合并。
mirror_overwrites_diverged_branches布尔值拉取镜像覆盖已分化的分支。仅限专业版和旗舰版。
mirror_trigger_builds布尔值拉取镜像触发构建。仅限专业版和旗舰版。
mirror_user_id整数负责拉取镜像事件所有活动的用户。(仅管理员) 仅限专业版和旗舰版。
mirror布尔值在项目中启用拉取镜像。仅限专业版和旗舰版。
mr_default_target_self布尔值对于派生的项目,将合并请求的目标指向此项目。如果为 false,则目标为上游项目。
name字符串项目的名称。
only_allow_merge_if_all_discussions_are_resolved布尔值设置是否仅在所有讨论都解决后才能合并合并请求。
only_allow_merge_if_pipeline_succeeds布尔值设置是否仅在作业成功后才能合并合并请求。
only_mirror_protected_branches布尔值仅镜像受保护的分支。仅限专业版和旗舰版。
packages_enabled布尔值在极狐GitLab 17.10 中已弃用。启用或禁用软件包仓库功能。请改用 package_registry_access_level
package_registry_access_level字符串启用或禁用软件包仓库功能。
path字符串项目的自定义仓库名称。默认根据名称生成。
prevent_merge_without_jira_issue布尔值设置合并请求是否要求关联的议题。
markdown
1来自 Jira。仅旗舰版可用。| 2| `printing_merge_request_link_enabled` | boolean | 否 | 通过命令行推送时,显示创建/查看合并请求的链接。 | 3| `protect_merge_request_pipelines` | boolean | 否 | 启用或禁用[控制对受保护变量和 Runner 的访问](../ci/pipelines/merge_request_pipelines.md#control-access-to-protected-variables-and-runners)。 | 4| `public_builds` | boolean | 否 | _(已弃用)_ 如果为 `true`,非项目成员也可以查看作业。请改用 `public_jobs`。 | 5| `public_jobs` | boolean | 否 | 如果为 `true`,非项目成员也可以查看作业。 | 6| `remove_source_branch_after_merge` | boolean | 否 | 默认情况下,为所有新合并请求启用 `合并后删除源分支` 选项。 | 7| `repository_storage` | string | 否 | 代码仓所在的存储分片。 _(仅管理员可用)_ | 8| `request_access_enabled` | boolean | 否 | 允许用户请求成员访问权限。 | 9| `resolve_outdated_diff_discussions` | boolean | 否 | 自动解决因推送导致行变更的合并请求差异讨论。 | 10| `restrict_user_defined_variables` | boolean | 否 | _([已弃用](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/154510)于极狐GitLab 17.7,改用 `ci_pipeline_variables_minimum_override_role`)_ 仅允许具有维护者角色的用户在触发流水线时传递用户自定义变量。例如通过 UI、API 或触发令牌触发流水线时。 | 11| `service_desk_enabled` | boolean | 否 | 启用或禁用 Service Desk 功能。 | 12| `shared_runners_enabled` | boolean | 否 | 为此项目启用实例 Runner。 | 13| `show_default_award_emojis` | boolean | 否 | 显示默认表情回应。 | 14| `snippets_enabled` | boolean | 否 | _(已弃用)_ 为此项目启用代码片段。请改用 `snippets_access_level`。 | 15| `issue_branch_template` | string | 否 | 用于为[从议题创建的分支](../user/project/merge_requests/creating_merge_requests.md#from-an-issue)建议名称的模板。_([引入于](https://gitlab.com/gitlab-org/gitlab/-/issues/21243)极狐GitLab 15.6。)_ | 16| `spp_repository_pipeline_access` | boolean | 否 | 允许用户和令牌对此项目具有只读访问权限,以获取安全策略配置。对于使用此项目作为其安全策略源的项目强制执行安全策略是必需的。仅旗舰版可用。 | 17| `squash_commit_template` | string | 否 | 用于在合并请求中创建压缩提交信息的[模板](../user/project/merge_requests/commit_templates.md)。 | 18| `squash_option` | string | 否 | 可以是 `never``always``default_on``default_off` 之一。 | 19| `suggestion_commit_message` | string | 否 | 用于应用合并请求建议的提交信息。 | 20| `tag_list` | array | 否 | _([已弃用](https://gitlab.com/gitlab-org/gitlab/-/issues/328226)于极狐GitLab 14.0)_ 项目的标签列表;放置最终应分配给项目的标签数组。请改用 `topics`。 | 21| `topics` | array | 否 | 项目的主题列表。这将替换已添加到项目的任何现有主题。 | 22| `visibility` | string | 否 | 见[项目可见性级别](#project-visibility-level)。 | 23| `warn_about_potentially_unwanted_characters` | boolean | 否 | 对此项目中潜在有害字符的使用启用警告。 | 24| `wiki_enabled` | boolean | 否 | _(已弃用)_ 为此项目启用 Wiki。请改用 `wiki_access_level`。 | 25| `web_based_commit_signing_enabled` | boolean | 否 | 为从极狐GitLab UI 创建的提交启用基于 Web 的提交签名。仅在 JihuLab.com 上可用。 | 26 27例如,为一个 JihuLab.com 项目切换[实例 Runner 设置](../ci/runners/_index.md)28 29```shell 30curl --request PUT --header "PRIVATE-TOKEN: <your-token>" \ 31 --url "https://gitlab.com/api/v4/projects/<your-project-ID>" \ 32 --data "shared_runners_enabled=true" # 要关闭的话:"shared_runners_enabled=false"

设置单个项目功能的可见性级别, 请参见项目功能可见性级别

导入成员#

从另一个项目导入成员。

如果导入成员在目标项目中的角色是:

  • 维护者,则源项目中具有所有者角色的成员将以维护者角色导入。
  • 所有者,则源项目中具有所有者角色的成员将以所有者角色导入。
plaintext
POST /projects/:id/import_project_members/:project_id

支持的属性:

属性类型是否必需描述
idinteger 或 string接收成员的目标项目的 ID 或 URL 编码路径
project_idinteger 或 string要从中导入成员的源项目的 ID 或 URL 编码路径

示例请求:

shell
curl --request POST \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/5/import_project_members/32"

返回:

  • 成功时返回 200 OK
  • 如果目标或源项目不存在或请求者无法访问,则返回 404 Project Not Found
  • 如果项目成员导入未成功完成,则返回 422 Unprocessable Entity

示例响应:

  • 所有邮件均成功发送时(200 HTTP 状态码):

    json
    { "status": "success" }
  • 导入 1 个或多个成员时发生任何错误(200 HTTP 状态码):

    json
    1{ 2 "status": "error", 3 "message": { 4 "john_smith": "Some individual error message", 5 "jane_smith": "Some individual error message" 6 }, 7 "total_members_count": 3 8}
  • 出现系统错误时(404422 HTTP 状态码):

json
{ "message": "Import failed" }

归档项目#

版本历史

归档指定项目。

先决条件:

  • 您必须是管理员或在该项目中具有所有者角色。

此端点是幂等的,归档一个已归档的项目不会改变项目状态。

plaintext
POST /projects/:id/archive

支持的属性:

属性类型是否必需描述
idinteger 或 string项目的 ID 或 URL 编码路径

示例请求:

shell
curl --request POST \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/5/archive"

示例响应:

json
1{ 2 "id": 3, 3 "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 4 "description_html": "<p data-sourcepos=\"1:1-1:56\" dir=\"auto\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>", 5 "default_branch": "main", 6 "visibility": "private", 7 "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git", 8 "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", 9 "web_url": "http://example.com/diaspora/diaspora-project-site", 10 "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/main/README.md", 11 "tag_list": [ //已弃用,请改用 `topics` 12 "example", 13 "disapora project" 14 ], 15 "topics": [ 16 "example", 17 "disapora project" 18 ], 19 "owner": { 20 "id": 3, 21 "name": "Diaspora", 22 "created_at": "2013-09-30T13:46:02Z" 23 }, 24 "name": "Diaspora Project Site", 25 "name_with_namespace": "Diaspora / Diaspora Project Site", 26 "path": "diaspora-project-site", 27 "path_with_namespace": "diaspora/diaspora-project-site", 28 "repository_object_format": "sha1", 29 "issues_enabled": true, 30 "open_issues_count": 1, 31 "merge_requests_enabled": true, 32 "jobs_enabled": true, 33 "wiki_enabled": true, 34 "snippets_enabled": false, 35 "can_create_merge_request_in": true, 36 "resolve_outdated_diff_discussions": false, 37 "container_registry_enabled": false, // 已弃用,请改用 container_registry_access_level 38 "container_registry_access_level": "disabled", 39 "security_and_compliance_access_level": "disabled", 40 "created_at": "2013-09-30T13:46:02Z", 41 "updated_at": "2013-09-30T13:46:02Z", 42 "last_activity_at": "2013-09-30T13:46:02Z", 43 "creator_id": 3, 44 "namespace": { 45 "id": 3, 46 "name": "Diaspora", 47 "path": "diaspora", 48 "kind": "group", 49 "full_path": "diaspora" 50 }, 51 "import_status": "none", 52 "import_error": null, 53 "permissions": { 54 "project_access": { 55 "access_level": 10, 56 "notification_level": 3 57 }, 58 "group_access": { 59 "access_level": 50, 60 "notification_level": 3 61 } 62 }, 63 "archived": true, 64 "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png", 65 "license_url": "http://example.com/diaspora/diaspora-client/blob/main/LICENSE", 66 "license": { 67 "key": "lgpl-3.0", 68 "name": "GNU Lesser General Public License v3.0", 69 "nickname": "GNU LGPLv3", 70 "html_url": "http://choosealicense.com/licenses/lgpl-3.0/", 71 "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt" 72 }, 73 "shared_runners_enabled": true, 74 "group_runners_enabled": true, 75 "forks_count": 0, 76 "star_count": 0, 77 "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b", 78 "ci_default_git_depth": 50, 79 "ci_forward_deployment_enabled": true, 80 "ci_forward_deployment_rollback_allowed": true, 81 "ci_allow_fork_pipelines_to_run_in_parent_project": true, 82 "ci_id_token_sub_claim_components": ["project_path", "ref_type", "ref"], 83 "ci_separated_caches": true, 84 "ci_restrict_pipeline_cancellation_role": "developer", 85 "ci_pipeline_variables_minimum_override_role": "maintainer", 86 "ci_push_repository_for_job_token_allowed": false, 87 "ci_display_pipeline_variables": false, 88 "protect_merge_request_pipelines": true, 89 "public_jobs": true, 90 "shared_with_groups": [], 91 "only_allow_merge_if_pipeline_succeeds": false, 92 "allow_merge_on_skipped_pipeline": false, 93 "allow_pipeline_trigger_approve_deployment": false, 94 "restrict_user_defined_variables": false, 95 "only_allow_merge_if_all_discussions_are_resolved": false, 96 "remove_source_branch_after_merge": false, 97 "request_access_enabled": false, 98 "merge_method": "merge", 99 "squash_option": "default_on", 100 "autoclose_referenced_issues": true, 101 "enforce_auth_checks_on_uploads": true, 102 "suggestion_commit_message": null, 103 "merge_commit_template": null, 104 "mr_default_title_template": null, 105 "secret_push_protection_enabled": false, 106 "container_registry_image_prefix": "registry.example.com/diaspora/diaspora-project-site", 107 "_links": { 108 "self": "http://example.com/api/v4/projects", 109 "issues": "http://example.com/api/v4/projects/1/issues", 110 "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", 111 "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", 112 "labels": "http://example.com/api/v4/projects/1/labels", 113 "events": "http://example.com/api/v4/projects/1/events", 114 "members": "http://example.com/api/v4/projects/1/members", 115 "cluster_agents": "http://example.com/api/v4/projects/1/cluster_agents" 116 } 117}

取消归档项目#

版本历史

取消归档指定项目。

先决条件:

  • 您必须是管理员或在该项目中具有所有者角色。

此端点是幂等的,取消归档一个未归档的项目不会改变项目状态。

plaintext
POST /projects/:id/unarchive

支持的属性:

属性类型是否必需描述
idinteger 或 string项目的 ID 或 URL 编码路径

示例请求:

shell
curl --request POST \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/5/unarchive"

示例响应:

json
1{ 2 "id": 3, 3 "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 4 "description_html": "<p data-sourcepos=\"1:1-1:56\" dir=\"auto\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>", 5 "default_branch": "main", 6 "visibility": "private", 7 "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git", 8 "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", 9 "web_url": "http://example.com/diaspora/diaspora-project-site", 10 "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/main/README.md", 11 "tag_list": [ //已弃用,请改用 `topics` 12 "example", 13 "disapora project" 14 ], 15 "topics": [ 16 "example", 17 "disapora project" 18 ], 19 "owner": { 20 "id": 3, 21 "name": "Diaspora", 22 "created_at": "2013-09-30T13:46:02Z" 23 }, 24 "name": "Diaspora Project Site", 25 "name_with_namespace": "Diaspora / Diaspora Project Site", 26 "path": "diaspora-project-site", 27 "path_with_namespace": "diaspora/diaspora-project-site", 28 "repository_object_format": "sha1", 29 "issues_enabled": true, 30 "open_issues_count": 1, 31 "merge_requests_enabled": true, 32 "jobs_enabled": true, 33 "wiki_enabled": true, 34 "snippets_enabled": false, 35 "can_create_merge_request_in": true, 36 "resolve_outdated_diff_discussions": false, 37 "container_registry_enabled": false, // 已弃用,请改用 container_registry_access_level 38 "container_registry_access_level": "disabled", 39 "security_and_compliance_access_level": "disabled", 40 "created_at": "2013-09-30T13:46:02Z", 41 "updated_at": "2013-09-30T13:46:02Z", 42 "last_activity_at": "2013-09-30T13:46:02Z", 43 "creator_id": 3, 44 "namespace": { 45 "id": 3, 46 "name": "Diaspora", 47 "path": "diaspora", 48 "kind": "group", 49 "full_path": "diaspora" 50 }, 51 "import_status": "none", 52 "import_error": null, 53 "permissions": { 54 "project_access": { 55 "access_level": 10, 56 "notification_level": 3 57 }, 58 "group_access": { 59 "access_level": 50, 60 "notification_level": 3 61 } 62 }, 63 "archived": false, 64 "avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png", 65 "license_url": "http://example.com/diaspora/diaspora-client/blob/main/LICENSE", 66 "license": { 67 "key": "lgpl-3.0", 68 "name": "GNU Lesser General Public License v3.0", 69 "nickname": "GNU LGPLv3", 70 "html_url": "http://choosealicense.com/licenses/lgpl-3.0/", 71 "source_url": "http://www.gnu.org/licenses/lgpl-3.0.txt" 72 }, 73 "shared_runners_enabled": true, 74 "group_runners_enabled": true, 75 "forks_count": 0, 76 "star_count": 0, 77 "runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b", 78 "ci_default_git_depth": 50, 79 "ci_forward_deployment_enabled": true, 80 "ci_forward_deployment_rollback_allowed": true, 81 "ci_allow_fork_pipelines_to_run_in_parent_project": true, 82 "ci_id_token_sub_claim_components": ["project_path", "ref_type", "ref"], 83 "ci_separated_caches": true, 84 "ci_restrict_pipeline_cancellation_role": "developer", 85 "ci_pipeline_variables_minimum_override_role": "maintainer", 86 "ci_push_repository_for_job_token_allowed": false, 87 "ci_display_pipeline_variables": false, 88 "protect_merge_request_pipelines": true, 89 "public_jobs": true, 90 "shared_with_groups": [], 91 "only_allow_merge_if_pipeline_succeeds": false, 92 "allow_merge_on_skipped_pipeline": false, 93 "allow_pipeline_trigger_approve_deployment": false, 94 "restrict_user_defined_variables": false, 95 "only_allow_merge_if_all_discussions_are_resolved": false, 96 "remove_source_branch_after_merge": false, 97 "request_access_enabled": false, 98 "merge_method": "merge", 99 "squash_option": "default_on", 100 "autoclose_referenced_issues": true, 101 "enforce_auth_checks_on_uploads": true, 102 "suggestion_commit_message": null, 103 "merge_commit_template": null, 104 "mr_default_title_template": null, 105 "container_registry_image_prefix": "registry.example.com/diaspora/diaspora-project-site", 106 "secret_push_protection_enabled": false, 107 "_links": { 108 "self": "http://example.com/api/v4/projects", 109 "issues": "http://example.com/api/v4/projects/1/issues", 110 "merge_requests": "http://example.com/api/v4/projects/1/merge_requests", 111 "repo_branches": "http://example.com/api/v4/projects/1/repository_branches", 112 "labels": "http://example.com/api/v4/projects/1/labels", 113 "events": "http://example.com/api/v4/projects/1/events", 114 "members": "http://example.com/api/v4/projects/1/members", 115 "cluster_agents": "http://example.com/api/v4/projects/1/cluster_agents" 116 } 117}

删除项目#

版本历史
  • GA于极狐GitLab 16.0。仅专业版和旗舰版可用。
  • 迁移于极狐GitLab 18.0,从极狐GitLab 专业版到极狐GitLab 基础版。

先决条件:

  • 您必须是管理员或在该项目中具有所有者角色。

将项目标记为删除。项目将在保留期结束后删除:

  • 在 JihuLab.com 上,项目保留 30 天。
  • 在私有化部署实例上,保留期由实例设置控制。

此端点也可以立即删除先前标记为删除的项目。

在 JihuLab.com 上,项目删除后,其数据会保留 30 天,且永久删除不可用。 如果您确实需要立即删除 JihuLab.com 上的项目,可以提交一个 support ticket

plaintext
DELETE /projects/:id

支持的属性:

属性类型是否必需描述
idinteger 或 string项目的 ID 或 URL 编码路径
full_pathstring用于 permanently_remove 的项目完整路径。引入于极狐GitLab 15.11,仅专业版和旗舰版可用,并于 18.0 迁移至极狐GitLab 基础版。要查找项目路径,请使用获取单个项目中的 path_with_namespace
permanently_removeboolean/string如果项目已标记为删除,则立即删除该项目。引入于极狐GitLab 15.11,仅专业版和旗舰版可用,并于 18.0 迁移至极狐GitLab 基础版。在 JihuLab.com 上禁用。

恢复标记为删除的项目#

恢复已标记为删除的指定项目。

plaintext
POST /projects/:id/restore

支持的属性:

属性类型是否必需描述
idinteger 或 string项目的 ID 或 URL 编码路径

将项目转移至新命名空间#

版本历史

将项目转移到新的命名空间。

有关移交项目的先决条件信息,请参阅 将项目转移到另一个命名空间

plaintext
PUT /projects/:id/transfer

支持的属性:

属性类型是否必需描述
idinteger 或 string项目的 ID 或 URL 编码路径
namespaceinteger 或 string项目要转移到的命名空间的 ID 或路径。

示例请求:

shell
curl --request PUT \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/5/transfer?namespace=14"

示例响应:

text
1```json 2 { 3 "id": 7, 4 "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 5 "description_html": "<p data-sourcepos=\"1:1-1:56\" dir=\"auto\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>", 6 "name": "hello-world", 7 "name_with_namespace": "cute-cats / hello-world", 8 "path": "hello-world", 9 "path_with_namespace": "cute-cats/hello-world", 10 "created_at": "2020-10-15T16:25:22.415Z", 11 "updated_at": "2020-10-15T16:25:22.415Z", 12 "default_branch": "main", 13 "tag_list": [], //已弃用,请使用 `topics` 代替 14 "topics": [], 15 "ssh_url_to_repo": "git@gitlab.example.com:cute-cats/hello-world.git", 16 "http_url_to_repo": "https://gitlab.example.com/cute-cats/hello-world.git", 17 "web_url": "https://gitlab.example.com/cute-cats/hello-world", 18 "readme_url": "https://gitlab.example.com/cute-cats/hello-world/-/blob/main/README.md", 19 "avatar_url": null, 20 "forks_count": 0, 21 "star_count": 0, 22 "last_activity_at": "2020-10-15T16:25:22.415Z", 23 "namespace": { 24 "id": 18, 25 "name": "cute-cats", 26 "path": "cute-cats", 27 "kind": "group", 28 "full_path": "cute-cats", 29 "parent_id": null, 30 "avatar_url": null, 31 "web_url": "https://gitlab.example.com/groups/cute-cats" 32 }, 33 "container_registry_image_prefix": "registry.example.com/cute-cats/hello-world", 34 "_links": { 35 "self": "https://gitlab.example.com/api/v4/projects/7", 36 "issues": "https://gitlab.example.com/api/v4/projects/7/issues", 37 "merge_requests": "https://gitlab.example.com/api/v4/projects/7/merge_requests", 38 "repo_branches": "https://gitlab.example.com/api/v4/projects/7/repository/branches", 39 "labels": "https://gitlab.example.com/api/v4/projects/7/labels", 40 "events": "https://gitlab.example.com/api/v4/projects/7/events", 41 "members": "https://gitlab.example.com/api/v4/projects/7/members" 42 }, 43 "packages_enabled": true, // 已弃用,请使用 package_registry_access_level 代替 44 "package_registry_access_level": "enabled", 45 "empty_repo": false, 46 "archived": false, 47 "visibility": "private", 48 "resolve_outdated_diff_discussions": false, 49 "container_registry_enabled": true, // 已弃用,请使用 container_registry_access_level 代替 50 "container_registry_access_level": "enabled", 51 "container_expiration_policy": { 52 "cadence": "7d", 53 "enabled": false, 54 "keep_n": null, 55 "older_than": null, 56 "name_regex": null, 57 "name_regex_keep": null, 58 "next_run_at": "2020-10-22T16:25:22.746Z" 59 }, 60 "issues_enabled": true, 61 "merge_requests_enabled": true, 62 "wiki_enabled": true, 63 "jobs_enabled": true, 64 "snippets_enabled": true, 65 "service_desk_enabled": false, 66 "service_desk_address": null, 67 "can_create_merge_request_in": true, 68 "issues_access_level": "enabled", 69 "repository_access_level": "enabled", 70 "merge_requests_access_level": "enabled", 71 "forking_access_level": "enabled", 72 "analytics_access_level": "enabled", 73 "wiki_access_level": "enabled", 74 "builds_access_level": "enabled", 75 "snippets_access_level": "enabled", 76 "pages_access_level": "enabled", 77 "security_and_compliance_access_level": "enabled", 78 "emails_disabled": null, 79 "emails_enabled": null, 80 "shared_runners_enabled": true, 81 "group_runners_enabled": true, 82 "lfs_enabled": true, 83 "creator_id": 2, 84 "import_status": "none", 85 "open_issues_count": 0, 86 "ci_default_git_depth": 50, 87 "public_jobs": true, 88 "build_timeout": 3600, 89 "auto_cancel_pending_pipelines": "enabled", 90 "ci_config_path": null, 91 "shared_with_groups": [], 92 "only_allow_merge_if_pipeline_succeeds": false, 93 "allow_merge_on_skipped_pipeline": null, 94 "allow_pipeline_trigger_approve_deployment": false, 95 "restrict_user_defined_variables": false, 96 "request_access_enabled": true, 97 "only_allow_merge_if_all_discussions_are_resolved": false, 98 "remove_source_branch_after_merge": true, 99 "printing_merge_request_link_enabled": true, 100 "merge_method": "merge", 101 "squash_option": "default_on", 102 "suggestion_commit_message": null, 103 "merge_commit_template": null, 104 "mr_default_title_template": null, 105 "auto_devops_enabled": true, 106 "auto_devops_deploy_strategy": "continuous", 107 "autoclose_referenced_issues": true, 108 "approvals_before_merge": 0, // 已弃用。请改用合并请求审批 API。 109 "mirror": false, 110 "compliance_frameworks": [], 111 "warn_about_potentially_unwanted_characters": true, 112 "secret_push_protection_enabled": false 113}

列出可用于项目转移的群组#

获取用户可以将项目转移到的一组群组。

plaintext
GET /projects/:id/transfer_locations

支持的属性:

属性类型必需描述
id整数或字符串项目 ID 或 URL 编码的项目路径
search字符串要搜索的群组名称。

请求示例:

shell
curl --url "https://gitlab.example.com/api/v4/projects/1/transfer_locations"

响应示例:

json
1[ 2 { 3 "id": 27, 4 "web_url": "https://gitlab.example.com/groups/gitlab", 5 "name": "GitLab", 6 "avatar_url": null, 7 "full_name": "GitLab", 8 "full_path": "GitLab" 9 }, 10 { 11 "id": 31, 12 "web_url": "https://gitlab.example.com/groups/foobar", 13 "name": "FooBar", 14 "avatar_url": null, 15 "full_name": "FooBar", 16 "full_path": "FooBar" 17 } 18]

上传项目头像#

向指定项目上传头像。

plaintext
PUT /projects/:id

先决条件:

  • 你必须拥有项目的 维护者所有者 角色。
  • 你的文件必须小于等于 200 KB。理想的图片尺寸为 192 x 192 像素。
  • 图片必须为以下文件类型之一:
    • .bmp
    • .gif
    • .ico
    • .jpeg
    • .png
    • .tiff

支持的属性:

属性类型必需描述
avatar字符串要上传的文件。
id整数或字符串项目 ID 或 URL 编码的项目路径

要从文件系统上传头像,使用 --form 参数。这会使 cURL 使用头部信息 Content-Type: multipart/form-data 发送数据。avatar= 参数必须指向文件系统上的图片文件,并且前面带有 @

请求示例:

shell
curl --request PUT \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/5" \ --form "avatar=@dk.png"

响应示例:

json
{ "avatar_url": "https://gitlab.example.com/uploads/-/system/project/avatar/2/dk.png" }

下载项目头像#

版本历史
  • 引入于 极狐GitLab 16.9。

下载项目头像。如果项目是公开可访问的,你可以在无需认证的情况下访问此端点。

plaintext
GET /projects/:id/avatar

支持的属性:

属性类型必需描述
id整数或字符串项目 ID 或 URL 编码的路径

请求示例:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/4/avatar"

删除项目头像#

要删除项目头像,请将 avatar 属性设置为空值。

请求示例:

shell
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" \ --data "avatar=" "https://gitlab.example.com/api/v4/projects/5"

共享项目#

与群组共享一个项目。

更多信息,请参见邀请群组加入项目

与群组共享项目#

与指定群组共享特定项目。

plaintext
POST /projects/:id/share

支持的属性:

属性类型必需描述
group_access整数授予群组的访问级别。可能的取值:5(最低访问),10(访客),15(计划者),20(报告者),25(安全经理),30(开发者),40(维护者)或 50(所有者)。
group_id整数要共享的群组 ID。
id整数或字符串项目 ID 或 URL 编码的项目路径
expires_at字符串共享过期日期,采用 ISO 8601 格式。例如 2016-09-26

取消与指定群组的项目共享。成功时返回 204 且无内容。

plaintext
DELETE /projects/:id/share/:group_id

支持的属性:

属性类型必需描述
group_id整数群组 ID。
id整数或字符串项目 ID 或 URL 编码的项目路径

请求示例:

shell
curl --request DELETE \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/5/share/17"

启动项目的内务管理任务#

启动项目的内务管理任务

plaintext
POST /projects/:id/housekeeping

支持的属性:

属性类型必需描述
id整数或字符串项目 ID 或 URL 编码的项目路径
task字符串prune 触发手动清理不可达对象,或 eager 触发积极清理。

实时安全扫描#

Tier: 旗舰版

Offering: JihuLab.com

Status: 实验

版本历史
  • 引入于 极狐GitLab 17.6。此功能为实验

实时返回单个文件的 SAST 扫描结果。

plaintext
POST /projects/:id/security_scans/sast/scan

支持的属性:

属性类型必需描述
id整数或字符串项目 ID 或 URL 编码的项目路径

请求示例:

shell
1curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ 2 --header "Content-Type: application/json" \ 3 --data '{ 4 "file_path":"src/main.c", 5 "content":"#include<string.h>\nint main(int argc, char **argv) {\n char buff[128];\n strcpy(buff, argv[1]);\n return 0;\n}\n" 6 }' \ 7 --url "https://gitlab.example.com/api/v4/projects/:id/security_scans/sast/scan"

响应示例:

json
1{ 2 "vulnerabilities": [ 3 { 4 "name": "不安全的字符串处理函数 (strcpy)", 5 "description": "`strcpy` 系列函数无法在复制到目标缓冲区之前限制或检查缓冲区大小。这可能导致缓冲区溢出。请考虑使用更安全的替代方案,如 `strncpy`,并为目标缓冲区提供正确的限制,同时确保字符串以 null 结尾。\n\n更多信息请参见:https://linux.die.net/man/3/strncpy\n\n如果是为 C 运行时库 (CRT) 开发,建议使用这些函数更安全的版本,请参见:\nhttps://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l?view=msvc-170\n", 6 "severity": "高", 7 "location": { 8 "file": "src/main.c", 9 "start_line": 5, 10 "end_line": 5, 11 "start_column": 3, 12 "end_column": 23 13 } 14 } 15 ] 16}

下载 Git 仓库快照#

此端点只能由管理员用户访问。

下载项目(或 wiki,若请求)的 Git 仓库快照。此 快照始终为未压缩的 tar 格式。

如果仓库损坏到 git clone 无法正常工作的程度,快照可能允许检索部分数据。

plaintext
GET /projects/:id/snapshot

支持的属性:

属性类型必需描述
id整数或字符串项目 ID 或 URL 编码的项目路径
wiki布尔值是否下载 wiki 而不是项目仓库。

获取仓库存储路径#

获取指定项目的仓库存储路径。如果你正在使用 Gitaly Cluster (Praefect),请参见 Praefect 生成的副本路径

仅管理员可用。

plaintext
GET /projects/:id/storage

支持的属性:

属性类型必需描述
id整数或字符串项目 ID 或 URL 编码的项目路径
json
1[ 2 { 3 "project_id": 1, 4 "disk_path": "@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b", 5 "created_at": "2012-10-12T17:04:47Z", 6 "repository_storage": "default" 7 } 8]

密钥推送保护状态#

Tier: 旗舰版

版本历史
  • 引入于 极狐GitLab 17.3。
  • 在 极狐GitLab 17.11 中从 setPreReceiveSecretDetection 重命名。

如果你拥有安全经理、开发者、维护者或所有者角色,以下请求也可能返回 secret_push_protection_enabled 值。 其中一些请求对角色有更严格的要求。请参考前面提到的端点以获取澄清。 使用此信息判断是否为项目启用了密钥推送保护。 要修改 secret_push_protection_enabled 值,请使用项目安全设置 API

  • GET /projects
  • GET /projects/:id
  • GET /users/:user_id/projects
  • GET /users/:user_id/contributed_projects
  • PUT /projects/:project_id/transfer?namespace=:namespace_id
  • PUT /projects/:id
  • POST /projects
  • POST /projects/user/:user_id
  • POST /projects/:id/archive
  • POST /projects/:id/unarchive

响应示例:

json
1{ 2 "id": 1, 3 "project_id": 3, 4 "secret_push_protection_enabled": true, 5 ... 6}

故障排除#

响应中意外的 restrict_user_defined_variables 值#

如果你为 restrict_user_defined_variablesci_pipeline_variables_minimum_override_role 设置了冲突的值, 响应值可能与你的预期不符,因为 pipeline_variables_minimum_override_role 设置具有更高的优先级。

例如,如果你:

  • restrict_user_defined_variables 设置为 true,同时将 ci_pipeline_variables_minimum_override_role 设置为 developer, 响应将返回 restrict_user_defined_variables: false。将 ci_pipeline_variables_minimum_override_role 设置为 developer 会优先执行,变量不受限制。
  • restrict_user_defined_variables 设置为 false,同时将 ci_pipeline_variables_minimum_override_role 设置为 maintainer, 响应将返回 restrict_user_defined_variables: true,因为将 ci_pipeline_variables_minimum_override_role 设置为 maintainer 会优先执行,变量受到限制。