Jenkins中修改gradle的默认目录

Jenkins中修改gradle的默认目录

之前公司有一个旧的Jenkins在提供客户端打包,随着时间的推移发现默认gradle占用根分区的资源空间越来越大。照成数据盘有很大闲置,而根分区不够的现象。

Jenkins中修改gradle的默认目录

可以看到我根分区剩余空间非常少

Jenkins中修改gradle的默认目录
经过排查发现gradle 的默认目录占的比较大,为了合理运用资源,就想着移动gradle的默认目录

网上也找了好多。什么5中方式改变gradl的目录。发现好多都是windows. z T 8 = |的。其中发现了X x C y b C一个但用处不是很大。

最后通过

[root@dbjenkins gradle_cac * ! X Xche]# gradl: ; x / z } }e --h

USAGE: g_ { ( . u M o p gradle [option...] [tar : { / m U &sk...]
-?, -h, --help          Shows this help message.
-a, --no-rebuild        Do not rebuild project dependencies.
-b, --build-file        Specifies: n H d | l the build fV X I G ! ( {ile.
-_ D y $ a O @c, --settings-file     Specifies the settings file.
--configure-on-demand   Only relevant projects are configured in this build run. This means faster b|  Yuild for large multi-project builds. [incubating]
--console               Specifies which type of console output to generate. Values are J [ c l z G'plain', 'auto' (default) or 'rich'.
--continue              ContinV D l Bues task execution after a task failc 0 p 4ure.
-D, --system-prop       Set system property of the JVM (e.g. -Dmyprop=myvalue).
-d, --dG   . ) |ebug             Log in debug mode (includes normal stacktracej ] n).
--daemon                Uses the Gradle daemon to run the build. Starts t e | ghe daemon if not running.
--foreground            Starts the Gradle daemon in the foregroung ; X Rd. [incubating]
-g, --gradle-user-home  Specifies the gradle user h? V yome directory.
-= q m X % y 6 &-gui                   Launches the Gradle GUI.
-I, --init-script       Specifies an initialization script.
-iF l ] W R f, --info              Set log level to info.
-m, --dry-run           Runs the builds with all task actions disabled.
--q = d X z ;max-workers           Configure the number of concurrent workers Gradle is alloh K v 7wed to use. [incubating]
--no-color              Do not use color in the conu Y Q g O c ,sole output. [deprecated - use --console=plain instead]
--no-daemon             Do not use the Gradle daemon to run the build.
--offline               The build should operate without accessing netwo* # e } J ork resources.
-P, --project-prop      Set project property for the buil% S , Id script (e.g.M B a U V D G -Pmyprop=myvalue).
-p, --projecl x t 7 at-dir       Specifie| Y R l L 8s the start direcx 0 g G [ * e $tory for Gradle. Defaults to current direcU @ 9 B  #tory.
--parallel              Build projects in parallel. Gradle willD F y { [ N m 4 attempt to determine the optimal nun B ^ gmber of executor threads to use.U  p n [inN T x F o Ocubating]
--parallel-threads      Build projects in parallel, using the specified number of executor threads. [deprecated - Please use --parallel,g @ u H X ` optionally in conjunction with --max-workers.] [incub7 # 2 8 c y ] : ating]
--profile` / #               Profiles build execution time and generates a rept U % .ort i; I = M ) H Pn the <build8 * + Q 3  W_dir>/reports/profile directory.
--project-cache-dir     Specifies the project-specific cache directorD u q Q B  7y. Defaults to .gradle in0 } 2 the root project di_ { g ) Erectory.
-q, --qui Q ~et             Log errors only.
--recompile-scripts     Force build script recomp, 9 : %iling.
--refresh-dependencies  Refresh the state of dependencies.
--rerun-tasks           Ignore previously cached task results.
-S, --full-stacktr9 E Xace   Print out the full (very verbose) stacktrace for all exceptions.
-s, --stacktrace        Print out the stacktrace for all exceptions.
--stop                  Stops thx Q T o De GraN ; i ^ [ ) * Hdl# F h l Q ? Te daemon if it is runb T e h U w z aning.
-t, --continuous        Enables continuous build. Gradle does not exit and will 3 Z @ Y & W 7 ?l re-execute tasks when task file inputs change. [incubating]
-u, --no-search-upward  Don't search in parent fo& ? }lders for a settings.gradle file.
-v, --version           Print version info.
-x, --exclude-task      Specify a ta3 ) Y 3 ,sk to be excluded from execution.

发现

-g,--g= r n ^ n x W g Rradle-uP 7 g 8 }ser-home指定gradle用P P u k d K户的主目录。

--project-cacK k : n Ahe-dir指定特定于项目的缓存目录。在根项目目录中默认为.gradle。

[root@dbjenkins ~]# mkdir /dbox/gradle_cache/

建立gradle 的主u I 2 q目录,和缓存目录

[g ] ~ H y 8root@dbjenkins gradle_cache]# gradle -g /dbox/gv l G q K ] % Oradle_cache

:help
Welcome to Gradle 2.14.1.
To run a build, run grado , ~ t %le &l r ,lt;task> ...
To see a list of available tasks, run graw ^ g z Y ]dle tasks
To see a list of command-line options, run gradle --help
To see more detail about a task, run( . m 9 gradle help -D 3 , L k-task <task>
BUILD SUCCESSFUL
Total time: 1.662 secs
Thi` 0 9 w # A Bs build coul5 V 5 , 7d be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html

我是把缓存目录和主目录放在一起了,方便以后查找

[root@dbjenkins gradle_cache]# gradle --proje# [ } rctO W N y N m-cache-dir /dbox/gradle_cache

:} j # ! S . zhelp
Welcome tk M m 6 g S z so Gradle 2.14.1.
To run a build, run gradle <task> .../ * Q Y ( 
To see a list of availal } $ n 0ble tasks, r- 7 8un gradle tasks
To see a list of command-line options, run gradle --helpn % ] l
To see more detail about a task, run gradle help --task <task>
BUILD SUCCESSFUL
Total time: 1.72 secs
This build could be faster, please conw k ? / m w ksider using the Gradle DaV 7 3emon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html

[root@dbjenkins ~]# cd /dbox/gradle_ca8 d 2 l ! Ache/
[root@dbjenkins? 1 - ^ : k { D gradle_cache]# ls -a

[root@dbjenkins gradl k k + ele_car o a 9 =che]#

.  ..  2.14.1  caches  .gradle+ - Z * W b x ^  native

Jenkins中修改gradle的默认目录

发现目录下已经生成了一些默认的目录