Symptoms
- The build agent is connected, registered, and authorized on the TeamCity server.
- The build agent's summary page includes the field
Hostname. - However, this field displays the agent's IP address instead of the host machine's hostname.
Cause
When the agent registers on the server, TeamCity prioritizes the address reported by the agent and ensures it is reachable via its hostname. The process looks like this:
- The agent connects to the server and reports its address.
- The reported address comes from the
ownAddressproperty in<TeamCity Agent Home>/conf/buildAgent.propertiesfile. Its value can be a hostname or an IP address. - If the
buildAgent.propertiesfile hasteamcity.agent.resolveOwnAddress=trueproperty along withownAddress, the agent will resolve the value ofownAddressto the IP address if needed, and the reported address will always be the agent's host IP. - If the
ownAddressproperty is absent, the agent reports an empty value, and the server infers an address from the established connection. - As a fallback, TeamCity sets the agent's hostname to the resulting value (either an IP address or the hostname), either reported by the agent or obtained from the connection.
- During agent registration, the TeamCity server performs a DNS lookup for the resulting value.
- If it succeeds, TeamCity sets the agent's hostname to the hostname in the found DNS record.
- If not, the agent's hostname is left as set on step 5.
- The resulting hostname is what is shown in the
Hostnamefield of the agent summary page.
Resolution
The easiest way to make TeamCity always show the agent's host machine's hostname in the Hostname field is to configure the ownAddress property in <TeamCity Agent Home>/conf/buildAgent.properties file and make sure it can be resolved by the TeamCity server and is reachable from it.
However, it may not always be possible, depending on the network configuration, build agent type, etc. In such a case, refer to the logic provided above and identify the solution most suitable for your environment and configuration.
Comments
0 comments
Please sign in to leave a comment.