我正在尝试上传 pom.xml
文件到托管在 Artifactory 服务器上的 Maven 存储库。 <project>
节pom.xml
看起来像这样:
<groupId>com.x.y.z</groupId>
<artifactId>common</artifactId>
<version>2.3.0-RELEASE</version>
<packaging>jar</packaging>
我在管道脚本中使用 Jenkins 的 Artifactory 插件,这里是 uploadSpec
{
"files": [
{
"pattern": "target/common-2.3.0-RELEASE.jar",
"target": "REPOSITORY/com/x/y/z/common/2.3.0-RELEASE/common-2.3.0-RELEASE.jar"
},
{
"pattern": "pom.xml",
"target": "REPOSITORY/com/x/y/z/common/2.3.0-RELEASE/common-2.3.0-RELEASE.pom"
}
]
}
当我现在尝试上传 Artifact 时,我收到以下错误消息:
java.io.IOException: Failed to deploy file.
Status code: 409
Response message: Artifactory returned the following errors:
The target deployment path 'com/x/y/z/common/2.3.0-RELEASE/common-2.3.0-RELEASE.pom'
does not match the POM's expected path prefix 'com/x/y/z/common/2.2.7'.
Please verify your POM content for correctness and make sure the source path is a valid Maven repository root path. Status code: 409
在我上传 RELEASE
之前,我上传一个SNAPSHOT
其中(在本例中)的版本为 2.2.7-SNAPSHOT。之后我将版本提升到 2.3.0
, 用 mvn clean install
重新构建项目然后开始另一个上传到 Artifactory。当我尝试上传新版本时,Artifactory 似乎仍然期待“旧”版本。
编辑
当我使用 curl
上传文件时,一切都按预期工作:
curl -user:password-T pom.xml \
"http://DOMAIN/artifactory/REPOSITORY/com/x/y/z/common/2.3.0-RELEASE/common-2.3.0-RELEASE.pom"
所以这似乎与 Jenkins Artifactory 插件有关。
最佳答案
您将 pom 文件上传到错误的位置。你用
REPOSITORY/com/x/y/z/common-2.3.0-RELEASE.pom
作为路径,当路径应该是
REPOSITORY/com/x/y/z/common/2.3.0-RELEASE/common-2.3.0-RELEASE.pom
请注意缺少的版本命名目录。
好消息是您甚至不需要为此操心。当您使用我们的 Artifactory.newMavenBuild
进行 Maven 构建时,我们将负责正确部署。参见 the example .
关于maven - 目标部署路径 '...' 与 POM 的预期路径前缀不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43388832/