I have this exact same exception (except I can reproduce it everytime), and was about to post a new bug when I saw this come across. I encountered this when migrating to Jenkins from Hudson, but have since verified it is an issue with the current Hudson as well.
For us, this was an issue I believe introduced when Hudson started supporting Maven3 (we had other Maven3 issues when 1.392 came out and rolled back until now). My build works in Hudson 1.391, and does not currently work with Hudson 1.395, nor the latest Jenkins release.
We have a Master/slaves configuration and our job is running with Maven 2.2.1. It is a multi-module project, and some of the modules produce multiple artifacts (though I don't think that is related, as the first module to publish fails and only produces one artifact).
The error we have is that it reports the exception that it can't create the destination directory, but it is providing a filepath on the slave, that actually already exists and is readable by the slave (the maven build process created it).
Here is the error output (with search and replace of project/company names... hopefully it is still readable):
Deploying artifacts to https://COMPANY-NAME/content/repositories/snapshots/
Deploying the main artifact ARTIFACT-NAME-1.0.0-SNAPSHOT.pom
ERROR: Error retrieving previous build number for artifact 'GROUP-NAME:ARTIFACT-NAME:pom': repository metadata for: 'snapshot GROUP-NAME:ARTIFACT-NAME:1.0.0-SNAPSHOT' could not be retrieved from repository: nexus-snapshots due to an error: Specified destination directory cannot be created: /SLAVE-WORKSPACE/JOB-NAME/.repository/GROUPNAME/ARTIFACT-NAME/1.0.0-SNAPSHOT
org.apache.maven.artifact.deployer.ArtifactDeploymentException: Error retrieving previous build number for artifact 'GROUP-NAME:ARTIFACT-NAME:pom': repository metadata for: 'snapshot GROUP-NAME:ARTIFACT-NAME:1.0.0-SNAPSHOT' could not be retrieved from repository: inventrio-nexus-snapshots due to an error: Specified destination directory cannot be created: /SLAVE-WORKSPACE/JOB-NAME/.repository/GROUPNAME/ARTIFACT-NAME/1.0.0-SNAPSHOT
at hudson.maven.artifact.transform.SnapshotTransformation.transformForDeployment(SnapshotTransformation.java:110)
at hudson.maven.artifact.transform.DefaultArtifactTransformationManager.transformForDeployment(DefaultArtifactTransformationManager.java:71)
at hudson.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:92)
at hudson.maven.reporters.MavenArtifactRecord.deployMavenArtifact(MavenArtifactRecord.java:139)
at hudson.maven.reporters.MavenArtifactRecord.deploy(MavenArtifactRecord.java:126)
at hudson.maven.RedeployPublisher.perform(RedeployPublisher.java:128)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:622)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:601)
at hudson.maven.MavenModuleSetBuild$RunnerImpl.post2(MavenModuleSetBuild.java:762)
at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:548)
at hudson.model.Run.run(Run.java:1386)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:405)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:145)
Caused by: org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException: repository metadata for: 'snapshot GROUP-NAME:ARTIFACT-NAME:1.0.0-SNAPSHOT' could not be retrieved from repository: nexus-snapshots due to an error: Specified destination directory cannot be created: /SLAVE-WORKSPACE/JOB-NAME/.repository/GROUPNAME/ARTIFACT-NAME/1.0.0-SNAPSHOT
at org.apache.maven.artifact.repository.metadata.DefaultRepositoryMetadataManager.resolveAlways(DefaultRepositoryMetadataManager.java:400)
at hudson.maven.artifact.transform.SnapshotTransformation.resolveLatestSnapshotBuildNumber(SnapshotTransformation.java:158)
at hudson.maven.artifact.transform.SnapshotTransformation.transformForDeployment(SnapshotTransformation.java:104)
... 14 more
Caused by: org.apache.maven.wagon.TransferFailedException: Specified destination directory cannot be created: /SLAVE-WORKSPACE/JOB-NAME/.repository/GROUPNAME/ARTIFACT-NAME/1.0.0-SNAPSHOT
at org.apache.maven.wagon.AbstractWagon.createParentDirectories(AbstractWagon.java:253)
at org.apache.maven.wagon.AbstractWagon.getTransfer(AbstractWagon.java:291)
at org.apache.maven.wagon.AbstractWagon.getTransfer(AbstractWagon.java:276)
at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:97)
at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
at org.apache.maven.repository.legacy.DefaultWagonManager.getRemoteFile(DefaultWagonManager.java:351)
at org.apache.maven.repository.legacy.DefaultWagonManager.getArtifactMetadataFromDeploymentRepository(DefaultWagonManager.java:215)
at org.apache.maven.artifact.repository.metadata.DefaultRepositoryMetadataManager.getArtifactMetadataFromDeploymentRepository(DefaultRepositoryMetadataManager.java:424)
at org.apache.maven.artifact.repository.metadata.DefaultRepositoryMetadataManager.resolveAlways(DefaultRepositoryMetadataManager.java:396)
... 16 more
If I just do a "deploy" goal in the build and not the post build action, it works, but I prefer to use the post build as I can ensure all the tests pass for all the modules.
Does the post build deploy action run on the master, or the slave? If on the Master, the filepath is wrong. If on the Slave, it is failing saying it can't create a directory that already exists and it (the slave process) owns, has permissions on, and already created.
do you have any logs for this ?
because "attached" artifacts are use (ie : target/*.jar or *.war), artifacts produced by the maven build