How To

Where to put the file on Jenkins

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

Sometimes you need to have a 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 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 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 file that contains our api key to /var/lib/jenkins/.gradle

For example:

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

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

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

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