Where to put the gradle.properties file on Jenkins

TL;DR: Put your gradle.properties file in the /var/lib/jenkins/.gradle/ directory on a standard Ubuntu install.

Sometimes you need to have a gradle.properties file that is not included in your git repository. Many times this is because you need to have an api key that you would not like to be made public.

Because your gradle.properties file will not be checked into your git repository, the job will fail to build if your api key value is not able to be found.

One way to fix this is by placing your gradle.properties file in a place that jenkins will look for it. By default this location is in the .gradle directory of your Jenkins user.home directory.

To find the user.home directory open the Jenkins console in your browser, click “Manage Jenkins”, and then click the “System Information” link.

Scroll down until you find “user.home”


In this example, the user.home directory is /var/lib/jenkins.

Now that we know this, we need to copy our gradle.properties file that contains our api key to /var/lib/jenkins/.gradle

For example:

sudo cp ~/source/a-caring-text/gradle.properties /var/lib/jenkins/.gradle/

Change the file permissions so that Jenkins can read the file:

sudo chown jenkins:jenkins /var/lib/jenkins/.gradle/gradle.properties

Now you can build the job that was depending on this api key!


Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.