409 conflict in the snapshot release handling policy during artifact deploy

Viewed 27056

We have a set of files that we would like to deploy to artifactory, test results specifically. Files which match the following pattern seem to consistently produce a 409 rejected the resolution of an artifact due to conflict in the snapshot release handling policy. The file follows the format abcxyz-test-results.json. We have other result files that are just test-results.json that upload just fine. It is worth noting that all other artifacts upload successfully until the 409 is encountered.

Our repository uses the maven-2-default repository layout. The include regex is set to **/* and we do not define any exclusion. My next step is to increase the verbosity of the logging that Artifactory produces when we encounter this error but I am not sure if that will be fruitful.

I am at a loss as to what about the snapshot handling policy we are violating with this file. Any ideas about what debugging steps I can take, or what the actual conflict might be would be greatly appreciated.

2 Answers

For future readers who stumble upon this question.

And magic phrase(s)

due to conflict in the snapshot release handling policy

IF you are publishing to the simple versions, most likely like this:

String repoKeyValue = version.endsWith('SNAPSHOT') ? 'libs-snapshot-local' : 'libs-release-local'

Then you probably will not get this error.

However, if you are trying to publish to a company wide full scale artifactory implementation, you might be publishing to something that looks more like this:

String repoKeyValue = version.contains('SNAPSHOT') ? 'MyCustomRepository-Snapshots/com/mycompany/mypackagename1/mypackagename2/' : 'MyCustomRepository-Releases/com/mycompany/mypackagename1/mypackagename2/'

So what is the issue?

When you publish with this (just below) configuration (full context of the configuration later in this question:

        publishBuildInfo = true
        publishPom = true

Artifactory is doing checking..to make sure what is the .pom's is consistent to your overall publish path name.

Hack fix: (immediately below code)

        publishBuildInfo = false
        publishPom = false

The real fix is to harmonize your com.mycompany.mypackage......blah.blah.blah names so that the artifactory naming consistency checks pass correctly.

 The repository 'MyCustomRepository-Snapshots' rejected the resolution of an artifact 'MyCustomRepository-Snapshots:com/mycompany/mypackagenameNotQuiteRight999/myPackageNameNotQuiteRight888/my-thing-impl/1.0.60-SNAPSHOT-1601111703114/my-thing-impl-1.0.60-SNAPSHOT-1601111703114.jar' 

due to conflict in the snapshot release handling policy. Status code: 409

So you'll get the above error, if you were trying publish to (see variable repoKeyValue above)

'MyCustomRepository-Snapshots/com/mycompany/mypackagename1/mypackagename2/'

BECAUSE (and this is the key thing to understand)... there is a disprepency between "com/mycompany/mypackagename1/mypackagename2/" and "com/mycompany/mypackagenameNotQuiteRight999/myPackageNameNotQuiteRight888/"

The above sentence is key-idea to understand to trouble shoot.

Artifactory (when you have publishPom and publishBuildInfo set to true) to checking for that consistency...(as far as I can tell)

Below is more fuller context of the magic attributes. Note, I have a multi module gradle project and I do not want to publish the root project. #monolithsAreHorrible

(below is in my root build.gradle file)

artifactoryPublish.skip = true


artifactory {
    contextUrl = "${artifactory_url}"
    publish {
        repository {
            repoKey = "${repoKeyValue}"

            username = "${artifactory_user}"
            password = "${artifactory_password}"
        }

        defaults {
            publications('myPublicationNameOne', 'myPublicationNameTwo', 'myPublicationNameThree')
            publishArtifacts = true
            publishBuildInfo = true
            publishPom = true
        }
    }
}

Below is one of my module build.gradle files (they all look the same).

I have found the simpler I keep the publication (ex: "myPublicationNameOne"), the more sane I am when I get it all working in a harmonized way.

// the "name" variable inside the publications/myPublicationName block is getting overwritten.  so create a variable here to capture the name (as the artifactid)

def artifactIdForPublicationBlockHolder = "${name}"


dependencies {
    testImplementation group: 'junit', name: 'junit', version: junitVersion
}

println("hey.there.myPublicationNameOne")
println("group=${group}")
println("version=${version}")
println("artifactId=${name}")


publishing {
    publications {
        myPublicationNameOne(MavenPublication) {
            // groupId, artifactId and version have defaults, so do not arbitrarily override : https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:publications
            artifact "./build/libs/${artifactIdForPublicationBlockHolder}-${version}.jar"
        }
    }
}

Bonus Material:

See https://docs.gradle.org/current/dsl/org.gradle.api.publish.maven.MavenPublication.html about the publicationNames (if you are a first time learner, people using keywords for publicationName(s) threw me off for a while)

"gradle.settings" with artifactory:

https://www.jfrog.com/confluence/display/JFROG/Working+with+Gradle#WorkingwithGradle-ConfiguringGradle

timestamp on artifactId

How to add timestamp for artifacts in Jenkins

DEBUG TIP:

Purposely set your target artifactory to:

String repoKeyValue = version.endsWith('SNAPSHOT') ? 'doesnotexist-libs-snapshot-local' : 'doesnotexist-libs-release-local'

(it will fail, but that's ok temporarily)

and try to run the artifactory push locally:

in gradle it is (or could be based on your set up):

./gradlew clean build artifactoryPublish   

This will at least show you what it is trying to "push".

You'll see a failure like this:

[pool-1-thread-1] Deploying artifact: https://somewhere.com/artifactory/MY-Snapshots/com/mycompany/mypackagenameNotQuiteRight999/myPackageNameNotQuiteRight888/1.0-SNAPSHOT/myPackageNameNotQuiteRight888-1.0-SNAPSHOT.jar
Failed to upload file

BUT it shows you what it is trying to "push" and you can harmonize from there.

Related