Back to Gitlabhq

Maven API

doc/api/packages/maven.md

18.11.24.3 KB
Original Source

{{< details >}}

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

{{< /details >}}

Use this API to interact with the Maven package manager client.

[!warning] This API is used by the Maven package manager client and is generally not meant for manual consumption.

These endpoints do not adhere to the standard API authentication methods. See Maven package registry documentation for details on which headers and token types are supported. Undocumented authentication methods might be removed in the future.

Download a package file for an instance

Downloads a specified Maven package file for the instance.

plaintext
GET packages/maven/*path/:file_name
AttributeTypeRequiredDescription
pathstringyesThe Maven package path, in the format <groupId>/<artifactId>/<version>. Replace any . in the groupId with /.
file_namestringyesThe name of the Maven package file.
shell
curl --header "PRIVATE-TOKEN: <personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.jar"

To write the output to file:

shell
curl --header "PRIVATE-TOKEN: <personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.jar" >> mypkg-1.0-SNAPSHOT.jar

This writes the downloaded file to mypkg-1.0-SNAPSHOT.jar in the current directory.

Download a package file for a group-level

Downloads a specified Maven package file for a group.

plaintext
GET groups/:id/-/packages/maven/*path/:file_name
AttributeTypeRequiredDescription
pathstringyesThe Maven package path, in the format <groupId>/<artifactId>/<version>. Replace any . in the groupId with /.
file_namestringyesThe name of the Maven package file.
shell
curl --header "PRIVATE-TOKEN: <personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/1/-/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.jar"

To write the output to file:

shell
curl --header "PRIVATE-TOKEN: <personal_access_token>" \
  --url "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

This writes the downloaded file to mypkg-1.0-SNAPSHOT.jar in the current directory.

Download a package file for a project

Downloads a specified Maven package file for a project.

plaintext
GET projects/:id/packages/maven/*path/:file_name
AttributeTypeRequiredDescription
pathstringyesThe Maven package path, in the format <groupId>/<artifactId>/<version>. Replace any . in the groupId with /.
file_namestringyesThe name of the Maven package file.
shell
curl --header "PRIVATE-TOKEN: <personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.jar"

To write the output to file:

shell
curl --header "PRIVATE-TOKEN: <personal_access_token>" \
  --url "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

This writes the downloaded file to mypkg-1.0-SNAPSHOT.jar in the current directory.

Upload a package file

Uploads a specified Maven package file for a project.

plaintext
PUT projects/:id/packages/maven/*path/:file_name
AttributeTypeRequiredDescription
pathstringyesThe Maven package path, in the format <groupId>/<artifactId>/<version>. Replace any . in the groupId with /.
file_namestringyesThe name of the Maven package file.
shell
curl --request PUT \
     --upload-file path/to/mypkg-1.0-SNAPSHOT.pom \
     --header "PRIVATE-TOKEN: <personal_access_token>" \
     --url "https://gitlab.example.com/api/v4/projects/1/packages/maven/foo/bar/mypkg/1.0-SNAPSHOT/mypkg-1.0-SNAPSHOT.pom"