{{< details >}}

  • Tier: 基础版, 专业版, 旗舰版
  • Offering: JihuLab.com, 私有化部署

{{< /details >}}

这是 Maven 软件包 的 API 文档。

{{< alert type=”warning” >}}

此 API 由 Maven 软件包管理器客户端 使用,通常不适合手动使用。

{{< /alert >}}

有关如何从极狐GitLab 软件包注册表上传和安装 Maven 软件包的说明,请参阅 Maven 软件包注册表文档

{{< alert type=”note” >}}

这些端点不符合标准 API 认证方法。有关支持的标头和令牌类型的详细信息,请参阅 Maven 软件包注册表文档。未记录的认证方法可能会在未来被移除。

{{< /alert >}}

下载实例级别的软件包文件

下载 Maven 软件包文件:

GET packages/maven/*path/:file_name
属性 类型 必需 描述
path string yes Maven 软件包路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的任何 . 替换为 /
file_name string yes 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 yes Maven 软件包路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的任何 . 替换为 /
file_name string yes 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 yes Maven 软件包路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的任何 . 替换为 /
file_name string yes 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 yes Maven 软件包路径,格式为 <groupId>/<artifactId>/<version>。将 groupId 中的任何 . 替换为 /
file_name string yes 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"