Why do I get a 400 when attempting to use publish-plugin from the Grails Release plugin

1.4k Views Asked by At

I'm using Grails 2.4.1 & The Grails Release plugin version 3.0.1.

I have a Sonatype nexus repository (v2.3.1-01) setup that's in use by several other projects with no issues.

I'm attempting to create a new Plugin that I want to distribute through a SNAPSHOT repository in nexus (and later through our Releases repository).

In my ${projectName}GrailsPlugin.groovy file I have:

def groupId ="my-department-grails-plugins"
def version = "0.1-SNAPSHOT"

In my application.properties file I have:

app.name=MyPluginNameForGrails

In my BuildConfig.groovy I have:

grails.project.repos.newsnapshots.url = "http://internal.server.address/nexus/service/local/repositories/snapshots"
grails.project.repos.newsnapshots.username = "username"
grails.project.repos.newsnapshots.password = "password"

I'm trying to kick things off with the following command:

publish-plugin --snapshot --repository=newsnapshots --stacktrace

The build success everything looks good until it trys to push into nexus and I get:

Using configured username and password from grails.project.repos.newsnapshots ....Error | Failed to publish plugin: Error deploying artifact 'ald-grails-plugins:my-plugin-name-for-grails:zip': Error deploying artifact: Failed to transfer file: http://internal.server.address/nexus/content/groups/public/my-department-grails-plugins/my-plugin-name-for-grails/0.1-SNAPSHOT/my-plugin-name-for-grails-0.1-20140815.191240-1.zip. Return code is: 400

I've found a related StackOverflow question which seems related but none of the conditions they describe as causing the 400 exist.

I also found the article by Sonatype Nexus which describes possible causes of 400's and those don't seem to be it either.

If you notice the repository that I'm pointing to, it is directly to a repository but then in the error message it lists a path to a group. I am thinking this may be somehow related but but if so... I am not sure how to fix it since this seems to be happening somehow internal to the Releases Plugin.

I should also add that I've removed the -SNAPSHOT from the GrailsPlugin.groovy file and changed the destination repository to be our RELEASES repository with the exact same result.

2

There are 2 best solutions below

0
On BEST ANSWER

My problem was due to a mirror defined in my .m2/settings.xml file (thanks Jeff Beck for the comment that led to the resolution!). This was causing the POST to the repository to be redirected to the public GROUP which wasn't allowing the artifact to be uploaded.

There are a few other secondary causes that were contributing to my troubleshooting issues:

  1. While uploading to a SNAPSHOT repository your version number must be of the pattern x-SNAPSHOT where x can be anything(?).
  2. You cannot upload to a SNAPSHOT repository when using the Nexus ReST API. This didn't actually end up affecting my specific solution but it's worth noting for others that may run into this issue.
  3. While uploading to a NON-SNAPSHOT repository your version number must NOT be of the pattern x-SNAPSHOT.
0
On

Given a mirror setting in the .m2 directory the grails release plugin will have issues trying to deploy xif the mirror matches where you are deploying to. You can remove the mirror setting or change it to not match your targeted repo. Check out these jiras for more info: