Is it possible to reference a file within force:mdapi:deploy -r in order to extract the names of the test classes to run?

What I am trying to achieve is something like:

sfdx force:mdapi:deploy -c -d src -w 20 -l RunSpecifiedTests -r ClassesToValidate.txt -u myUser

I cannot find anything like this within the documentation.


As far as I'm aware, there's no way to do so directly (or, at least, it's not documented, as you've noted).

However, if your shell supports parameter substitution, awk, and other tools (i.e. you have a POSIX-like environment), you can use shell commands, such as:

sfdx force:mdapi:deploy ... -r $(cat ClassesToValidate.txt) ...


sfdx force:mdapi:deploy ... -r `cat ClassesToValidate.txt` ...
| improve this answer | |
  • Thank you I will try that! – Arthlete Apr 26 '19 at 18:51
  • That worked, thanks so much! Beautiful. – Arthlete Apr 26 '19 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.