TeamCity Custom Variable

Hi there.

Everybody knows which is the solid tool to run continuous integration process. Indeed it’s the best  tool I ever have worked with.
Nevertheless, sometimes you may find out that it doesn’t provide something that you need, though it seems it should have that. Well, there is no miracle cure for all our needs and wishes.

In my case, TeamCity doesn’t have a variable that could be integrated in build-script and that could tell IP address of the host which TeamCity is running on. Fortunately I have been told about that solution recently by my colleague Yury Schkatula. That can be solved with TeamCity custom variable.

How To Do

You should patch TeamCity agent properties to introduce a new variable. Most likely, you want to change the file which can be found in folder:

This is default folder and could be different from yours.
In the end of that file you should add your variable. Let’s put there the following for the case described above:

Instead of XXX.XXX.XXX.XXX you should write something which is relevant for your environment.
After that you’ll be able to use that variable in the script.

For example,

<replacestring from=”localhost” to=”${host-ip-var}”>

That’s it.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Post

%d bloggers like this: