You need to split the idea of a build and a deployment in your mind.
I find it best to imagine there is no internet and you are posting out CD ROMs to your customers, who then install and configure them
You Build the source code and burn the CD ROM with version X
Your customer Deploys the binary to their server and configures it for their environment.
In my view you should define separate execution environments in separate files, e.g. like Spring's application-test.yml, application-local.yml, application.yml etc. That way you can switch between executions by changing only one thing (the exact invokation command).
Whether or not to arrange the description files so that duplicate settings are declared only ...