sfdk-apply
Apply desired state configuration to a system
TLDR
Apply all patches
Reverse apply all patches
SYNOPSIS
sfdk-apply --source-dir PATH --target-org ALIAS_OR_ID [OPTIONS]
PARAMETERS
--source-dir PATH
The path to the local directory containing Salesforce metadata or source code to deploy.
--target-org ALIAS_OR_ID
The alias or ID of the Salesforce org to deploy the changes to. This org must be authenticated in your SFDK environment.
--check-only
Performs a validation deployment without actually saving any changes to the target org. Useful for pre-deployment checks.
--dry-run
Simulates the deployment process, showing what would happen without committing any changes. Similar to --check-only but might have subtle differences depending on the SFDK version.
--api-version VERSION
Specifies the Salesforce API version to use for the deployment. Defaults to the latest supported version.
--wait MINUTES
The number of minutes to wait for the deployment operation to complete. Defaults to a reasonable timeout.
--json
Outputs the command results in JSON format, useful for scripting and automation.
--verbose
Displays more detailed output during the deployment process, including progress and potential warnings.
--quiet
Suppresses all command output except for critical errors, useful for silent operations in scripts.
--help, -h
Displays help information and usage details for the sfdk-apply command.
DESCRIPTION
The `sfdk-apply` command is a crucial utility within the Salesforce Development Kit (SFDK), designed for deploying or applying changes to a Salesforce organization. It facilitates the process of taking local metadata, source code, or configuration files and synchronizing them with a remote Salesforce org.
This command is typically used by developers and administrators to push new features, bug fixes, or configuration updates from a local development environment or version control system to a scratch org, sandbox, or even a production environment (with caution). Its primary function is to interpret the provided source (often a directory containing Salesforce metadata components or unpacked source files) and apply the corresponding changes to the specified target Salesforce org. It handles the complex dependencies and potential destructive changes that might occur during deployment, providing feedback on the success or failure of the operation. This command is fundamental for maintaining consistency between local development artifacts and the deployed state of a Salesforce application, streamlining CI/CD pipelines and collaborative development efforts.
CAVEATS
This command operates within the Salesforce Development Kit (SFDK) ecosystem. It requires a properly configured SFDK environment and authenticated Salesforce organizations. Applying changes to production organizations should always be done with extreme caution and after thorough testing in lower environments. Network connectivity to Salesforce servers is essential. Be aware that if components are removed from your local --source-dir, they might be destructively deleted from the target org upon deployment.
CI/CD INTEGRATION
sfdk-apply is frequently utilized in continuous integration and continuous deployment (CI/CD) pipelines to automate the deployment of code and configuration changes, ensuring consistent and rapid delivery of Salesforce applications.
ROLLBACK CONSIDERATIONS
While sfdk-apply facilitates deployments, it does not inherently provide an automatic rollback mechanism. Reverting changes typically involves deploying a previous version of the source or manually undoing the modifications on the target Salesforce org.
HISTORY
The sfdk-apply command emerged as a core component of the Salesforce Development Kit (SFDK), a suite of tools designed to streamline the development and deployment lifecycle for Salesforce applications. Its development paralleled the growth of Salesforce DX (SFDX) and the increasing need for robust, automatable methods to manage Salesforce metadata and source code. It became a cornerstone for continuous integration and continuous deployment (CI/CD) pipelines in Salesforce development, providing a programmatic way to synchronize local development artifacts with remote Salesforce environments.
SEE ALSO
sf deploy, sf retrieve, git apply(1), kubectl apply(1)