Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Artifactory upload with checksum

Tags:

If you upload an artifact to Artifactory and don't provide a checksum, it gives this warning:

Screenshot, Artifactory, Fix Checksum

How do you upload with curl and include a checksum?

like image 390
spuder Avatar asked Oct 12 '16 22:10

spuder


People also ask

What is checksum in Artifactory?

Checksum-Based Storage Overview Artifactory uniquely stores artifacts using checksum-based storage. A file that is uploaded to Artifactory, first has its SHA1 checksum calculated, and is then renamed to its checksum.

What are the advantages of checksum-based storage in Artifactory?

The benefits of checksum-based storage are unquestionable. From vastly improved performance when accessing binaries through significant reduction in filestore usage volume to support for any packaging format that may emerge on the market, checksum-based storage is a significant factor in optimizing your CI/CD workflow.

How do I Upload artifacts to JFrog Artifactory?

Go to the artifact browser, select the repository you want to upload to, and hit the Set Me Up button for instructions. You can upload a file using Artifactory UI. Go to the artifact browser, select the repository you want to upload to, and hit the Upload button for instructions.


1 Answers

This feature currently isn't well documented, an example is found on this page:

https://www.jfrog.com/knowledge-base/what-are-client-checksum-server-checksum-and-checksum-policy-in-local-repositories/

Simply add the following to the curl command: "--header "X-Checksum-<type>:${CHECKSUM}"

Sha1

CHECKSUM=$(shasum -a 1 foo.zip | awk '{ print $1 }')  curl --header "X-Checksum-Sha1:${CHECKSUM}" --upload-file "foo.zip -u "admin:<apikey>" -v https://artifactory.example.com/foo/ 

MD5

CHECKSUM=$(md5sum foo.zip | awk '{ print $1 }')  curl --header "X-Checksum-MD5:${CHECKSUM}" --upload-file "foo.zip -u "admin:<apikey>" -v https://artifactory.example.com/foo/ 

Or provide both checksums at once

ARTIFACT_MD5_CHECKSUM=$(md5sum foo.zip | awk '{print $1}') ARTIFACT_SHA1_CHECKSUM=$(shasum -a 1 foo.zip | awk '{ print $1 }') curl --upload-file "foo.zip" \ --header "X-Checksum-MD5:${ARTIFACT_MD5_CHECKSUM}" \ --header "X-Checksum-Sha1:${ARTIFACT_SHA1_CHECKSUM}" \ -u "admin:<apikey>" \ -v https://artifactory.example.com/foo/ 

Unfortunatley, uploading with the sha256 doesn't work with curl because of a bug

like image 130
spuder Avatar answered Sep 21 '22 11:09

spuder