How can I fail the build if a certain artifact does exist in the repository? The Maven Wagon Plugin has an "exists" goal, but not the opposite.
The reason for my question is as follows.
My Maven project goes through an automated build pipeline, which ends in a release stage. This stage performs an automated release through a mvn deploy -P release
, after setting the release version with a mvn versions:set -DremoveSnapshot
. The stage is triggered manually (since not every push should result in a release).
The mvn deploy
will fail if the artifact to be uploaded is already in the repository. But this failure would come very late, during the last stage of the pipeline, while existence in the repository could be checked much earlier.
In order to get fail-fast behavior I would like to check if the artifact that would be released has not already been uploaded to Nexus. I want to do this in the first stage of the pipeline, which only performs a mvn package -P releasable
. Preferably the "releasable" profile would make Maven do this check automatically during the "validate" phase of the default lifecycle.