Gradle builds and build parameters

What is the most elegant way to deal with agent parameters that are passed as system properties to Gradle builds? It is possible to access the value of a system property xyz through teamcity["xyz"] in build.gradle but that only works on TeamCity. If that statement is present in a build file IDEA fails when it refreshes the project because it doesn't know about that property.

What is the most elegant way to have build files that work both on TeamCity and in the IDE? Do I need to implement special treatment (propertyMissing) for the IDE or is there a more elegant solution?

0
1 comment

Hi Dirk,

Yes, special treatment is needed. The solution is to define some default value, for example:

if (hasProperty("teamcity")) {
  xyz = teamcity["xyz"]
else {
  xyz = "N/A"
}
0

Please sign in to leave a comment.