Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change gradle's local repo cache location for Jenkins cloud build

I need to change where repo downloads are saved. I cannot use the user home because my build is run on a cloud service which does not preserve this.

This is causing my deps to be downloaded over and over and is chewing up a lot of cloud buld time.

I am using gradle 1.0 milestone 5 and my build file has the following repos setup:

repositories {
    mavenLocal()
    mavenRepo urls: ['http://repo1.maven.org/maven2/', 'http://test-utils.googlecode.com/svn/maven-repo/snapshots']
    flatDir(name: 'fileRepo', dirs: "$projectDir/libs")
}

(I have changed test-utils to hide some test lib I'm messing with).

I have added this execute sh step before gradle build:

env GRADLE_USER_HOME="${WORKSPACE}"
export GRADLE_USER_HOME="${WORKSPACE}"

But the deps must be being downloaded elsewhere still because my Jenkins build's workspace does not have any downloaded deps in it, but it does have some temp gradle files in it.

Any ideas how I can make sure downloaded deps are placed in the $WORKSPACE so that I can avoid these downloads all the time?

like image 370
Steven Avatar asked Dec 15 '11 06:12

Steven


1 Answers

Defining GRADLE_USER_HOME should do the trick.

Setting GRADLE_USER_HOME to ${WORKSPACE} will put various directories under ${WORKSPACE}. I'd create ${WORKSPACE}/gradle-home and set GRADLE_USER_HOME to that.

Check what ${WORKSPACE} resolves to.

You can also try setting the gradle user home directory using the -g command line option.

like image 128
David Resnick Avatar answered Sep 20 '22 15:09

David Resnick