3

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.

Community
  • 1
  • 1
Randyaa
  • 2,935
  • 4
  • 36
  • 49
  • Can you publish a snapshot jar from something like gradle to the same repo with the same user pass? – Jeff Beck Aug 16 '14 at 22:34
  • I tried this simple curl command and it worked just fine: curl -v -u username:password --upload-file pom.xml http://internal.server.address/nexus/content/repositories/snapshots/org/department/test/randy-test/0.1-SNAPSHOT/randy-test-0.1-SNAPSHOT.pom – Randyaa Aug 18 '14 at 13:53
  • I used a slightly more complicated curl command utilizing the ReST API & including both my pom file and artifact. The result was the following 400: This is a Maven SNAPSHOT repository, and manual upload against it is forbidden! – Randyaa Aug 18 '14 at 14:21
  • Using the same curl command but changing the repository to our releases repository & the version to 0.1 (instead of 0.1-SNAPSHOT) seems to work just fine. – Randyaa Aug 18 '14 at 14:23
  • I'm not sure exactly the problem I haven't had an issue with our nexus it might be how that one is configured. sorry I can't be of more help – Jeff Beck Aug 18 '14 at 16:05
  • There aren't any mirror settings in your .m2 config file are there? I've seen those cause issues. – Jeff Beck Aug 18 '14 at 16:06
  • Yes there were and that resolved it. Thank you! – Randyaa Aug 18 '14 at 17:31

2 Answers2

3

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.
Community
  • 1
  • 1
Randyaa
  • 2,935
  • 4
  • 36
  • 49
0

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:

Jeff Beck
  • 3,944
  • 3
  • 28
  • 45