更改gradle的本地回购缓存位置以进行Jenkins云构建 [英] Change gradle's local repo cache location for Jenkins cloud build

查看:274
本文介绍了更改gradle的本地回购缓存位置以进行Jenkins云构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更改回购下载的保存位置.我无法使用用户主目录,因为我的构建是在不保留此内容的云服务上运行的.

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.

我正在使用gradle 1.0里程碑5,并且我的构建文件具有以下存储库设置:

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")
}

(我更改了test-utils以隐藏一些我正在弄乱的测试库).

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

我在gradle构建之前添加了该execute sh步骤:

I have added this execute sh step before gradle build:

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

但是deps必须仍在其他地方下载,因为我的Jenkins版本的工作区中没有任何已下载的dep,但是其中确实有一些临时gradle文件.

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.

有什么想法可以确保将下载的dep放置在$ WORKSPACE中,这样我就可以始终避免下载这些内容?

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

推荐答案

定义GRADLE_USER_HOME应该可以解决问题.

Defining GRADLE_USER_HOME should do the trick.

GRADLE_USER_HOME设置为${WORKSPACE}将在${WORKSPACE}下放置各种目录.我将创建${WORKSPACE}/gradle-home并将其设置为GRADLE_USER_HOME.

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.

检查${WORKSPACE}解决的问题.

您还可以尝试使用-g命令行选项设置gradle用户的主目录.

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

这篇关于更改gradle的本地回购缓存位置以进行Jenkins云构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆