目标部署路径“...”与 POM 的预期路径前缀不匹配
The target deployment path '...' does not match the POM's expected path prefix
我正在尝试将 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
之前,我上传了一个 SNAPSHOT
,它(在本例中)的版本是 2.2.7-SNAPSHOT。之后我将版本升级到 2.3.0
,用 mvn clean install
重新构建项目,然后开始另一个上传到 Artifactory。当我尝试上传新版本时,Artifactory 似乎仍然期待 "old" 版本。
编辑
当我使用 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。
你能在管道脚本中试试下面的代码吗?
{
"pattern": "pom.xml",
"target": "REPOSITORY/com/x/y/z/common/2.3.0-RELEASE/common-2.3.0-RELEASE.pom"
}
或者如果它不起作用,您可以使用
在管道脚本中使用 maven 部署
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
我正在尝试将 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
之前,我上传了一个 SNAPSHOT
,它(在本例中)的版本是 2.2.7-SNAPSHOT。之后我将版本升级到 2.3.0
,用 mvn clean install
重新构建项目,然后开始另一个上传到 Artifactory。当我尝试上传新版本时,Artifactory 似乎仍然期待 "old" 版本。
编辑
当我使用 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。
你能在管道脚本中试试下面的代码吗?
{
"pattern": "pom.xml",
"target": "REPOSITORY/com/x/y/z/common/2.3.0-RELEASE/common-2.3.0-RELEASE.pom"
}
或者如果它不起作用,您可以使用
在管道脚本中使用 maven 部署 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