Skip to main content
Salto CLI
Support avatar
Written by Support
Updated over 4 months ago

This article is about the Salto Cloud CLI

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 SALTO_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 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"
-p, --push Push deployed elements to git
-o, --deploy-on-behalf Deploy on behalf of the deployment owner
-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 validate [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

Preview Command

Print the deployment preview

./salto-cloud deployment preview [options]

Usage: salto-cloud deployment preview [options]

Print deployment preview

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"
-w, --allow-warnings Do not consider a plan with warnings as failed
-v, --verbose Output extra logs
-h, --help display help for command

Create Commands

From Other Salto Deployments

./salto-cloud deployment create from-deployments [options]

Usage: salto-cloud deployment create from-deployments [options]
Create a new deployment representing the changes that were deployed in the specified deployments.
All specified deployments must target the same environment.

Options:
-e, --target-env [string] The name of the target env
-E, --target-env-id [string] The id of the target env
-i, --deployment-ids [string...] Array of deployment ids
-b, --branch-names [string...] Identify deployment by attached PR details
-n, --deployment-name [string] Name of the new deployment
-a, --include-all-fixes [boolean] Auto include parent and all fixes
-t, --api-token [string] API token can be generate in Salto, you can provide it here or through environment variable "SALTO_API_TOKEN"
-v, --verbose Output extra logs
-h, --help display help for command

From SFDX/SDF Pull Request

./salto-cloud deployment create from-pull-request [options]

Usage: salto-cloud deployment create from-pull-request [options]
Create a new deployment from an SFDX/SDF repository pull request

Options:
-e, --target-env [string] The name of the target env
-E, --target-env-id [string] The id of the target env
-u, --pr-url <string> SFDX/SDF repository pull request URL
-a, --account [string] Target netsuite/salesforce account name
-t, --api-token [string] API token can be generate in Salto, you can provide it here or through environment variable "SALTO_API_TOKEN"
-v, --verbose Output extra logs
-h, --help display help for command

Update Commands

From SFDX/SDF Pull Request

./salto-cloud deployment update from-pull-request [options]

Usage: salto-cloud deployment update from-pull-request [options]
Update a deployment from its source SFDX/SDF pull request

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 "SALTO_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?