My particular use case is for Salesforce ant deployment. I wanted to replace some metadata before I deploy to the target org which will allow me to automate the process. I can fetch metadata from my sandbox org and when it gets deployed to the target org like production the values will be updated.
You should have the latest ant-salesforce.jar as a requirement. You can grab the latest ant migration tool from here – https://help.salesforce.com/articleView?id=code_tools_ant_using.htm&type=5
My sample script entails having a conditional check before doing the replace a logic with Custom Labels. This is how my build XML looks.
Additional library you would need to perform the conditional check is ant-contrib.jar file. You can grab the latest library from here – http://ant-contrib.sourceforge.net/
If you try to run the script without the library you might end with the error below.
Fix Ant Build Error: Problem: failed to create task or type if
On the build.xml simply add the reference to the library.
If everything is in place, like the properties file has the right credentials, running the following command should deploy your code and replace the values as per your ant script.
ant -Denvironment=prod -buildfile build.xml deployMetadata
Source code available here – https://github.com/olopsman/salesforce-ant