简体   繁体   English

我应该把 gradle.properties 放在詹金斯的什么地方

[英]Where should I put gradle.properties in Jenkins

Where should I put the gradle.properties file in Jenkins?我应该将 gradle.properties 文件放在 Jenkins 的什么位置?

I'm using version 1.21 of the Gradle plugin, but it isn't finding the properties file when I put it in the user home .gradle directory.我正在使用 Gradle 插件的 1.21 版,但是当我将它放在用户主 .gradle 目录中时它没有找到属性文件。

Any pointers would be much appreciated.任何指针将不胜感激。

Thanks谢谢

UPDATED更新

The Gradle plugin looks by default in the workspace of each project for a gradle.properties file. Gradle 插件默认在每个项目的工作区中查找 gradle.properties 文件。 In order to use one file across all jobs, you need to set your gradle home in your job configurations as follows, by adding the following under 'switches':为了在所有作业中使用一个文件,您需要在作业配置中设置 gradle home,如下所示,在“开关”下添加以下内容:

-Dgradle.user.home=$HOME/.gradle

The Gradle plugin looks by default in the workspace of each project for a gradle.properties file. Gradle 插件默认在每个项目的工作区中查找 gradle.properties 文件。 In order to use one file across all jobs, you need to set your gradle home in your job configurations as follows, by adding the following under 'switches':为了在所有作业中使用一个文件,您需要在作业配置中设置 gradle home,如下所示,在“开关”下添加以下内容:

-Dgradle.user.home=$HOME/.gradle

In your Jenkins webpage, you can see 'user.home' property in 'System Information' page.在您的 Jenkins 网页中,您可以在“系统信息”页面中看到“user.home”属性。 (for slve, check slave's 'System Information' page) You'd put gradle.properties under 'user.home'/.gradle/ folder and every gradle job could see that properties. (对于 slve,检查 slave 的“系统信息”页面)您将 gradle.properties 放在“user.home”/.gradle/ 文件夹下,每个 gradle 作业都可以看到该属性。 Adding switch is not work if your job runs on the other slave environment (ie. Windows system)如果您的作业在其他从属环境(即 Windows 系统)上运行,则添加开关不起作用

In addition to the answer of @devmojopum, make sure "Force GRADLE_USER_HOME to use workspace" is not checked in your job configuration.除了@devmojopum 的回答之外,请确保在您的作业配置中未选中“强制 GRADLE_USER_HOME 使用工作区”。

摇篮配置

I do not agree with the upvoted answers.我不同意赞成的答案。 This only works in single-workspace environments.这仅适用于单工作区环境。 If you use multiple projects, have multiple nexus environments to publish to,and want also eg jenkins not to mess up, then you should read如果您使用多个项目,有多个要发布到的 nexus 环境,并且还希望 jenkins 不会搞砸,那么您应该阅读

https://docs.gradle.org/current/userguide/build_environment.html https://docs.gradle.org/current/userguide/build_environment.html

how to chain gradle properties.如何链接 gradle 属性。

Gradle project properties can be stored in a separate folder and copied to the workplace root, the latter one added to .gitignore, so everybody can configure her own passwords and settings. Gradle 项目属性可以存储在单独的文件夹中并复制到工作区根目录,后者添加到 .gitignore 中,因此每个人都可以配置自己的密码和设置。

This also encourages to use the FORCE flag to be uses in Jenkins.这也鼓励在 Jenkins 中使用 FORCE 标志。

Just put gradle.properties next to your build.gradle.只需将 gradle.properties 放在 build.gradle 旁边。

Regards, Olle问候, 奥莱

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM