Artifactory: Difference between revisions
Jump to navigation
Jump to search
| Line 138: | Line 138: | ||
-H "Content-Type: application/x-www-form-urlencoded" \ | -H "Content-Type: application/x-www-form-urlencoded" \ | ||
-d "grant_type=refresh_token" \ | -d "grant_type=refresh_token" \ | ||
-d "refresh_token=${REFRESH_TOKEN}" | |||
</pre> | |||
If you want to include a reference token: | |||
-d "include_reference_token=true" \ | |||
<pre> | |||
curl -v \ | |||
-X POST \ | |||
"https://artifactory.sandisk.com/access/api/v1/tokens" \ | |||
-H "Authorization: Bearer ${ACCESS_TOKEN}" \ | |||
-H "Content-Type: application/x-www-form-urlencoded" \ | |||
-d "grant_type=refresh_token" \ | |||
-d "include_reference_token=true" \ | |||
-d "refresh_token=${REFRESH_TOKEN}" | -d "refresh_token=${REFRESH_TOKEN}" | ||
</pre> | </pre> | ||
Revision as of 17:17, 23 July 2026
jfrog cli
Installation - https://jfrog.com/getcli/
Debian/Ubuntu:
# Create the keyrings directory if it doesn't exist sudo mkdir -p /usr/share/keyrings;
# Download and save the JFrog GPG key to a keyring file wget -qO - https://releases.jfrog.io/artifactory/api/v2/repositories/jfrog-debs/keyPairs/primary/public | sudo gpg --dearmor -o /usr/share/keyrings/jfrog.gpg
# Add the JFrog repository to your APT sources with the signed-by option echo "deb [signed-by=/usr/share/keyrings/jfrog.gpg] https://releases.jfrog.io/artifactory/jfrog-debs focal contrib" | sudo tee /etc/apt/sources.list.d/jfrog.list
# Update the package list sudo apt update
# Install the JFrog CLI sudo apt install -y jfrog-cli-v2-jf
# Run the JFrog CLI intro command jf intro
OLD: # wget -qO - https://releases.jfrog.io/artifactory/jfrog-gpg-public/jfrog_public_gpg.key | sudo apt-key add - # # echo "deb https://releases.jfrog.io/artifactory/jfrog-debs xenial contrib" | sudo tee -a /etc/apt/sources.list.d/jfrog.list && sudo apt update # echo "deb https://releases.jfrog.io/artifactory/jfrog-debs noble contrib" | sudo tee -a /etc/apt/sources.list.d/jfrog.list && sudo apt update # sudo apt install -y jfrog-cli-v2-jf # jf intro
Redhat:
# Create and configure the JFrog CLI YUM repository echo "[jfrog-cli]" > jfrog-cli.repo && echo "name=JFrog CLI" >> jfrog-cli.repo && echo "baseurl=https://releases.jfrog.io/artifactory/jfrog-rpms" >> jfrog-cli.repo && echo "enabled=1" >> jfrog-cli.repo && echo "gpgcheck=1" >> jfrog-cli.repo &&
# Import GPG keys for verifying packages # Note: Two keys are imported for backward compatibility with older versions rpm --import https://releases.jfrog.io/artifactory/api/v2/repositories/jfrog-rpms/keyPairs/primary/public && rpm --import https://releases.jfrog.io/artifactory/api/v2/repositories/jfrog-rpms/keyPairs/secondary/public &&
# Move the repository file to the YUM configuration directory sudo mv jfrog-cli.repo /etc/yum.repos.d/ &&
# Install the JFrog CLI package yum install -y jfrog-cli-v2-jf &&
# Display an introductory message for JFrog CLI jf intro
Artifactory JFrog Client Commands
Ping server
jf rt ping ok
Show config
jf c s # jf config show
Add artifactory
jf c add # jf config add
server id: simple name
url: http://artifactory.example.com/
save and continue (assuming the urls are correct)
username: your username
pass/api: your password or api key
reverse proxy? likely no
jf c add ... CI=true jf c add sandisk --url [url] --artifactory-url [url]/artifactory CI=true jf c add sandisk --url https://artifactory.example.com/ --artifactory-url https://artifactory.example.com/artifactory
Search file
jf rt s [repo/pattern] # pattern can use wild cards
Example:
# jf rt s myrepo/test/BUILD_NUMBER
13:42:58 [🔵Info] Searching artifacts...
13:42:58 [🔵Info] Found 1 artifact.
[
{
"path": "myrepo/test/BUILD_NUMBER",
"type": "file",
"size": 38,
"created": "2023-07-26T18:25:55.912Z",
"modified": "2023-07-28T00:32:13.868Z",
"sha1": "b43cda47086846025ca5aaa6256372bc2550xxxx",
"sha256": "62cce4682d3700b62d5dba0a098b65af928149576f614c51f5c7a03b99xxxxx",
"md5": "bd11639e2c9022ce8ab12d1eda61xxx"
}
]
Access Token Creation
jf access-token-create jf atc
Create a token that expires in 90 days:
jf atc --expiry=7776000 --description="CLI token"
Create a refreshable token:
jf atc --refreshable=true jf atc --refreshable
Return a reference token as well:
jf atc --reference=true jf atc --reference
Create a 90 day refreshable token with short reference token:
jf atc --expiry=7776000 --description="CLI token" --refreshable --reference
Example:
{
"scope": "applied-permissions/user",
"access_token": "eyJ....xxx_REALLY_REALLY_LONG_TOKEN_xxx",
"expires_in": 7776000,
"token_type": "Bearer",
"refresh_token": "59372fb0-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"reference_token": "cmVxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"token_id": "f28a7682-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
Refresh refreshable access token:
ACCESS_TOKEN="access_token content"
REFRESH_TOKEN="refresh_token content"
curl -v \
-X POST \
"https://artifactory.sandisk.com/access/api/v1/tokens" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=refresh_token" \
-d "refresh_token=${REFRESH_TOKEN}"
If you want to include a reference token:
-d "include_reference_token=true" \
curl -v \
-X POST \
"https://artifactory.sandisk.com/access/api/v1/tokens" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=refresh_token" \
-d "include_reference_token=true" \
-d "refresh_token=${REFRESH_TOKEN}"
API
Test Connection
GET /api/v1/system/ping
curl -X GET "http://ARTIFACTORY_SERVER_HOSTNAME:8082/distribution/api/v1/system/ping"
Ref: https://jfrog.com/help/r/jfrog-rest-apis/test-connection
Get System Info
GET /api/v1/system/info
curl -u myUser:myP455w0rd! -X GET "http://ARTIFACTORY_SERVER_HOSTNAME:8082/distribution/api/v1/system/info"
ref: https://jfrog.com/help/r/jfrog-rest-apis/get-system-info