We have a similar situation. I handle it in my framework. When I generate a new test run to execute, part of that generation includes referencing what we call a "run definition". That includes several parameters and such to indicate a) what application is being tested, b) which test cases are included, c) what environment it executes in.
Then, when the test run kicks off, it reads the environment part of the rundefinition into a ProjectSuite variable which we then reference anywhere in our test cases where we need to navigate to a new page manually (as opposed to clicking links).
That's one solution... but something similar could work for you where you could have your build set a system environment variable and have your tests configured to read that value and utilize it anywhere a URL is referenced.