Maven Repository Administration

You can configure the Maven repository to limit the number of snapshots and overwrite an artifact if another with same groupID, artifactID, and version value is uploaded.

Configure Auto-Cleanup for Snapshots

By default, when you upload a new snapshot of an artifact to the project’s Maven repository manually or through job builds, the repository retains the old versions of the snapshots. The project owner can configure auto-cleanup so the project will automatically remove old versions when a new version is uploaded:

  1. In the left navigator, click Project Administration Project Administration.
  2. Click Repositories.
  3. In Maven Repository, if necessary, expand Configure auto cleanup for Snapshot versions.
  4. Select the Purge check box.
  5. In Default Max Snapshots, enter a number between 2 and 500 to specify the maximum versions to retain. By default, 2 versions of the snapshots are retained.

All changes are saved automatically when you navigate to another field. After the rule is enabled, any new upload of a snapshot will remove its older versions if the number of snapshots exceed the value in Default Max Snapshots.

You can also add exceptions to the auto-cleanup and Default Max Snapshots rule and customize the snapshot counts. The project Maven repository retains the snapshot counts of group IDs and artifacts defined in the Customized Snapshot Counts section and uses the default value specified in Default Max Snapshots for artifacts that don’t have exceptions defined.

To define exceptions and customize snapshot count:

  1. In the Maven Repository section of the Repositories page, select the Purge check box and configure the default auto-cleanup as described above.

  2. To add an artifact group or an artifact name as an exception, click + Add in the Customized Snapshot Counts section.

  3. Specify these details:

    • Group Id (Required): Enter or select the Group ID of the artifact. You can select the ID from the list or start typing and then select the ID from the list of suggestions. The auto-suggest list is based on the Maven indexes. If no index data is available, the auto-suggest list doesn’t display.

    • Artifact Id (Optional): Enter or select the Artifact ID of the artifact. You can select the ID from the list or start typing and then select the ID from the list of suggestions. The auto-suggest list is based on the Maven indexes. If no index data is available, the auto-suggest list doesn’t display.

    • Snapshot Count: Select the number of snapshots to retain in the project Maven repository. By default, 2 snapshots are retained.

To remove an exception, on the right, click Remove the Remove icon. For a long list of exceptions, you can use the Filter field and enter a search coordinates criteria to see the exceptions matching the criteria. If you enter an exception with duplicate coordinates, an error message Unable to save. Coordinates already exists. Enter unique coordinates appears.

Configure Overwriting for Release Artifacts

By default, if a user or build tries to upload a Maven release artifact that has the same groupID, artifactID, and version values as an existing artifact, the upload will fail. The project owner can configure the Maven repository to allow uploaded duplicate release artifacts to overwrite existing ones.

Here's how the project owner can configure overwriting:

  1. In the left navigator, click Project Administration Project Administration.
  2. Click Repositories.
  3. In Maven Repository, if necessary, expand Configure Overwrite Property for Release Artifacts.
  4. Select the Allow check box.