我正在尝试将pom.xml
文件上传到Artifactory服务器上托管的Maven存储库。pom.xml
的<project>
部分如下所示:
<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"
}
]
}
当我现在尝试上传项目时,我收到以下错误消息:
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
之前,我上传了一个(在这种情况下(版本为2.2.7-SNAPSHOT的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 构建时,我们将负责正确的部署。请参阅示例。
您可以在管道脚本中尝试以下代码吗?
{
"pattern": "pom.xml",
"target": "REPOSITORY/com/x/y/z/common/2.3.0-RELEASE/common-2.3.0-RELEASE.pom"
}
或者,如果它不起作用,您可以使用
def mvnHome = tool mvnName
sh "$mvnHome/bin/mvn deploy -deploy-file -Durl=file:///C:/m2-repo
-DrepositoryId=some.id
-Dfile=path-to-your-artifact-jar
-DpomFile=path-to-your-pom.xml