[SalesForce] Deployment to Production Org using VS Code

I need one help to deploy different components like classes, triggers, objects, profiles, permission sets, etc from sandbox to the production org.

I used following command to deploy all the items on the production. But I noticed that it only validates the changes and is not giving any option to deploy the components

sfdx force:source:deploy -m ApexClass:TestUtility -l RunLocalTests -c -w 3 -u myProdUserName

I read different blogs and found that we can use the command "sfdx force:mdapi:deploy" for the deployment. But, I didn't get the exact syntax/procedure or any option in the VS Code which allow deploying all the components on the production.

Best Answer

You should read through the documentation on force:source:deploy again

The reason why you're only validating the changes is because that's exactly what you're telling sfdx to do when you use the -c flag

-c | --checkonly
Optional

Validates the deployed metadata and runs all Apex tests, but prevents the deployment from being saved to the org.

Further, when using the -m flag, you're either deploying everything in your project of a particular metadata type (when you use, for example -m ApexClass), or only deploying specific components (when you use -m ApexClass:MyClass, only MyClass is deployed)

Put into words, that command you're currently running says...

deploy the testUtility class (-m ApexClass:testUtility) to myOrgName (-u myOrgName), but only verify the changes (-c). Run all local tests (-l RunLocalTests), and stop listening for updates if the operation takes more than 3 minutes (-w 3)

Using the -p flag to specify a path to deploy to is probably the easiest way to do what you're describing. Using it and pointing to the "force-app" folder would deploy everything in your project unless you've done some serious modification to your project structure.

Related Topic