Using Artifactory OSS version 4.2.1. My libs-release-local repo is set to only handle releases. As per this scenario whenever somebody tries using gradle to deploy a SNAPSHOT(1.3-SNAPSHOT/sample-war-app-1.3-SNAPSHOT.jar) file into this folder it should throw an error 409 due to its snapshot/release handling policy.but occasionally some of these files are getting deployed into releases. Could somebody explain me how artifactory identifies a release and a snapshot ?
1 Answers
Artifactory uses a regular expression to match your deployment paths to the standard maven repository layout. Assuming that the deployment path of the artifact matches this regex, Artifactory will be able to tokenize the path and work out what each of the path elements represent (i.e the groupId, the artifactId, the version, etc). You can read more about repository layouts here.
The release/snapshot handling capability is built on top of this mechanism because it needs to know whether the version element in the path represents a snapshot version or not (otherwise it's a release version), and subsequently reject or accept the deployment according to the handling policy of the repo.
The default 'maven-2-default' layout that maven repos use (e.g the 'libs-release-local' repo) defines this regular expression for a snapshot identifier:
SNAPSHOT|(?:(?:[0-9]{8}.[0-9]{6})-(?:[0-9]+))
(You can find this in Admin -> Layouts (under Repositories) -> maven-2-default)
So a valid snapshot path can be either:
com/uriahl/myArtifact/1.0-SNAPSHOT/myArtifact-1.0-20161001.084249-1.jar
com/uriahl/myArtifact/1.0-SNAPSHOT/myArtifact-1.0-SNAPSHOT.jar
Otherwise, if the path doesn't correspond to a maven layout Artifactory won't be able to know whether the artifact you are uploading is a snapshot artifact or a release artifact, in which case you may end up with snapshot or release artifacts where they are not supposed to be, but it would also mean that you are deploying them not according to the repository layout.
You can also validate deployment paths if you click on the corresponding layout to edit it and use the "Test Artifact Path Resolution" section. If you are validating a snapshot path and you see that Artifactory can't make out the "File Integration Revision" of the artifact in the given path or that it interprets the path incorrectly, it would be a strong indication that the handling policy feature would also not work properly.