Salesforce DX – Deploying SFDX-Converted Metadata with Filtered Package.xml

In a DevOps chain, I have a SFDX project.

I want to deploy only parts of this SFDX Project to an org, using a custom package.xml

My actions are :

  • sfdx force:source:convert -d tmp/deployDemoQuali/
  • replace tmp/deployDemoQuali/package.xml by my own custom package.xml
  • sfdx force:mdapi:deploy -d tmp/deployDemoQuali/ -w 60 -u DemoQuali

Problem is that even with filtered package.xml, fdx force:mdapi:deploy seems to take the full content of tmp/deployDemoQuali/

How can I filter content of tmp/deployDemoQuali/ to keep only the items listed in my custom package.xml ?

Thanks ! 🙂

Best Answer

So ... I finally created a sfdx plugin allowing to do that

https://github.com/nvuillam/sfdx_metadatas_filtering

  • Install it

    sfdx plugins:install sfdx_metadatas_filtering

  • Use it

    sfdx metadatafilter:execute -i mdapi_output_dir -p myPackage.xml -o md_api_filtered_output_dir

Full example

sfdx force:source:convert -d tmp/deployDemoQuali/
sfdx metadatafilter:execute -i tmp/deployDemoQuali/ -p myPackage.xml -o tmp/deployDemoQualiFiltered/
sfdx force:mdapi:deploy -d tmp/deployDemoQualiFiltered/ -w 60 -u DemoQuali

Warnings:

  • all cases are not taken in account yet, please read carefully the README and contribute if you are in a hurry :)

  • Windows users: sfdx plugin generator is bugged on windows (hardcode call of linux rm instruction) , so you may use Git Bash to run this code ( at least while it installs the plugin dependencies )


EDIT 26/06/2018

It seems that several plugins are necessary to survive in this cruel world, so I joined all the ones I needed to create (including metadata filtering) into https://github.com/nvuillam/sfdx-essentials

This is the only maintained plugin , please use it :)


Related Topic