How to use JFrog CLI to Create, Update, Distribute & Delete Release Bundles

Saleh Samara
2020-03-27 23:50

Introduction

JFrog CLI (version 1.35.1) now supports JFrog Distribution 2.x commands. This post will help you with information on how to use JFrog CLI for your JFrog Distribution workflows.

For a full list of commands and options, please refer to JFrog CLI Wiki Page – Release Bundles.

 

Note: Requires JFrog Distribution version 2.0 or higher.

Configuration

For installation and configuration of JFrog CLI, please refer to the Wiki Page.

JFrog Platform is using the Artifactory (rt) domain for operating Release Bundles and distribution flow. Hence, all CLI commands should be started with rt prefix: 

 

./jfrog rt release-bundle-<command> <params>

Creating a Release Bundle

Distribution Release Bundle Version created as unsigned in order to allow updates to its content before making it final for distribution.

Minimal set of arguments to create release bundle: 

  • Release Bundle Name (30 chars max)

  • Release Bundle Version (30 chars max)

  • Release Bundle Files Spec: Path to a file spec, which describes what artifacts to include in Release Bundle Version. For more information about JFrog CLI File Spec, please refer to Wiki Page.

 

./jfrog rt rbc --spec=/Users/john/RB-spec.json myApp 1.0.0 

Example of Spec File – all files in myAppRepo:

{
  "files": [
    {
      "pattern": "/myAppRepo/"
    }
  ]
}

When creating the Release Bundle Version, it is also possible to finalize it by signing using pre-configured GPG key:

 

./jfrog rt rbc --spec=/Users/john/RB-spec.json --sign=”true” myApp 1.0.0 

 

Or 

 

./jfrog rt rbc --spec=/Users/john/RB-spec.json --sign myApp 1.0.0 

 

Note: once the Release Bundle Version is signed, it is not possible to make any changes.

Updating a Release Bundle 

To update an unsigned Release Bundle Version, it is possible to use release-bundle-update command. The parameters are the same as for release-bundle-create, but it will work only on existing versions of the Release Bundle.

 

./jfrog rt rbu --spec=/Users/john/RB-spec.json myApp 1.0.0 

Signing a Release Bundle

Signing a Release Bundle finalizes the process of creating a Release Bundle. This sets the Release Bundle status to Signed and the Release Bundle can no longer be edited. If the GPG key was created with a passphrase, please provide it as part of the command:

 

./jfrog rt rbs --passphrase="<passphrase>" myApp 1.0.0 

 

Note: The passphrase is optional. Provide GPG key passphrase if you generated the GPG signing keys with a passphrase. 

 

Distributing a release bundle

Once you have created your Release Bundle, you can distribute it to the Artifactory Edge Nodes that you are privileged to distribute to using release-bundle-distribute command. The distribution will happen according to the distribution rules that are provided in rules file (json format):

 

./jfrog rt rbd --dist-rules=/Users/john/distribute-rules.json myApp 1.0.0

 

Example of distribution rules – distribute to all Edge nodes:

 

{
  "dry_run": false,
  "distribution_rules": [
    {
      "site_name": "*",
      "city_name": "*",
      "country_codes": ["*"]
    }
  ]
}

 

Deleting a release bundle

Using release-bundle-delete command, it is possible to delete Release Bundle Version from the Edge Nodes and optionally from JFrog Distribution itself. To delete Release Bundle Version from Edge Nodes:

 

./jfrog rt rbdel --dist-rules=/Users/john/distribute-rules.json myApp 1.0.0

 

To avoid the confirmation message by adding –quiet to the command:

 

./jfrog rt rbdel --quiet --dist-rules=/Users/john/distribute-rules.json myApp 1.0.0

 

In order to delete the Release Bundle Version from the JFrog Distribution itself, add –delete-from-dist parameter: 

 

./jfrog rt rbdel --quiet --dist-rules=/Users/john/distribute-rules.json --delete-from-dist="true" myApp 1.0.0

 

You can also delete the Release Bundle Version from JFrog Distribution only, leaving distributed copies on the Edge nodes (however this is not a recommended scenario):

 

./jfrog rt rbdel --quiet --delete-from-dist="true" myApp 1.0.0

 

TroubleShooting

In order to get more info and verbose messages in command-line, please set the log level to debug as follows:

 

export JFROG_CLI_LOG_LEVEL=DEBUG