Search code examples
mavenjenkinsartifactoryjenkins-pipeline

The target deployment path '...' does not match the POM's expected path prefix


I am trying to upload a pom.xml file to a Maven repository hosted on an Artifactory server. The <project> section of the pom.xml looks like this:

<groupId>com.x.y.z</groupId>
<artifactId>common</artifactId>
<version>2.3.0-RELEASE</version>
<packaging>jar</packaging>

I am using the Artifactory plugin for Jenkins in a Pipeline script and here is the 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"
         }
     ]
 }

When I now try to upload the artifact, I'm getting the following error message:

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

Before I upload the RELEASE, I upload a SNAPSHOT which (in this case) had the version 2.2.7-SNAPSHOT. After that I bump the version to 2.3.0, re-build the project with mvn clean install and then start another upload to Artifactory. Somehow Artifactory still seems to expect the "old" version, when I try to upload the new version.

Edit

When I upload the file with curl, everything works as expected:

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"

So it seems like this is related to the Jenkins Artifactory Plugin.


Solution

  • You upload your pom file to an incorrect location. You use

    REPOSITORY/com/x/y/z/common-2.3.0-RELEASE.pom
    

    as a path, when the path should be

    REPOSITORY/com/x/y/z/common/2.3.0-RELEASE/common-2.3.0-RELEASE.pom
    

    Note version-named directory that is missing.

    The good news are you don't even need to bother with it. When you use our Artifactory.newMavenBuild for Maven builds, we'll take care of the correct deployment. See the example.