Question

I am stumped. I am using ant and maven-ant-tasks to build and deploy snapshot artifacts (non-maven) to a remote nexus repository. The build process specifies the url of the repository. This is the ant target that is run:

<target name="shared_resources_war_deploy" depends="shared_resources_war">
    <artifact:pom id="sharedResourcesPom" file="${resourcesdir}/shared-resources-pom.xml" />
    <echo message="**************************${nexus.url}*************************" />
    <artifact:deploy file="${resourcesdir}/shared-resources.war">
        <remoteRepository url="${nexus.url}">
            <authentication username="${nexusUserName}" password="${nexusUserPassword}" /> 
        </remoteRepository>
        <pom refid="sharedResourcesPom"/>
    </artifact:deploy>
</target>

And results in:

shared_resources_war_deploy:
     [echo] **************************http://${nexusIP}:8081/nexus/content/repositories/snapshots*************************
[artifact:deploy] Deploying to http://${nexusIP}:8081/nexus/content/groups/public
[artifact:deploy] [INFO] Retrieving previous build number from nexus
[artifact:deploy] Uploading: com/xactsites/shared-resources/13.1.19-SNAPSHOT/shared-resources-13.1.19-20121211.172831-28.war to repository nexus at http://${nexusIP}:8081/nexus/content/groups/public
[artifact:deploy] Transferring 2K from nexus
[artifact:deploy] An error has occurred while processing the Maven artifact tasks.
[artifact:deploy]  Diagnosis:
[artifact:deploy]
[artifact:deploy] Error deploying artifact 'com.xactsites:shared-resources:war': Error deploying artifact: Failed to transfer file: http://${nexusIP}:8081/nexus/content/groups/public/com/xactsites/shared-resources/13.1.19-SNAPSHOT/shared-resources-13.1.19-20121211.172831-28.war. Return code is: 400
[artifact:deploy]

BUILD FAILED
C:\Users\11_1_15\build.xml:561: The following error occurred while executing this line:
C:\Users\11_1_15\build.xml:551: Error deploying artifact 'com.xactsites:shared-resources:war': Error deploying artifact: Failed to transfer file: http://${nexusIP}:8081/nexus/content/groups/public/com/xactsites/shared-resources/13.1.19-SNAPSHOT/shared-resources-13.1.19-20121211.172831-28.war. Return code is: 400

For some reason beyond my understanding, maven is trying to deploy to the public repository (not allowed by nexus) instead of the snapshot repository specified (note the nexus.url variable). No where in the build file is the public URL being specified.

To make things more curious, on one machine the same build script is successfully deploying the same artifact with this result:

shared_resources_war_deploy:
     [echo] **************************http://${nexusIP}:8081/nexus/content/repositories/snapshots*************************
[artifact:deploy] Deploying to http://${nexusIP}:8081/nexus/content/repositories/snapshots
[artifact:deploy] [INFO] Retrieving previous build number from remote
[artifact:deploy] Uploading: com/xactsites/shared-resources/13.1.19-SNAPSHOT/shared-resources-13.1.19-20121211.172031-27.war to repository remote at http://${nexusIP}:8081/nexus/content/repositories/snapshots
[artifact:deploy] Transferring 2K from remote
[artifact:deploy] Uploaded 2K
[artifact:deploy] [INFO] Retrieving previous metadata from remote
[artifact:deploy] [INFO] Uploading repository metadata for: 'snapshot com.xactsites:shared-resources:13.1.19-SNAPSHOT'
[artifact:deploy] [INFO] Uploading project information for shared-resources 13.1.19-20121211.172031-27
[artifact:deploy] [INFO] Retrieving previous metadata from remote
[artifact:deploy] [INFO] Uploading repository metadata for: 'artifact com.xactsites:shared-resources'

BUILD SUCCESSFUL

where the URL specified is actually used. In comparing the two machines, both ant (version 1.8.1) and the maven-ant-tasks (2.1.3) are the same version. The nexus logs suggest that the incoming request is different between the two (where one specifies the snapshot repository and the other the public repository) so I want to pin this error on Maven. However, I haven't been able to determine any differences that would cause this.

What's going on?!

UPDATE:

After sniffing the packets we found that the request from maven was being sent to: /nexus/content/groups/public/com/xactsites/shared-resources/13.1.19.2/shared-resources-13.1.19.2.war HTTP/1.1, confirming that maven is changing the URL before sending the request. So, any efforts to solve this can focus on maven (not nexus).

Was it helpful?

Solution

After some painful research and a fluke typo by a coworker opened up a new path to explore we found the cause. Essentially, if the M2/M2_HOME environment variables are set as specified here, then the remote repository url is overwritten with that from our settings.xml file and uses the mirror that is set up for nexus (hence using the wrong, read-only URL for deployment).

This appears to be an issue both within the pom using the <distributionManagement> element as well as using the <remoteRepository> element within the ant file. There is already a bug filed for this.

Resolutions:

We narrowed it down that having the <mirrorOf>*</mirrorOf> set where the '*' causes this issue. Replacing the * with specific repositories (such as 'central') resolves this issue.

Just as well, not setting the M2 environment variables fixes this as well, since it can't get to the settings.xml file to get the URL. Of course, you wouldn't want to go this approach if you rely on some other things in your settings.xml to be present when running the deploy.

uggh, that was a painful bug to track down.

OTHER TIPS

This appears to be solved in version 2.1.4-SNAPSHOT.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top