13cr
13cr

Reputation: 41

Check for path existence in Artifactory through Jenkins

I have a Jenkins job that uploads multiple files to Artifactory and I'd like it to check for each file's path before actual upload with the following observations:

Do you have any idea how should I implement this? Any idea/approach will help.

Thanks!!

Upvotes: 1

Views: 560

Answers (1)

yahavi
yahavi

Reputation: 6043

The flow you mentioned is already implemented in the Jenkins Artifactory plugin. The plugin has an internal checksum-based upload optimization. This feature is supported out of the box and already enabled in all generic upload job types:

Scripted Pipeline, Declarative Pipeline and Freestyle job Generic upload.

Before uploading a file using one of the above methods, the Jenkins Artifactory plugin:

  1. Calculates the checksum of the file.
  2. Sends a PUT request to Artifactory with the checksum, but without the content of the file.

If the empty PUT request returned 200 - the new path is added to the artifact in Artifactory, so we don't have to upload it again.

If the empty PUT request returned 404 - we do a regular file upload.

This feature does not related to the target path of the file in Artifactory. Even if you see the file in other path, it is enough to skip uploading it again.

Upvotes: 3

Related Questions