Skip to content

hardis:mdapi:deploy

Description

Command Behavior

A wrapper command for Salesforce CLI's sf project deploy start (formerly sfdx force:mdapi:deploy), designed to assist with deployment error resolution.

This command facilitates the deployment of metadata API source (either from a zip file, a deployment directory, or a validated deploy request ID) to a Salesforce org. Its primary enhancement over the standard Salesforce CLI command is its ability to provide tips and guidance for solving common deployment errors.

Key features:

  • Flexible Input: Supports deploying from a .zip file (--zipfile), a local directory (--deploydir), or by referencing a previously validated deployment (--validateddeployrequestid).
  • Test Level Control: Allows specifying the test level for deployments (NoTestRun, RunSpecifiedTests, RunLocalTestsInOrg, RunAllTestsInOrg).
  • Error Handling Assistance: Displays helpful tips and links to documentation to guide you through resolving deployment failures.

Important Note: The underlying Salesforce CLI command sfdx force:mdapi:deploy is being deprecated by Salesforce in November 2024. It is recommended to migrate to sf project deploy start for future compatibility. See Salesforce CLI Migration Guide for more information.

For visual assistance with solving deployment errors, refer to this article:

Assisted solving of Salesforce deployments errors

Technical explanations

This command acts as an intelligent wrapper around the Salesforce CLI's metadata deployment functionality:

  • Command Wrapping: It uses the wrapSfdxCoreCommand utility to execute the sfdx force:mdapi:deploy (or its equivalent sf project deploy start) command, passing through all relevant flags and arguments.
  • Error Analysis (Implicit): While the direct code snippet doesn't show explicit error analysis, the description implies that the wrapSfdxCoreCommand or a subsequent process intercepts deployment failures and provides contextual help.
  • User Guidance: It logs messages to the console, including deprecation warnings and pointers to external documentation for troubleshooting.
  • Argument Passthrough: It directly passes the command-line arguments (this.argv) to the underlying Salesforce CLI command, ensuring all standard deployment options are supported.

Parameters

Name Type Description Default Required Options
checkonly
-c
boolean checkOnly
concise boolean concise
debug boolean debug
deploydir
-d
option deployDir
flags-dir option undefined
ignoreerrors boolean ignoreErrors
ignorewarnings
-g
boolean ignoreWarnings
json boolean Format output as json.
purgeondelete boolean purgeOnDelete
runtests
-r
option runTests
singlepackage
-s
boolean singlePackage
soapdeploy boolean soapDeploy
target-org
-o
option undefined
testlevel
-l
option testLevel NoTestRun NoTestRun
RunSpecifiedTests
RunLocalTests
RunAllTestsInOrg
validateddeployrequestid
-q
option validatedDeployRequestId
verbose boolean verbose
wait
-w
option wait 120
websocket option websocket
zipfile
-f
option zipFile

Examples