How to configure your repository to allow or prevent overwriting deployed versions

By default, once an artifact version has been deployed, users are not allowed to redeploy the same version over top of the existing one. Instead of redeploying a version, it is recommended that you always create a new version.

Why is redeployment usually bad?

Most of the time, you don’t want to allow redeploying versions, as this can lead to confusing situations and unreproducible builds. Under Maven’s normal behaviour, once it has downloaded a released version (i.e. not a SNAPSHOT), it will never look for updates to that version. This means that if you deployed a version, some people downloaded it, and then you redeployed that version, then there would be two different artifacts used as the same version. This can lead to all sorts of trouble, so it is recommended that you don’t allow this.

What happens if I try to redeploy an existing version?

The exact output will vary depending on your tool, but it should include “Redeploys to this repository are not allowed.”

ReasonPhrase: Forbidden - Redeploys to this repository are not allowed.

Maven

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project simple-mvn: Failed to deploy artifacts: Could not transfer artifact co.deps.test-projects:simple-mvn:jar:1.0.0 from/to deps-test-releases (https://repo.deps.co/acme/releases): Access denied to: https://repo.deps.co/acme/releases/co/deps/test-projects/simple-mvn/1.0.0/simple-mvn-1.0.0.jar, ReasonPhrase: Forbidden - Redeploys to this repository are not allowed. -> [Help 1]

Leiningen

Failed to deploy artifacts: Could not transfer artifact simple-lein:simple.lein:jar:0.1.0 from/to releases (https://repo.deps.co/acme/releases): Access denied to: https://repo.deps.co/acme/releases/simple-lein/simple.lein/0.1.0/simple.lein-0.1.0.jar, ReasonPhrase: Forbidden - Redeploys to this repository are not allowed.

Gradle

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':uploadArchives'.

> Could not publish configuration 'archives'

   > Failed to deploy artifacts: Could not transfer artifact gradle-group:gradle.artifact:jar:1.0Maven from/to remote (https://repo.deps.co/acme/releases): Access denied to: https://repo.deps.co/acme/releases/gradle-group/gradle.artifact/1.0Maven/gradle.artifact-1.0Maven.jar, ReasonPhrase: Forbidden - Redeploys to this repository are not allowed.

How do I configure redeployment settings?

By default redeploys are disabled. However, if you have a special situation, and want to change these settings, you can edit the Repository and check “Allow redeploying the same version?”. Redeployment settings are per-repository.

redeploy

SNAPSHOT versions

Users are always able to redeploy SNAPSHOT versions, as Maven understands how to check for new versions of the SNAPSHOT.

Technical details

Currently, even if redeploys are disallowed, the user that created the original deploy can redeploy an artifact for up to five minutes afterwards. This may change in future releases to completely prevent redeploys.