Salto CLI
Support avatar
Written by Support
Updated over a week ago

The Salto CLI allows to trigger various Salto operations from the command line.
Specifically, it supports various deployment related commands, thus opening the door for automated deployments, validations and CI/CD integration with Salto.

Setup

Installing the Salto CLI

The Salto CLI can be downloaded from the following locations:

> curl https://cli.salto.io/release/1/linux-x64.tar.gz --output linux-x64.tar.gz
> tar xvzf linux-x64.tar.gz
> curl https://cli.salto.io/release/1/macos-x64.tar.gz --output macos-x64.tar.gz
> tar xvzf macos-x64.tar.gz

The CLI executable can be stored in a location of your choice, however it’s recommended to store it in a directory which is under the system path. Otherwise, executing Salto CLI commands will require specifying the exact location of the executable.

Authenticating via the Salto CLI

In order to authenticate via the Salto CLI you will need to generate a Salto API token and then make sure to store it as the value of an OS environment variable named API_TOKEN. For Linux or MacOS you can simply execute export SALTO_API_TOKEN=<Your API Token> before running CLI commands.

Generating an API Token for Salto

  1. In the Salto app, navigate to your user setting by clicking on your avatar in the bottom left corner and then click on the ‘settings’ menu item

  2. Click on ‘Generate’ under the ‘API Token’ section

  3. Re-Authenticate against Salto

  4. Copy the newly generated token to the clipboard and keep it in a safe place

CLI Interface

Managing Deployments

CLI commands under the deployment section allow the user to manage Salto deployments from the command line.
A certain Salto deployment can be identified in 2 ways:

  1. Deployment id - when viewing a deployment in Salto, its id can be copied from the URL in the browser's address bar.
    https://app.salto.io/orgs/<org-id>/envs/<env-id>/deployments/<deployment-id>

  2. PR's source branch name - in case the deployment has a PR attached to it

Deploy Command

Deploy the changes specified in a Salto deployment record

./salto-cloud deployment deploy [options]

Usage: salto-cloud deployment deploy [options]

Deploy the changes specified in a deployment record

Options:
-i, --deployment-id <string> Id of the deployment to deploy
-b, --branch-name <string> Identify deployment by attached PR details
-t, --api-token [string] API token can be generate in Salto, you can provide it here or through environment
variable "API_TOKEN"
-v, --verbose Output extra logs
-h, --help display help for command

Validate Command (Salesforce only)

Validate the changes specified in a deployment record

./salto-cloud deployment deploy [options]

Usage: salto-cloud deployment validate [options]

Validate the changes specified in a deployment record (salesforce only)

Options:
-C, --config [string...] Validation config params (format: <service>.<path>=<value>)
-i, --deployment-id <string> Id of the deployment to deploy
-b, --branch-name <string> Identify deployment by attached PR details
-t, --api-token [string] API token can be generate in Salto, you can provide it here or through environment
variable "API_TOKEN"
-v, --verbose Output extra logs
-h, --help display help for command

Plan Command

Print the deployment plan

./salto-cloud deployment plan [options]

Usage: salto-cloud deployment plan [options]

Print deployment plan

Options:
-w, --allow-warnings Do not consider a plan with warnings as failed
-i, --deployment-id <string> Id of the deployment to deploy
-b, --branch-name <string> Identify deployment by attached PR details
-t, --api-token [string] API token can be generate in Salto, you can provide it here or through environment
variable "API_TOKEN"
-v, --verbose Output extra logs
-h, --help display help for command

Status Command

Print the deployment status

./salto-cloud deployment status [options]

Usage: salto-cloud deployment status [options]

Print deployment status

Options:
-i, --deployment-id <string> Id of the deployment to deploy
-b, --branch-name <string> Identify deployment by attached PR details
-t, --api-token [string] API token can be generate in Salto, you can provide it here or through environment
variable "API_TOKEN"
-v, --verbose Output extra logs
-h, --help display help for command

Generic Flags

  • -V, --version output the version number

  • -h, --help display help for command

Return Codes

  • 0 - Successful execution

  • 1 - Authentication / Authorization problem

  • 2 - Bad input, e.g. missing params, invalid param value etc

  • 3 - Negative operation result, e.g. broken deploy plan, failed to deploy etc

  • 4 - Internal Salto error

Did this answer your question?