How to target a specific build agent based on a parameter within Graddle?
Is there a way to specify a build agent based on some value within source code?
E.g. if build.gradle file contains sourceCompatibility = 1.8 then it would build on agent A and if its sourceCompatibility = 11 then on agent B.
We are in the process of upgrading our project from Java 8 to Java 11 and the idea was to have two separate build configurations targeting specific build agents (using Agent requirement). I know we can specify a branch pattern to be used to target a specific build configuration and its associated build agent but having to make sure branch names include java version seems like a messy solution. While having java version specified anywhere within the code seems (such as build.gradle) appears to be much simpler.
Please sign in to leave a comment.
Hello Aidanas,
Unfortunately, it is not possible to set up an agent requirement basing on the value in the Gradle build file. However, if you plan to have two build configurations, where 1st would be built on agent A and 2nd on agent B, you could set up the agent requirements basing just on the agent names (for example, teamcity.agent.name equals <1st agent name>):

Please let me know if this could work for you.