Working with the Apache Maven registry

パッケージを作成する

Before publishing and installing Maven packages from the registry, you will first need to create a package which represents the Maven package in Bitbucket.

  1. 上部のナビゲーション バーで [作成] を選択し、[作成] ドロップダウン メニューを開きます。

  2. [作成] ドロップダウンから [パッケージ] を選択します。

  3. Select Maven package type from the Package type dropdown.

  4. Provide a group ID for the package in the Group ID field.

  5. Provide an artifact ID for the package in the Artifact ID field.

  6. Select the Repository to link to dropdown and select the repository that you want to link the package to. Note: The package inherits the permissions of the repository which then grants users the same permissions to access the package.

  7. [送信] を選択し、パッケージを作成します。

Package manager support

We support the mvn and gradle package manager clients.

認証

Publishing and installing Maven packages from the Bitbucket package registry requires you to authenticate your client with an Atlassian API token.

To authenticate to the Bitbucket package registry within Bitbucket Pipelines, you can use BITBUCKET_PACKAGES_USERNAME and BITBUCKET_PACKAGES_TOKEN environment variables available to each step in your Bitbucket Pipeline runs. Learn more about using variables to integrate with Pipelines.

Maven

Add the following to your settings.xml file. Create a new file if one doesn’t exist.

<settings> <servers> <server> <id>bitbucket-packages</id> <username>{atlassian-email}</username> <password>{atlassian-api-token}</password> </server> </servers> </settings>

Gradle

Add the following to the gradle.properties file in your Gradle user home directory. Create a new file if one doesn’t exist.

atlassianEmail=<atlassian-email> atlassianApiToken=<atlassian-api-token>

Groovy DSL

Add the following to your build.gradle file.

publishing { repositories { maven { name = "Bitbucket Packages" // We will elaborate on this in the publishing section url = uri("https://maven.apkg.io/<workspace-slug>") credentials { username = atlassianEmail password = atlassianApiToken } } } }

Kotlin DSL

Add the following to your build.gradle.kts file.

publishing { repositories { maven { name = "Bitbucket Packages" // We will elaborate on this in the publishing section url = uri("https://maven.apkg.io/<workspace-slug>") credentials { username = findProperty("atlassianEmail") as String? password = findProperty("atlassianApiToken") as String? } } } }

Publishing a Maven package to the registry

Maven

  1. Edit the distributionManagement element in the pom.xml file in your package directory, replacing workspace-slug in the example provided below with the Bitbucket workspace slug where the package is published.

    <distributionManagement> <repository> <id>bitbucket-packages</id> <name>Bitbucket Packages</name> <url>https://maven.apkg.io/{workspace-slug}</url> </repository> </distributionManagement>
  2. Publish the package.

    mvn deploy

Gradle

  1. Specify the url attribute in either your build.gradle or build.gradle.kts file, replacing workspace-slug in the example below with the Bitbucket workspace slug where the package is published.

    publishing { repositories { maven { name = "Bitbucket Packages" url = uri("https://maven.apkg.io/<workspace-slug>") credentials { username = atlassianEmail password = atlassianApiToken } } } }
  2. Publish the package.

    gradle publish

Installing a Maven package

Maven

  1. Add the repositories element in the pom.xml file in your package directory, replacing workspace-slug in the example below with the Bitbucket workspace slug where the package is installed.

    <repositories> <repository> <id>bitbucket-packages</id> <name>Bitbucket Packages</name> <url>https://maven.apkg.io/{workspace-slug}</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories>
  2. Add the package to the dependencies element of your pom.xml file.

    <dependencies> <dependency> <groupId>{group-id}</groupId> <artifactId>{artifact-id}</artifactId> <version>{version}</version> </dependency> </dependencies>
  3. Install the dependencies.

    mvn install

Gradle

Groovy DSL

  1. Specify the url attribute in your build.gradle, replacing workspace-slug in the example below with the Bitbucket workspace slug where the package is installed.

    repositories { maven { name = "BitbucketPackages" url = uri("https://maven.apkg.io/<workspace-slug>") credentials { username = atlassianEmail password = atlassianApiToken } } }
  2. Add the package to the dependencies block of your build.gradle file.

    dependencies { implementation '<group-id>:<artifact-id>:<version>' }
  3. Install the dependencies.

    gradle build

Kotlin DSL

  1. Specify the url attribute in your build.gradle.kts, replacing workspace-slug in the example below with the Bitbucket workspace slug where the package is installed.

    repositories { maven { name = "Bitbucket Packages" url = uri("https://maven.apkg.io/<workspace-slug>") credentials { username = findProperty("atlassianEmail") as String? password = findProperty("atlassianApiToken") as String? } } }
  2. Add the package to the dependencies block of your build.gradle.kts file.

    dependencies { implementation('<group-id>:<artifact-id>:<version>') }
  3. Install the dependencies.

    gradle build

Viewing Maven packages

The Maven packages within your registry can be viewed from the workspace, project, and repository. You will see a list of Maven packages along with other package types that have been published to your workspace, project, or repository.

  • To view the Maven packages within the workspace, select Packages on the left sidebar. This opens the Packages page which lists all the Maven packages within the workspace.

  • To view the Maven packages within a project, select Packages on the left sidebar from within the project in which you want to see a list of Maven packages.

  • To view the Maven packages within a repository, select Packages on the left sidebar within the repository in which you want to see a list of Maven packages.

Viewing Maven package details

  • Display a package: Select the Maven package name from the list of packages to see details about that Maven package.

  • Display a base version: A base version is either the release or snapshot version. Select the base version to see details specific to that base version and the list of versions associated with it if it is a snapshot version.

Delete a Maven package and version

In Bitbucket Cloud, you can delete either a Maven package version or the base version, or you can delete the entire Maven package, including all of its versions.

Delete a Maven package version

Only users with repository write or admin permissions can delete a Maven package version.

Deleting a Maven package version permanently removes it from Bitbucket Cloud. Once it is deleted, the version can no longer be installed and will free up the storage soon after. To delete a Maven package version:

  1. From the packages list view under the workspace, project, or repository, select the Maven package containing the version you want to delete.

  2. From the base versions list view, select the base version containing the version you want to delete.

  3. From the versions list view, select More actions (…).

  4. Select Delete version, then select Delete.

Delete a Maven package base version

Only users with repository write or admin permissions can delete a Maven package base version.

Deleting a Maven package base version permanently removes it and all of its versions from Bitbucket Cloud. Once it is deleted, the version can no longer be installed and will free up the storage soon after. To delete a Maven package base version:

  1. From the packages list view under the workspace, project or repository, select the Maven package containing the version you want to delete.

  2. From the base versions list view, select More actions (…).

  3. Select Delete base version, then select Delete.

Delete a Maven package

Only users with repository admin permission can delete a Maven package.

Deleting a Maven package permanently removes it and all of its versions from Bitbucket Cloud. Once deleted, the Maven package and all its versions can no longer be installed and will free up the storage soon after. To delete a Maven package:

  1. From the packages list view under the workspace, project, or repository, select the Maven package you want to delete.

  2. From the packages list view, select More actions (…).

  3. Select Delete package, then select Delete.

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。