Maven API
- Tier: 基础版, 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
这是 Maven 软件包 的 API 文档。
此 API 由 [Maven 软件包管理器客户端](https://maven.apache.org/) 使用,通常不适合手动使用。
有关如何从极狐GitLab 软件包注册表上传和安装 Maven 软件包的说明,请参阅 Maven 软件包注册表文档。
这些端点不符合标准 API 认证方法。有关支持的标头和令牌类型的详细信息,请参阅 [Maven 软件包注册表文档](../../user/packages/maven_repository/_index.md)。未记录的认证方法可能会在未来被移除。
下载实例级别的软件包文件
下载 Maven 软件包文件:
plaintextGET packages/maven/*path/:file_name
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| path | string | yes | Maven 软件包路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的任何 . 替换为 /。 |
| file_name | string | yes | Maven 软件包文件的名称。 |
shellcurl --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"
将输出写入文件:
shellcurl --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 软件包文件:
plaintextGET groups/:id/-/packages/maven/*path/:file_name
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| path | string | yes | Maven 软件包路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的任何 . 替换为 /。 |
| file_name | string | yes | Maven 软件包文件的名称。 |
shellcurl --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"
将输出写入文件:
shellcurl --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 软件包文件:
plaintextGET projects/:id/packages/maven/*path/:file_name
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| path | string | yes | Maven 软件包路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的任何 . 替换为 /。 |
| file_name | string | yes | Maven 软件包文件的名称。 |
shellcurl --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"
将输出写入文件:
shellcurl --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 软件包文件:
plaintextPUT projects/:id/packages/maven/*path/:file_name
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| path | string | yes | Maven 软件包路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的任何 . 替换为 /。 |
| file_name | string | yes | Maven 软件包文件的名称。 |
shellcurl --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"