我难住了。我正在使用 ant 和 maven-ant-tasks 构建快照工件(非 maven)并将其部署到远程 nexus 存储库。构建过程指定存储库的 url。这是运行的 ant 目标:
<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>
结果:
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
由于某些超出我理解的原因,maven 正试图部署到公共存储库(nexus 不允许)而不是指定的快照存储库(注意 nexus.url 变量)。构建文件中没有指定公共 URL。
更奇怪的是,在一台机器上,相同的构建脚本成功地部署了相同的工件,结果如下:
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
实际使用指定 URL 的位置。在比较两台机器时,ant(1.8.1 版)和 maven-ant-tasks(2.1.3)都是同一个版本。关系日志表明传入的请求在两者之间是不同的(其中一个指定快照存储库,另一个指定公共存储库),所以我想将此错误固定在 Maven 上。但是,我无法确定会导致这种情况的任何差异。
这是怎么回事?!
更新:
在嗅探数据包后,我们发现来自 maven 的请求被发送到:/nexus/content/groups/public/com/xactsites/shared-resources/13.1.19.2/shared-resources-13.1.19.2.war HTTP/1.1,在发送请求之前确认 maven 正在更改 URL。因此,解决此问题的任何努力都可以集中在 maven(而不是 nexus)上。