JFrog’s Artifactory is a binary repository manager.
The artifacts to Artifactory can be uploaded (deployed) using REST API.
In this note i am showing how to upload an artifact (simple file.zip
) to generic Artifactory repository using curl
command from the command line in Linux or from the PowerShell in Windows.
Cool Tip: Download an Artifact from Artifactory using cURL! Read more →
Upload Artifact to Artifactory
cURL in Linux
Upload a file to generic Artifactory repository using the curl
command in Linux.
Basic authentication using username and password or username and API Key:
$ curl -sSf -u "<USERNAME>:<PASSWORD>" \ -X PUT \ -T file.zip \ 'http(s)://<ARTIFACTORY_URL>/<REPO>/<PATH>/file.zip'
Upload a file to Artifactory with properties (metadata):
$ curl -sSf -u "<USERNAME>:<PASSWORD>" \ -X PUT \ -T file.zip \ 'http(s)://<ARTIFACTORY_URL>/<REPO>/<PATH>/file.zip;released=true;build.number=1.0'
Authentication using API Key in HTTP header:
$ curl -sSf -H "X-JFrog-Art-Api:<API_KEY>" \ -X PUT \ -T file.zip \ 'http(s)://<ARTIFACTORY_URL>/<REPO>/<PATH>/file.zip'
Upload a file to Artifactory with properties (metadata):
$ curl -sSf -H "X-JFrog-Art-Api:<API_KEY>" \ -X PUT \ -T file.zip \ 'http(s)://<ARTIFACTORY_URL>/<REPO>/<PATH>/file.zip;released=true;build.number=1.0'
Option | Description |
---|---|
-s, --silent |
Don’t show progress meter or error messages |
-S, --show-error |
When used with -s, --silent , it makes curl show an error message if it fails |
-f, --fail |
Return an error if HTTP status code is not 200 |
-H, --header <header> |
Extra HTTP header to include in the request |
-u, --user <username:password> |
Specify the username and password to use for server authentication |
-X, --request PUT |
Send PUT request |
-T, --upload-file <file> |
Specify the local file to transfer to the remote URL |
cURL in Windows PowerShell
Wget & cURL: The curl
and wget
commands in PowerShell are the aliases of the Invoke-WebRequest
command.
Hide the progress of Invoke-WebRequest
to increase upload speed:
PS C:\> $progresspreference = 'silentlyContinue'
Upload a file to generic Artifactory repository using Windows PowerShell (authentication using API Key in HTTP header):
PS C:\> curl -H @{'X-JFrog-Art-Api' = '<API_KEY>'} -method PUT -InFile 'C:\file.zip' 'http(s)://<ARTIFACTORY_URL>/<REPO>/<PATH>/file.zip'
Upload a file to Artifactory with properties (metadata):
PS C:\> curl -H @{'X-JFrog-Art-Api' = '<API_KEY>'} -method PUT -InFile 'C:\file.zip' 'http(s)://<ARTIFACTORY_URL>/<REPO>/<PATH>/file.zip;released=true;build.number=1.0'
Option | Description |
---|---|
-H, -Header <header> |
Specify the headers of the web request |
-method PUT |
Send PUT request |
-I, -InFile <file> |
Specify the file to transfer |
Resume display of the progress bar:
PS C:\> $progressPreference = 'Continue'
Cool Tip: Download a file using PowerShell! Read more →