15

Where should I put the gradle.properties file in Jenkins?

I'm using version 1.21 of the Gradle plugin, but it isn't finding the properties file when I put it in the user home .gradle directory.

Any pointers would be much appreciated.

Thanks

UPDATED

The Gradle plugin looks by default in the workspace of each project for a gradle.properties file. In order to use one file across all jobs, you need to set your gradle home in your job configurations as follows, by adding the following under 'switches':

-Dgradle.user.home=$HOME/.gradle
user1740752
  • 553
  • 1
  • 4
  • 14

4 Answers4

26

The Gradle plugin looks by default in the workspace of each project for a gradle.properties file. In order to use one file across all jobs, you need to set your gradle home in your job configurations as follows, by adding the following under 'switches':

-Dgradle.user.home=$HOME/.gradle
user1740752
  • 553
  • 1
  • 4
  • 14
  • +1 from me! However, I'm using different nodes with different user-homes, so I configured it like -Dgradle.user.home=${GRADLE_USER_HOME} and defined the environment variable with value 'C:\Users\\.gradle' in the configuration of each node. Hope it'll help someone with similar situation as me. – P Kuijpers May 14 '18 at 14:48
5

In your Jenkins webpage, you can see 'user.home' property in 'System Information' page. (for slve, check slave's 'System Information' page) You'd put gradle.properties under 'user.home'/.gradle/ folder and every gradle job could see that properties. Adding switch is not work if your job runs on the other slave environment (ie. Windows system)

devmojopum
  • 51
  • 1
  • 1
2

In addition to the answer of @devmojopum, make sure "Force GRADLE_USER_HOME to use workspace" is not checked in your job configuration.

Gradle Configuration

user2880229
  • 151
  • 8
-6

Just put gradle.properties next to your build.gradle.

Regards, Olle

Olle Hallin
  • 588
  • 1
  • 3
  • 12