I used force:source:retrieve
to retrieve the given list of components (classes, workflows etc) and committed the files to git. Now I want to deploy these components to higher environments like QA and Prod from Git.
force:source:deploy
– I can't use this since it doesn't have the options like validate only or run local tests etc.. So I am planning to use force:source:convert
to convert into mdapi format but even this does not have an option to convert a list of metadata, it converts all the source code in the root folder.
What are the options to convert given list of metadata (package.xml/list of files) to mdapi format and then deploy to sandbox/prod from git.
Best Answer
You can use
.forceignore
file to specify the files which you want to exclude while converting to metadata format.From How to Exclude Source When Syncing or Converting documentation:
Let's say you have a DX project structure as below:
And that you want to exclude
MySecondClass.cls
from being converted into a metadata format. You can then include this file in the.forceignore
file so that the output directory does not contain this entry. The entry in the.forceignore
file should be then as below:When you run the
force:source:convert
, the generated output metadata format directory will not containMySecondClass*
files or any entry in the generatedpackage.xml
.