github / maven-plugins

Official GitHub Maven Plugins
MIT License
584 stars 198 forks source link

Download resource with `name` already exists #19

Closed drewr closed 12 years ago

drewr commented 12 years ago

I'm using the downloads plugin version 0.5 to update our artifacts in our repo. It works just fine locally, but I get this error in our CI environment (using Jenkins): http://p.draines.com/1340737967626ed18ec28.txt. I can't figure out if I'm doing something wrong or if this is a bug.

org.apache.maven.lifecycle.LifecycleExecutionException: Resource elasticsearch-jetty-0.19.4.jar upload failed: Validation Failed (422): Download resource with 'name' field already exists
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Resource elasticsearch-jetty-0.19.4.jar upload failed: Validation Failed (422): Download resource with 'name' field already exists
    at com.github.maven.plugins.downloads.DownloadsMojo.execute(DownloadsMojo.java:346)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more
Caused by: org.eclipse.egit.github.core.client.RequestException: Validation Failed (422): Download resource with 'name' field already exists
    at org.eclipse.egit.github.core.client.GitHubClient.createException(GitHubClient.java:516)
    at org.eclipse.egit.github.core.client.GitHubClient.sendJson(GitHubClient.java:600)
    at org.eclipse.egit.github.core.client.GitHubClient.post(GitHubClient.java:679)
    at org.eclipse.egit.github.core.service.DownloadService.createResource(DownloadService.java:231)
    at org.eclipse.egit.github.core.service.DownloadService.createDownload(DownloadService.java:290)
    at org.eclipse.egit.github.core.service.DownloadService.createDownload(DownloadService.java:312)
    at com.github.maven.plugins.downloads.DownloadsMojo.execute(DownloadsMojo.java:342)
kevinsawicki commented 12 years ago

Do you have

<override>true</override>

in your plugin configuration?

drewr commented 12 years ago

It was set to true but I disabled it because I was getting http://p.draines.com/1340744132414a3829bc8.txt. I don't get this error either locally.

org.apache.maven.lifecycle.LifecycleExecutionException: Deleting existing download elasticsearch-jetty-0.19.4-sources.jar failed: Not Found (404)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Deleting existing download elasticsearch-jetty-0.19.4-sources.jar failed: Not Found (404)
    at com.github.maven.plugins.downloads.DownloadsMojo.deleteDownload(DownloadsMojo.java:283)
    at com.github.maven.plugins.downloads.DownloadsMojo.execute(DownloadsMojo.java:327)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more
Caused by: org.eclipse.egit.github.core.client.RequestException: Not Found (404)
    at org.eclipse.egit.github.core.client.GitHubClient.delete(GitHubClient.java:713)
    at org.eclipse.egit.github.core.client.GitHubClient.delete(GitHubClient.java:554)
    at org.eclipse.egit.github.core.service.DownloadService.deleteDownload(DownloadService.java:213)
    at com.github.maven.plugins.downloads.DownloadsMojo.deleteDownload(DownloadsMojo.java:279)
    ... 20 more
kevinsawicki commented 12 years ago

Do you have authentication setup on the CI machine?

drewr commented 12 years ago

Yes, via ~/.m2/settings.xml. I'm authenticating with a user who was able to post downloads via a custom script.

kevinsawicki commented 12 years ago

Is this repository public or private?

Can you include the output running with -X as well?

drewr commented 12 years ago

Public: https://github.com/sonian/elasticsearch-jetty

Here's the end of the output with -X:

[...]
[DEBUG] Configuring mojo 'com.github.github:downloads-maven-plugin:0.5:upload' -->
[DEBUG]   (f) description = Official elasticsearch-jetty build of the 0.19.4 release
[DEBUG]   (f) includeAttached = true
[DEBUG]   (f) override = true
[DEBUG]   (f) project = MavenProject: com.sonian:elasticsearch-jetty:0.19.4 @ /mnt/jenkins/workspace/elasticsearch-jetty/pom.xml
[DEBUG]   (f) server = github
[DEBUG]   (f) settings = org.apache.maven.settings.Settings@68cab3bf
[DEBUG] -- end configuration --
[INFO] [ghDownloads:upload {execution: default-cli}]
[DEBUG] Using GitHub repository sonian/elasticsearch-jetty
[DEBUG] Using 'github' server credentials
[DEBUG] Using basic authentication with username: safebot
[DEBUG] Listed 9 existing downloads
[DEBUG] Artifact files to include: [/mnt/jenkins/workspace/elasticsearch-jetty/target/elasticsearch-jetty-0.19.4.jar, /mnt/jenkins/workspace/elasticsearch-jetty/target/elasticsearch-jetty-0.19.4-sources.jar, /mnt/jenkins/workspace/elasticsearch-jetty/target/releases/elasticsearch-jetty-0.19.4.zip, /mnt/jenkins/workspace/elasticsearch-jetty/target/elasticsearch-jetty-0.19.4-sources.jar, /mnt/jenkins/workspace/elasticsearch-jetty/target/releases/elasticsearch-jetty-0.19.4.zip]
[INFO] Adding 5 downloads to repository sonian/elasticsearch-jetty
[INFO] Deleting existing download: elasticsearch-jetty-0.19.4.jar (id=263558)
[INFO] Adding download: elasticsearch-jetty-0.19.4.jar (51,785 bytes)
[INFO] Deleting existing download: elasticsearch-jetty-0.19.4-sources.jar (id=263559)
[INFO] Adding download: elasticsearch-jetty-0.19.4-sources.jar (32,104 bytes)
[INFO] Deleting existing download: elasticsearch-jetty-0.19.4.zip (id=263560)
[INFO] Adding download: elasticsearch-jetty-0.19.4.zip (925,200 bytes)
[INFO] Deleting existing download: elasticsearch-jetty-0.19.4-sources.jar (id=263559)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Deleting existing download elasticsearch-jetty-0.19.4-sources.jar failed: Not Found (404)

[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Deleting existing download elasticsearch-jetty-0.19.4-sources.jar failed: Not Found (404)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Deleting existing download elasticsearch-jetty-0.19.4-sources.jar failed: Not Found (404)
    at com.github.maven.plugins.downloads.DownloadsMojo.deleteDownload(DownloadsMojo.java:283)
    at com.github.maven.plugins.downloads.DownloadsMojo.execute(DownloadsMojo.java:327)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more
Caused by: org.eclipse.egit.github.core.client.RequestException: Not Found (404)
    at org.eclipse.egit.github.core.client.GitHubClient.delete(GitHubClient.java:713)
    at org.eclipse.egit.github.core.client.GitHubClient.delete(GitHubClient.java:554)
    at org.eclipse.egit.github.core.service.DownloadService.deleteDownload(DownloadService.java:213)
    at com.github.maven.plugins.downloads.DownloadsMojo.deleteDownload(DownloadsMojo.java:279)
    ... 20 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 34 seconds
[INFO] Finished at: Tue Jun 26 21:18:31 UTC 2012
[INFO] Final Memory: 58M/451M
[INFO] ------------------------------------------------------------------------
Build step 'Execute shell' marked build as failure
Finished: FAILURE
kevinsawicki commented 12 years ago

And just to confirm, it always completes normally locally but always fails from your CI machine?

drewr commented 12 years ago

That is correct. Here's a successful run locally:

[DEBUG] Configuring mojo com.github.github:downloads-maven-plugin:0.5:upload from plugin realm ClassRealm[plugin>com.github.github:downloads-maven-plugin:0.5, parent: sun.misc.Launcher$AppClassLoader@5ab8df17]
[DEBUG] Configuring mojo 'com.github.github:downloads-maven-plugin:0.5:upload' with basic configurator -->
[DEBUG]   (f) description = Official elasticsearch-jetty build of the 0.19.4 release
[DEBUG]   (f) includeAttached = true
[DEBUG]   (f) override = true
[DEBUG]   (f) project = MavenProject: com.sonian:elasticsearch-jetty:0.19.4 @ /Users/aar/src/elasticsearch-jetty/pom.xml
[DEBUG]   (f) server = github
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@71f801f7
[DEBUG] -- end configuration --
[DEBUG] Using GitHub repository sonian/elasticsearch-jetty
[DEBUG] Using 'github' server credentials
[DEBUG] Using basic authentication with username: drewr
[DEBUG] Listed 9 existing downloads
[DEBUG] Artifact files to include: [/Users/aar/src/elasticsearch-jetty/target/elasticsearch-jetty-0.19.4.jar,/Users/aar/src/elasticsearch-jetty/target/elasticsearch-jetty-0.19.4-sources.jar, /Users/aar/src/elasticsearch-jetty/target/releases/elasticsearch-jetty-0.19.4.zip]
[INFO] Adding 3 downloads to repository sonian/elasticsearch-jetty
[INFO] Deleting existing download: elasticsearch-jetty-0.19.4.jar (id=263580)
[INFO] Adding download: elasticsearch-jetty-0.19.4.jar (51,784 bytes)
[INFO] Deleting existing download: elasticsearch-jetty-0.19.4-sources.jar (id=263581)
[INFO] Adding download: elasticsearch-jetty-0.19.4-sources.jar (32,284 bytes)
[INFO] Deleting existing download: elasticsearch-jetty-0.19.4.zip (id=263582)
[INFO] Adding download: elasticsearch-jetty-0.19.4.zip (925,287 bytes)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 51.903s
[INFO] Finished at: Tue Jun 26 16:37:49 CDT 2012
[INFO] Final Memory: 19M/81M
[INFO] ------------------------------------------------------------------------
kevinsawicki commented 12 years ago

Looking at the following line from your output:

[DEBUG] Artifact files to include: [/mnt/jenkins/workspace/elasticsearch-jetty/target/elasticsearch-jetty-0.19.4.jar, /mnt/jenkins/workspace/elasticsearch-jetty/target/elasticsearch-jetty-0.19.4-sources.jar, /mnt/jenkins/workspace/elasticsearch-jetty/target/releases/elasticsearch-jetty-0.19.4.zip, /mnt/jenkins/workspace/elasticsearch-jetty/target/elasticsearch-jetty-0.19.4-sources.jar, /mnt/jenkins/workspace/elasticsearch-jetty/target/releases/elasticsearch-jetty-0.19.4.zip]

It looks like multiple entries of the same artifact are being reported as attached artifacts of the build (the elasticsearch-jetty-0.19.4-sources.jar file). This causes the same entry to be processed twice and is failing when deleting it the second time.

I'm not sure how this is happening and why only on one machine but it is fixable to just not include duplicates when building up the collection of downloads to create.

drewr commented 12 years ago

Thanks! Will you publish a new version to maven repos?

kevinsawicki commented 12 years ago

Just published a 0.6 of the downloads plugin to the Sonatype OSS.

Should be sync'ed to Maven Central is the next couple hours.

Please let me know if you still have issues but I believe the fix should resolve the error you are seeing.

drewr commented 12 years ago

Just a note that at least some of my issues were caused by a difference in Maven version. My CI server had 2.2.1 for some reason (old Ubuntu Lucid), while locally I am using 3.0.3.

Thanks for the help Kevin!