Salesforce meta-data API smart deploy to sandboxes (don't use this for production)
mdapi:deployrequires that all the code on your filesystem at the time of deploy, be defined in
package.xml. See details here.
I wanted to track all my sfdc in one repo, and be able to only deploy the metadata files that I'm working on at the moment, via the sfdx mdapi:deploy CLI command.
mdapi-smart-deploy to the rescue..
deploy-metadata.yaml specify what you want to deploy, and
- Create a zip file containing a dynamically generated
package.xml, with only the files you want to deploy.
sfdx force:mdapi:deployagainst your sandbox.
- Checks status of the deploy and reports errors
Make sure the root of your git repo has a
srcdir (containing your SFDC source).
src/package.xmlcan exist, it will be ignored.
Set the enviornment var
SFDC_SANDBOX_USERNAMEto your sandbox username. Run
sfdx force:org:listto view your usernames.
- fish shell:
set -x SFDC_SANDBOX_USERNAME email@example.com
deploy-metadata.yamlin your root specifying entries you would normally put in
Run the following from the root of your repo
Before promoting changes from your sandbox (to prod for example), remember to modify your
src/package.xmlto include your changes (
--only-gen-package-xmlcan help generate the additions you need to make).
Please see the examples directory
--src-dir: specify the directory your metata files (code) lives. Relative to the root of your git repo. Defaults to
--only-gen-package-xml: will ONLY generate and print
stdout. Will not invoke
--verbose: for debugging the tool
Big one is, only a few metadata types are supported today. See this issue