Help us learn about your current experience with the documentation. Take the survey.
Maven API
- 版本:Free, Premium, Ultimate
- 产品:GitLab.com, GitLab Self-Managed, GitLab Dedicated
这是 Maven Packages 的 API 文档。
此 API 供 Maven package manager client 使用, 通常不建议手动调用。
有关如何从 GitLab 包仓库上传和安装 Maven 包的说明,请参阅 Maven package registry documentation。
这些终端节点不遵循标准的 API 认证方法。 有关支持的 headers 和 token 类型的详细信息,请参阅 Maven package registry documentation。 未来可能会移除未在文档中说明的认证方法。
在实例级别下载包文件
下载 Maven 包文件:
GET packages/maven/*path/:file_name| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
path |
string | 是 | Maven 包的路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的所有 . 替换为 /。 |
file_name |
string | 是 | Maven 包文件的名称。 |
curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.jar"要将输出写入文件:
curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.jar" >> mypkg-1.0-SNAPSHOT.jar这会将下载的文件写入当前目录下的 mypkg-1.0-SNAPSHOT.jar 文件中。
在组级别下载包文件
下载 Maven 包文件:
GET groups/:id/-/packages/maven/*path/:file_name| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
path |
string | 是 | Maven 包的路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的所有 . 替换为 /。 |
file_name |
string | 是 | Maven 包文件的名称。 |
curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/groups/1/-/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.jar"要将输出写入文件:
curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/groups/1/-/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.jar" >> mypkg-1.0-SNAPSHOT.jar这会将下载的文件写入当前目录下的 mypkg-1.0-SNAPSHOT.jar 文件中。
在项目级别下载包文件
下载 Maven 包文件:
GET projects/:id/packages/maven/*path/:file_name| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
path |
string | 是 | Maven 包的路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的所有 . 替换为 /。 |
file_name |
string | 是 | Maven 包文件的名称。 |
curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.jar"要将输出写入文件:
curl --header "Private-Token: <personal_access_token>" "https://gitlab.example.com/api/v4/projects/1/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.jar" >> mypkg-1.0-SNAPSHOT.jar这会将下载的文件写入当前目录下的 mypkg-1.0-SNAPSHOT.jar 文件中。
上传包文件
上传 Maven 包文件:
PUT projects/:id/packages/maven/*path/:file_name| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
path |
string | 是 | Maven 包的路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的所有 . 替换为 /。 |
file_name |
string | 是 | Maven 包文件的名称。 |
curl --request PUT \
--upload-file path/to/mypkg-1.0-SNAPSHOT.pom \
--header "Private-Token: <personal_access_token>" \
"https://gitlab.example.com/api/v4/projects/1/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.pom"