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

标签 maven jenkins artifactory jenkins-pipeline

我正在尝试上传 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/

相关文章:

java - 部署 Spring MVC Web 应用程序

jenkins - 如何将凭证从一个 Jenkins 实例导出到另一个实例?

security - 如何在不对它们进行硬编码的情况下从 buildscript 发送 Artifactory 发布凭据?

go - 带参数的 jfrog go 命令

java - 在 Linux 上部署到 Tomcat 时出现 JSF PropertyNotFound

java - getClass().getResource ("/") 在命令行中返回 null

java - 与最新版本 Selenium Webdriver 和 PhantomJs 的兼容性问题

jenkins - 如何在 Jenkins 中显示测试结果趋势?

jenkins - Jenkins 的 Gerrit 触发器安装

docker - Windows docker 容器中的 jfrog-cli - x509 : certificate signed by unknown authority