deploy Commands
deploy
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 deployReprompt for all deployment inputs:
1sf deploy --interactiveUsage
- 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
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/sourceDeploy 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/objects1sf deploy metadata --source-dir path/to/apex/classes/MyClass.cls --source-dir path/to/source/objectsDeploy all Apex classes:
1sf deploy metadata --metadata ApexClassDeploy a specific Apex class:
1sf deploy metadata --metadata ApexClass:MyApexClassDeploy all custom objects and Apex classes (both examples are equivalent):
1sf deploy metadata --metadata CustomObject ApexClass1sf deploy metadata --metadata CustomObject --metadata ApexClassDeploy 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.xmlRun the tests that aren’t in any managed packages as part of a deployment:
1sf deploy metadata --metadata ApexClass --test-level RunLocalTestsUsage
- sf deploy metadata
- [--json]
- [-m METADATA]
- [-x MANIFEST]
- [-d SOURCE-DIR]
- [-o TARGET-ORG]
- [-l TEST-LEVEL]
- [-w WAIT]
Flags
- --json
- Optional
-
Format output as json.
- Type: boolean
- -m | --metadata METADATA
- Optional
-
Metadata component names to deploy.
- Type: option
- -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
- -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
- -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 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
- -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