cli

CLI setup

[!NOTE|label:reference:]

  • windows

    # Command Prompt
    > powershell "Start-Process -Wait -Verb RunAs powershell '-NoProfile iwr https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/2.41.1/jfrog-cli-windows-amd64/jf.exe -OutFile $env:USERPROFILE\jf.exe'"
    
    # verify
    > %USERPROFILE%\jf.exe --help
    NAME:
       jf - See https://github.com/jfrog/jfrog-cli for usage instructions.
    
    USAGE:
       jf [global options] command [command options] [arguments...]
    ...
  • homebrew

    $ brew install jfrog-cli
  • centos

    # via curl
    $ curl -fL https://install-cli.jfrog.io | sh
    
    # or
    $ sudo bash -c "cat > /etc/yum.repos.d/jfrog-cli.repo" << EOF
    [jfrog-cli]
    name=jfrog-cli
    baseurl=https://releases.jfrog.io/artifactory/jfrog-rpms
    enabled=1
    EOF
    $ sudo rpm --import https://releases.jfrog.io/artifactory/jfrog-gpg-public/jfrog_public_gpg.key
    $ sudo yum install -y jfrog-cli-v2-jf
  • ubuntu

    [!NOTE|label:references:]

    # via curl
    $ curl -fL https://install-cli.jfrog.io | sh
    
    # via apt
    #                                                                                               dos2unix
    #                                                                                                   v
    $ curl -fsSL https://releases.jfrog.io/artifactory/jfrog-gpg-public/jfrog_public_gpg.key | tr -d '\015' | sudo tee /usr/share/keyrings/jfrog.asc >/dev/null
    $ echo "deb [signed-by=/usr/share/keyrings/jfrog.asc] https://releases.jfrog.io/artifactory/jfrog-debs xenial contrib" > /etc/apt/source.list.d/jfrog.list >/dev/null
    $ sudo apt update -y
    $ sudo apt install jfrog-cli-v2-jf -y
    # deprecated for ubuntu 22.04
    $ 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
    $ sudo apt update
    $ sudo apt install -y jfrog-cli-v2-jf
  • docker

    # slim
    $ docker run releases-docker.jfrog.io/jfrog/jfrog-cli-v2-jf jf -v
    
    # full
    $ docker run releases-docker.jfrog.io/jfrog/jfrog-cli-full-v2-jf jf -v
  • npm

    $ npm install -g jfrog-cli-v2-jf && jf intro
  • npm

    $ npm i -g jfrog-cli-go
  • homebrew

    $ brew install jfrog-cli-go
  • docker

    $ docker run docker.bintray.io/jfrog/jfrog-cli-go:latest jfrog <COMMAND>

completion

  • bash

    $ jf completion bash --install
  • zsh

    $ jf completion zsh --install
  • Oh My Zsh

    plugins=(git mvn npm sdk jfrog)
  • fish

    $ jf completion fish --install

Environment Variables

VARIABLE NAMEDEFAULTSUPPORTED

JFROG_CLI_LOG_LEVEL

INFO

DEBUG, INFO, WARN, ERROR

JFROG_CLI_LOG_TIMESTAMP

TIME

TIME, DATE_AND_TIME, OFF

JFROG_CLI_HOME_DIR

~/.jfrog

-

JFROG_CLI_TEMP_DIR

-

-

JFROG_CLI_PLUGINS_SERVER

-

-

JFROG_CLI_PLUGINS_REPO

jfrog-cli-plugins

-

JFROG_CLI_RELEASES_REPO

-

-

JFROG_CLI_SERVER_ID

-

-

CI

false

-

CLI

VARIABLE NAMEDEFAULT

JFROG_CLI_MIN_CHECKSUM_DEPLOY_SIZE_KB

10

JFROG_CLI_RELEASES_REPO

-

JFROG_CLI_DEPENDENCIES_DIR

$JFROG_CLI_HOME_DIR/dependencies

JFROG_CLI_REPORT_USAGE

true

JFROG_CLI_SERVER_ID

-

JFROG_CLI_BUILD_NAME

-

JFROG_CLI_BUILD_NUMBER

-

JFROG_CLI_BUILD_PROJECT

-

JFROG_CLI_BUILD_URL

-

JFROG_CLI_ENV_EXCLUDE

*password*;*secret*;*key*;*token*

JFROG_CLI_TRANSITIVE_DOWNLOAD_EXPERIMENTAL

false

CLI

reference:

ABBREVIATIONCOMMANDS

atc

access-token-create

bad

build-add-dependencies

bag

build-add-git

ba

build-append

bc

build-clean

bce

build-collect-env

bdi

build-discard

bdc

build-docker-create

bpr

build-promote

bp

build-publish

bs

build-scan

cp

copy

cl

curl

del

delete

delp

delete-props

dpr

docker-promote

dpl

docker-pull

dp

docker-push

donet

dotnet

dotnetc

dotnet-config

dl

download

glc

git-lfs-clean

go

go

-

go-config

gp

go-publish

-

gradle

gradlec

gradle-config

gau

group-add-users

gc

group-create

gdel

group-delete

h

help

mv

move

mvn

mvn

mvnc

mvn-config

npmci

npm-ci

npmc

npm-config

npmi

npm-install

npmp

npm-publish

nuget

nuget

nugetc

nuget-config

ndt

nuget-deps-tree

osb

oc

ptc

permission-target-create

ptdel

permission-target-delete

ptt

permission-target-template

ptu

permission-target-update

p

ping

pipc

pip-config

pipi

pip-install

ppl

podman-pull

pp

podman-push

rplc

replication-create

rpldel

replication-delete

rplt

replication-template

rc

repo-create

rdel

repo-delete

rpt

repo-template

ru

repo-update

s

search

sp

set-props

-

transfer-config

-

transfer-config-merge

-

transfer-files

-

transfer-plugin-install

-

transfer-settings

u

upload

-

user-create

uc

users-create

udel

users-delete

yarn

yarn

yarnc

yarn-config

configuration

  • via ssh

    $ jf c add --url=ssh://artifactory.example.com:1339 \
               --ssh-key-path=/Users/marslo/.ssh/id_rsa \
               sample
    
    $ jf c show sample
    Server ID:              sample
    JFrog Platform URL:     ssh://artifactory.example.com:1339/
    Artifactory URL:        ssh://artifactory.example.com:1339/
    SSH key file path:      /Users/marslo/.ssh/id_rsa
    Default:                true
  • via password/api key

    $ jf c add --serverId rt-api-key \
               --artifactory-url=https://artifactory.sample.com/artifactory \
               --user=marslo \
               --password=A***********************************************************************x \
               --insecure-tls \
               --interactive=false
    $ jfrog rt c sample --url=https://artifactory.example.com/artifactory --apikey=***********
    JFrog Distribution URL (Optional):
    For commands which don't use external tools or the JFrog Distribution service, JFrog CLI supports replacing the configured username and password/API key with automatically created access token that's refreshed hourly. Enable this setting? (y/n) [y]? n
    Is the Artifactory reverse proxy configured to accept a client certificate? (y/n) [n]? n
    
    $ jfrog rt c show
    Server ID:  sample
    Url:        https://artifactory.example.com/artifactory/
    API key:    ***************
    Default:    true
    • via username/password

      $ jfrog rt c sample --user=myaccount \
                          --url=https://artifactory.example.com/artifactory \
                          --password=mypassword
      JFrog Distribution URL (Optional):
      For commands which don't use external tools or the JFrog Distribution service, JFrog CLI supports replacing the configured username and password/API key with automatically created access token that's refreshed hourly. Enable this setting? (y/n) [y]? n
      Is the Artifactory reverse proxy configured to accept a client certificate? (y/n) [n]? n
      [Info] Encrypting password...
  • access token

    $ jf c add --serverId sample
               --artifactory-url=https://artifactory.sample.com/artifactory \
               --user=marslo \
               --access-token=c**************************************************************Q \
               --interactive=false \
               --insecure-tls
  • in docker

    $ docker run -it \
                 --rm \
                 -v $(PWD):/root docker.bintray.io/jfrog/jfrog-cli-go \
                 jfrog rt c prod \
                          --url=https://artifactory.example.com/artifactory \
                          --user=myaccount \
                          --password=mypassword

set default

$ jf rt use <SERVER_ID>

ping

  • check configuration or remote server

    $ jf rt p
    OK
    
    # or
    $ jfrog rt p --server-id=sample
    OK

discarding old builds from artifactory

  • clean build info and artifacts 30 days before

    $ jf use <sample>
    $ jfrog rt bdi --max-days=30 --delete-artifacts=true "my-job-build"
    $ jfrog rt use sample
    $ jfrog rt bdi --max-days=30 --delete-artifacts=true "my-job-build"
  • using cli via docker

    $ docker run \
             -it \
             --rm \
             -v $(PWD):/root docker.bintray.io/jfrog/jfrog-cli-go \
                       jfrog rt bdi --max-days=45 --delete-artifacts 'ci - buildinfo - name'

search with aql

[!NOTE|label:references:]

$ cat spec.json
{
  "files": [{
    "aql": {
      "items.find": {
        "repo": "my-repo",
        "type":"folder",
        "depth" : "1",
        "created": { "$before": "15d" }
      }
    }
  }]
}

$ jfrog rt s --spec spec.json
  • delete with aql search

    $ jfrog rt del --spec spec.json

delete docker images

#              registry name  image name    tag
#              +-----------+ +-----------+ +---+
$ jf rt delete docker-local/devops/ubuntu/4.0.0**
  docker-local/devops/ubuntu/4.0.0-py310-jammy-dind-v95-94d13a3db/
  docker-local/devops/ubuntu/4.0.0-py310-jammy-dind/
  docker-local/devops/ubuntu/4.0.0-py310-jammy/
Are you sure you want to delete the above paths? (y/n) [n]? y
{
  "status": "success",
  "totals": {
    "success": 3,
    "failure": 0
  }
}

# or remote all v4.0.0* tags via
$ jf rt delete docker-local/devops/*/4.0.0**
  docker-local/devops/clang/4.0.0-py310-jammy-dind-v95-94d13a3db/
  docker-local/devops/clang/4.0.0-py310-jammy-dind/
  docker-local/devops/clang/4.0.0-py310-jammy-v95-94d13a3db/
  docker-local/devops/clang/4.0.0-py310-jammy/
  docker-local/devops/doxygen/4.0.0-py310-jammy-dind-v95-94d13a3db/
  docker-local/devops/doxygen/4.0.0-py310-jammy-dind/
  docker-local/devops/doxygen/4.0.0-py310-jammy-v95-94d13a3db/
  docker-local/devops/doxygen/4.0.0-py310-jammy/
  docker-local/devops/jnlp/4.0.0-py310-jammy-dind-v95-94d13a3db/
  docker-local/devops/jnlp/4.0.0-py310-jammy-dind/
  docker-local/devops/jnlp/4.0.0-py310-jammy-v95-94d13a3db/
  docker-local/devops/jnlp/4.0.0-py310-jammy/
Are you sure you want to delete the above paths? (y/n) [n]?

[!NOTE|label:references:]

$ jf rt docker-promote hello-world default-docker-local stef-docker-local \
                       --source-tag=1.0.0 \
                       --target-docker-image=hello-world \
                       --target-tag=prod

Last updated