Ensure all agents are using the same JDK

Hi,

Is there a way to ensure all the agents are using the same jdk?  Even this involves making some changes on the server directly that I'm fine with.  I'm asking this as we have over 40 agents and need to upgrade the jdk and wanted to find out if TeamCity had an easy way of doing this from the server side maybe by means of updating the agent on the server and having all agents update.  I also want to avoid having to configure where JAVA_HOME is located per build configuration.  Maybe this is also something you can do directly on the teamcity server and all agents will go into an upgrade phase and update accordingly.  Please let me know if you have done anything like this or know of an easy to do this through TeamCity.

Thanks,
Jay

6 comments

I would also be very much interested in this. I've been updating JAVA_HOME in buildAgent.properties file on each agent, but this is cumbersome.

0

Jason,
Oleg,

Do you need to update JDK for your builds or for the TeamCity agent?

Current approach might be:
- write a build script that will install JDK in a desired location. The script should be platform-specific.
- create a build configuration in TeamCity that runs the script and trigger it on all the agents.

The script can also update buildAgent.properties file (e.g. using search and replace).

If you need to upgrade the JDK that is being used by TeamCity agent, this is probabaly a no-brainer for Linux-based platforms where you can overwrite existing JDK installation with new files, but will require some tricky workaround to do that under Windows.

ANd you will probably be interesed in the feature request to allow TeamCity to manage software installations on agents: TW-3478

0

Also, for distributing a fixed set of files to all the agents, the workaround described in the comment may be used.

0

We need to update it for TeamCity agent in Windows. Yegor, is it possible to bundle JDK with TeamCity? Do the licensing terms allow it? Perhaps in the future, TC can have an option in "install agent software" to also install JDK.

0

> Yegor, is it possible to bundle JDK with TeamCity? Do the licensing terms allow it?

Yes/yes/It is bundled in .exe agent distribution.

So when user installs the agent from .exe JDK is installed. However, when agent upgrades, it uses .zip distribution and JDK is not affected.

There are at least two reasons:
- it's not easy to upgrade JDK from the Java code that runs on the JDK
- we bundle JDK only for Windows and it does not seem possible to bundle *nix JDKs.

> Perhaps in the future, TC can have an option in "install agent software" to also install JDK.

I filed a feaure request to support Agent's JDK upgrade. However, this might be not a trivial to implement.

0

Just the jdk the build uses, not the jdk the teamcity agent uses.

0

Please sign in to leave a comment.