目标部署路径' ...'与POM的预期路径前缀不匹配

时间:2017-04-13 09:45:08

标签: maven jenkins artifactory jenkins-pipeline

我正在尝试将pom.xml文件上传到Artifactory服务器上托管的Maven存储库。 <project>的{​​{1}}部分如下所示:

pom.xml

我在管道脚本中使用Jenkins的Artifactory插件,这里是<groupId>com.x.y.z</groupId> <artifactId>common</artifactId> <version>2.3.0-RELEASE</version> <packaging>jar</packaging>

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重新构建项目,然后再开始上传到Artifactory。不知何故Artifactory似乎仍然期待着#34; old&#34;版本,当我尝试上传新版本时。

修改

当我使用mvn clean install上传文件时,一切都按预期工作:

curl

所以看起来这与Jenkins Artifactory插件有关。

2 个答案:

答案 0 :(得分:3)

您将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

答案 1 :(得分:1)

您可以在管道脚本中尝试以下代码吗?

 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

或者如果它不起作用,您可以使用

在管道脚本中使用maven deploy
users:write:1234