Forum Discussion

manish2501345's avatar
manish2501345
Copper Contributor
Sep 02, 2024

Best Practice to build multiple application using different java version with Single Agent

Hello,

 

I had an java application with tech stack such as gradle, java11 etc. I configured an agent with all required tools including java 11 to build the app. It worked fine.

 

Recently for a new java application which uses java17, I used the same agent and installed java17 on that.

Build for this application worked fine but I noticed that old application build which require java 11 started getting failed along with ./gradlew commands

 

When I checked on the agent, JAVA_HOME was correctly pointing to JAVA11 but java -version was set to java17. Also gradle 6.7 version is set to use java11.

 

 

I am pretty sure that issue is due to java version conflicting or mismatch but I want to understand on best practices to follow:

 

  • is it ok to use same agent server for different application (which required different java versions) or in other terms is it ok to install multiple java versions on same agent server
  • if it's fine how to make sure the applications are using the expected java version. I have already set the toolchain to use respective java version in build.gradle of application itseld but still ./gradlew addCredentials is failing for the same commit which was successful before I installed java 17 and used the same agent for another application.

Please suggest.

Resources