Error when deploying an artifact in Nexus
Solution 1
A couple things I can think of:
- user credentials are wrong
- url to server is wrong
- user does not have access to the deployment repository
- user does not have access to the specific repository target
- artifact is already deployed with that version if it is a release (not -SNAPSHOT version)
- the repository is not suitable for deployment of the respective artifact (e.g. release repo for snapshot version, proxy repo or group instead of a hosted repository)
Check those and if you still run into trouble provide more details here.
Solution 2
Just to create a separate answer. The answer is actually found in a comment for the accepted answer.
Try changing the version of your artefact to end with -SNAPSHOT
.
Solution 3
400 Bad Request will be returned if you attempt to:
- Deploy a snapshot artifact (or version) ending in -SNAPSHOT to a release repository
- Deploy a release artifact (version not ending in -SNAPSHOT) to a snapshot repository
- Deploy the same version of a release artifact more than once to a release repository
Solution 4
Cause of problem for me was -source.jars was getting uploaded twice (with maven-source-plugin) as mentioned as one of the cause in accepted answer. Redirecting to answer that I referred: Maven release plugin fails : source artifacts getting deployed twice
Solution 5
I had this exact problem today and the problem was that the version I was trying to release:perform was already in the Nexus repo.
In my case this was likely due to a network disconnect during an earlier invocation of release:perform. Even though I lost my connection, it appears the release succeeded.
acimutal
Updated on January 06, 2022Comments
-
acimutal over 2 years
Im' getting an error when deploying an artifact in my own repository in a Nexus server: "Failed to deploy artifacts: Could not transfer artifact" "Failed to transfer file http:///my_artifact. Return code is: 400"
I have Nexus running with one custom repository my_repo with the next maven local configuration:
settings.xml
<server> <id>my_repo</id> <username>user</username> <password>pass</password> </server> ... <mirror> <id>my_repo</id> <name>Repo Mirror</name> <url><my_url_to_my_repo></url> <mirrorOf>*</mirrorOf> </mirror>
- user has permissions to create/read/write into my_repo -
pom.xml
<distributionManagement> <repository> <id>my_repo</id> <name>my_repo</name> <url><my_url_to_my_repo></url> <layout>default</layout> </repository> <snapshotRepository> <id>snapshots</id> <name>Snapshots</name> <url><my_url_to_my_snapshot_repo></url> </snapshotRepository> </distributionManagement>
and then I execute
mvn deploy
and get the error. Any idea?
-
acimutal over 10 yearsI changed version of my artifact to SNAPSHOT and then deploy and all was ok. Then I realized that I was trying to deploy to a Nexus group (not a Nexus repository), so the cause of my problem was: 'url to my nexus repository was wrong'
-
user1535501 over 9 yearswhere did you found this more specific error 'url to my nexus repository was wrong' having similar issue and not seeing it in logs
-
Manfred Moser over 9 yearsAsk a new question.. but basically you have to use the url of a hosted repository
-
kuhajeyan almost 9 yearsNo you are missing the whole point, read the comment carefully it mentions "so the cause of my problem was: 'url to my nexus repository was wrong' ". And get some idea about what is meant be 'Return code is: 400' (before you just copy someones comments as answer)
-
Craig almost 9 yearsJust wanted to comment here since I hit this page in my searching. I ran into the same 400 error and what bhagyas said here is key (though I didn't realize it at the time), if deploying to a snapshot repository the version MUST end in -SNAPSHOT. My version was 1.13.0.SNAPSHOT and it took me an hour to figure out it needed to be 1.13.0-SNAPSHOT.
-
Nathan Russell over 8 yearsJust to add to this, if you dont have interactive access to the server (I dont - its a managed box), you can delete the offending artifact with a HTTP DELETE. I use PostMan for this purpose
-
Bhushan about 8 yearsIMPORTANT : "artifact is already deployed with that version if it is a release (not -SNAPSHOT version)"
-
venugopal over 7 yearsSaved my day... I removed the -SNAPSHOT word from version in pom.xml, that is why its not able to deploy on to nexus... I added the SNAPSHOT word back , and it worked ..
-
Marcus Junius Brutus about 7 yearsIn my experience wrong credentials result in 401, not 400. Suffixing the version name with "-SNAPSHOT" fixed the issue for me.
-
slashron about 6 yearsI my case the issue, version name was not unique for every build in continuous delivery setup and nexus was rejecting the duplicate artifact.
-
chizou over 5 yearsI'm not sure if it's because I'm using the S3 blobstore plugin, but I don't see a directory structure that matches the repo structure. Is there some trick to identifying which dirs to delete? All my files are named with a hash. The directories are of the format
content/vol-{01-43}/chap-{01-47}
-
intechops6 over 5 yearserror 401 is an authentication issue and error 400 means you are reaching the nexus server and executing the goal has failed like uploading the artifact has failed. so, status code 400 means, it could be that re-deply is disabled.
-
Gregor about 5 yearsI had some old .m2/settings.xml which missed the configuration and esp. credentials for our snapshot repository, adding that fixed my issues with deploying.
-
Christian Trimble about 5 yearsYou can also delete all of the files for a release by navigating to the release directory from the repository, instead of looking for the artifact from a GAV type search. In the repository view, you can right-click on the directory to get a delete action for all files at that GAV.
-
Furqan about 5 yearsyou can simply change the deployment policy of your repository to enable redeploy
-
Manfred Moser about 5 years@furqan while that is possible, it is also a terrible idea since it violates the idea that releases are immutable.
-
Furqan almost 5 years@ManfredMoser yes, I realized this and I tried to answer below.
-
maveroid almost 5 yearsartifact is already deployed with that version if it is a release (not -SNAPSHOT version) This was the reason for me.
-
Itaypk almost 5 yearsAllowing redeployment for releases repository is usually not considered a good practice. Do not do that without consideration.
-
Furqan almost 5 years@Itaypk you are right that is why I have suggested a few other suggestions. In my opinion, changing the version is better.
-
ghoulfolk about 3 yearsthis one helped me. The problem was that I had to do a revert, which caused the project version number to be reverted as well, causing problems because the version which was reverted to was already on nexus. I then manually upped the version number and the job finished in success
-
Freddie about 2 yearsIn my case my repo was accidentally using an npm repo and I was trying to use maven to deploy. I had to change to the nexus maven repo.
-
Manfred Moser about 2 yearshahah ... too many different repo formats around these days right @Jared
-
Brad M about 2 yearsBy principle maven releases should not be redeployed. If you have a version released, there should be only one.