deploy Commands

Commands to deploy artifacts to an environment.

deploy

Deploy a project interactively to any Salesforce environment.

Description for deploy

This command must be run from within a project.

The command first analyzes your project, your active or logged-into environments, and local defaults to determine what to deploy and where to deploy it. The command then prompts you for information about this particular deployment and provides intelligent choices based on its analysis.

For example, if your local project contains a source directory with metadata files in source format, the command asks if you want to deploy that Salesforce app to an org. The command lists your connected orgs and asks which one you want to deploy to. The list of orgs starts with scratch orgs, ordered by expiration date with the most recently created one first, and then Dev Hub and production orgs ordered by name. If the command finds Apex tests, it asks if you want to run them and at which level.

The command stores your responses in the "deploy-options.json" file in your local project directory and uses them as defaults when you rerun the command. Specify --interactive to force the command to reprompt.

Use this command for quick and simple deploys. For more complicated deployments, use the environment-specific commands, such as "sf deploy metadata", that provide additional flags.

Examples for deploy

Deploy a project and use stored values from a previous command run:

1sf deploy

Reprompt for all deployment inputs:

1sf deploy --interactive

Usage

sf deploy
[--interactive]

Flags

--interactive
Optional

Force the CLI to prompt for all deployment inputs.

Type: boolean

deploy functions

Usage

sf deploy functions
-o CONNECTED-ORG
[-b BRANCH]
[--force]
[-q]

Flags

-o | --connected-org CONNECTED-ORG
Required

Username or alias for the org that the compute environment should be connected to.

Type: option
-b | --branch BRANCH
Optional

Deploy the latest commit from a branch different from the currently active branch.

Type: option
--force
Optional

Ignore warnings and overwrite remote repository (not allowed in production).

Type: boolean
-q | --quiet
Optional

Limit the amount of output displayed from the deploy process.

Type: boolean

deploy metadata (Beta)

Deploy metadata in source format to an org from your local project.

This feature is a Beta Service. Customers may opt to try such Beta Service in its sole discretion. Any use of the Beta Service is subject to the applicable Beta Services Terms provided at Agreements and Terms (https://www.salesforce.com/company/legal/agreements/).

Note

Description for deploy metadata

You must run this command from within a project.

This command doesn't support source-tracking. The source you deploy overwrites the corresponding metadata in your org. This command doesn’t attempt to merge your source with the versions in your org.

To run the command asynchronously, set --wait to 0, which immediately returns the job ID. This way, you can continue to use the CLI.

To deploy multiple metadata components, either set multiple --metadata <name> flags or a single --metadata flag with multiple names separated by spaces. Enclose names that contain spaces in one set of double quotes. The same syntax applies to --manifest and --source-dir.

Examples for deploy metadata

Deploy the source files in a directory:

1sf deploy metadata  --source-dir path/to/source

Deploy a specific Apex class and the objects whose source is in a directory (both examples are equivalent):

1sf deploy metadata --source-dir path/to/apex/classes/MyClass.cls path/to/source/objects
1sf deploy metadata --source-dir path/to/apex/classes/MyClass.cls --source-dir path/to/source/objects

Deploy all Apex classes:

1sf deploy metadata --metadata ApexClass

Deploy a specific Apex class:

1sf deploy metadata --metadata ApexClass:MyApexClass

Deploy all custom objects and Apex classes (both examples are equivalent):

1sf deploy metadata --metadata CustomObject ApexClass
1sf deploy metadata --metadata CustomObject --metadata ApexClass

Deploy all Apex classes and a profile that has a space in its name:

1sf deploy metadata --metadata ApexClass --metadata "Profile:My Profile"

Deploy all components listed in a manifest:

1sf deploy metadata --manifest path/to/package.xml

Run the tests that aren’t in any managed packages as part of a deployment:

1sf deploy metadata --metadata ApexClass --test-level RunLocalTests

Usage

sf deploy metadata
[--json]
[-a API-VERSION]
[--dry-run]
[-r]
[-g]
[-x MANIFEST]
[-m METADATA]
[-d SOURCE-DIR]
[-o TARGET-ORG]
[-t TESTS]
[-l TEST-LEVEL]
[--verbose]
[-w WAIT]

Flags

--json
Optional

Format output as json.

Type: boolean
-a | --api-version API-VERSION
Optional

Target API version for the deploy.

Use this flag to override the default API version, which is the latest version supported the CLI, with the API version of your package.xml file.

Type: option
--dry-run
Optional

Validate deploy and run Apex tests but don’t save to the org.

Type: boolean
-r | --ignore-errors
Optional

Ignore any errors and don’t roll back deployment.

When deploying to a production org, keep this flag set to false (default value). When set to true, components without errors are deployed and components with errors are skipped, and could result in an inconsistent production org.

Type: boolean
-g | --ignore-warnings
Optional

Ignore warnings and allow a deployment to complete successfully.

If a warning occurs and this flag is set to true, the success status of the deployment is set to true. When this flag is set to false, success is set to false, and the warning is treated like an error.

Type: boolean
-x | --manifest MANIFEST
Optional

Full file path for manifest (package.xml) of components to deploy.

All child components are included. If you specify this flag, don’t specify --metadata or --source-dir.

Type: option
-m | --metadata METADATA
Optional

Metadata component names to deploy.

Type: option
-d | --source-dir SOURCE-DIR
Optional

Path to the local source files to deploy.

The supplied path can be to a single file (in which case the operation is applied to only one file) or to a folder (in which case the operation is applied to all metadata types in the directory and its subdirectories).

If you specify this flag, don’t specify --metadata or --manifest.

Type: option
-o | --target-org TARGET-ORG
Optional

Login username or alias for the target org.

Overrides your default org.

Type: option
-t | --tests TESTS
Optional

Apex tests to run when --test-level is RunSpecifiedTests.

Separate multiple test names with commas, and enclose the entire flag value in double quotes if a test contains a space.

Type: option
-l | --test-level TEST-LEVEL
Optional

Deployment Apex testing level.

Valid values are:

- NoTestRun — No tests are run. This test level applies only to deployments to development environments, such as sandbox, Developer Edition, or trial orgs. This test level is the default for development environments.

- RunSpecifiedTests — Runs only the tests that you specify with the --run-tests flag. Code coverage requirements differ from the default coverage requirements when using this test level. Executed tests must comprise a minimum of 75% code coverage for each class and trigger in the deployment package. This coverage is computed for each class and trigger individually and is different than the overall coverage percentage.

- RunLocalTests — All tests in your org are run, except the ones that originate from installed managed and unlocked packages. This test level is the default for production deployments that include Apex classes or triggers.

- RunAllTestsInOrg — All tests in your org are run, including tests of managed packages.

If you don’t specify a test level, the default behavior depends on the contents of your deployment package. For more information, see [Running Tests in a Deployment](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_deploy_running_tests.htm) in the "Metadata API Developer Guide".

Type: option
Permissible values are: NoTestRun, RunSpecifiedTests, RunLocalTests, RunAllTestsInOrg
Default value: NoTestRun
--verbose
Optional

Show verbose output of the deploy result.

Type: boolean
-w | --wait WAIT
Optional

Number of minutes to wait for command to complete and display results.

If the command continues to run after the wait period, the CLI returns control of the terminal window to you.

Type: option
Default value: 33 minutes