如何在 Windows 上更改 Jenkins 默认文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12689139/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:56:25  来源:igfitidea点击:

How to change Jenkins default folder on Windows?

windowscontinuous-integrationjenkinshudson

提问by Micha? Kuliński

How to change Jenkins default folder on Windows where Jenkins runs as Windows service. I want to change C:\Users\Coola\.jenkinsfolder to d:\Jenkinsdue to lack of space on C:partition (Every build takes ~10MB of free space). I don't want to reinstall Jenkinsas Windows service. I just want to change folder of existing Jenkinsinstance. In case of lack of global solution I could focus only on relocating jobsfolder.

如何在 Jenkins 作为 Windows 服务运行的 Windows 上更改 Jenkins 默认文件夹。由于分区空间不足,我想将C:\Users\Coola\.jenkins文件夹更改为(每个构建需要约 10MB 的可用空间)。我不想重新安装为 Windows 服务。我只想更改现有实例的文件夹。如果缺乏全局解决方案,我只能专注于重新定位文件夹。d:\JenkinsC:JenkinsJenkinsjobs

Thanks in advance for your help.

在此先感谢您的帮助。

采纳答案by grams

  • Stop Jenkins service
  • Move C:\Users\Coola\.jenkinsfolder to d:\Jenkins
  • Using regedit, change HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Jenkins\ImagePathto "d:\Jenkins\jenkins.exe"
  • Start service
  • 停止 Jenkins 服务
  • C:\Users\Coola\.jenkins文件夹移动到d:\Jenkins
  • 使用regedit,更改HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Jenkins\ImagePath"d:\Jenkins\jenkins.exe"
  • 启动服务

回答by kap

Apparently, grams' answer works but is not preferred. In Windows software and data/configuration files are supposed to reside in different places. This should be well known to Unix guys, it is basically like having a home directory. However, the wording with regard to JENKINS_HOME is broken anyways as setting an environment variable does not help despite what is being said in the help text.

显然,克的答案有效但不是首选。在 Windows 中,软件和数据/配置文件应该位于不同的地方。这对于 Unix 人来说应该是众所周知的,它基本上就像拥有一个主目录。然而,关于 JENKINS_HOME 的措辞无论如何都被打破了,因为尽管帮助文本中说了些什么,但设置环境变量并没有帮助。

I used the procedure that is described here: http://tech.nitoyon.com/en/blog/2014/02/25/jenkins-home-win/

我使用了这里描述的程序:http: //tech.nitoyon.com/en/blog/2014/02/25/jenkins-home-win/

Basically:

基本上:

  1. Stop Jenkins service
  2. Edit entry <env name="JENKINS_HOME" value="%BASE%"/>in jenkins.xmlin the Jenkins installation directory. This will be something like C:\Program Files (x86)\Jenkins. In your case valuehas to be set to d:\Jenkins
  3. Move Files from the installation directory to the new destination, d:\Jenkins, all except (some of them may not exist in a fresh installation)

    • jre folder
    • jenkins.err.log
    • jenkins.exe
    • jenkins.exe.config
    • jenkins.out.log
    • jenkins.war
    • jenkins.war.bak
    • jenkins.war.tmp
    • jenkins.wrapper.log
    • jenkins.xml

      1. Restart the service again.
  1. 停止 Jenkins 服务
  2. 编辑条目<env name="JENKINS_HOME" value="%BASE%"/>jenkins.xml的詹金斯的安装目录。这将类似于C:\Program Files (x86)\Jenkins. 在你的情况下value必须设置为d:\Jenkins
  3. 将文件从安装目录移动到新目标,d:\Jenkins所有除外(其中一些在全新安装中可能不存在)

    • jre文件夹
    • 詹金斯错误日志
    • 詹金斯.exe
    • jenkins.exe.config
    • 詹金斯.out.log
    • 詹金斯.war
    • 詹金斯.war.bak
    • jenkins.war.tmp
    • jenkins.wrapper.log
    • 詹金斯.xml

      1. 再次重启服务。

回答by Carlos

回答by OblongZebra

When you read Administering Jenkinsyou can read all options how to modify the JENKINS_HOME environment variable.

当您阅读管理 Jenkins 时,您可以阅读如何修改 JENKINS_HOME 环境变量的所有选项。

On this websiteyou can read how to configure you Tomcat container to override the JENKINS_HOME environment variable, they advise to create the file $CATALINA_BASE/conf/localhost/jenkins.xml, with the following content:

此网站上,您可以阅读如何配置 Tomcat 容器以覆盖 JENKINS_HOME 环境变量,他们建议创建文件 $CATALINA_BASE/conf/localhost/jenkins.xml,其内容如下:

<Context docBase="../jenkins.war">
    <Environment name="JENKINS_HOME" type="java.lang.String" value="/data/jenkins" override="true"/>
</Context>

回答by dunni

And in addition to grams answer, the most important part is creating an environment variable named JENKINS_HOME with value "D:\Jenkins". Without that, on starting Jenkins it would again create the .jenkins folder in your user home folder.

除了克的答案,最重要的部分是创建一个名为 JENKINS_HOME 的环境变量,其值为“D:\Jenkins”。没有它,在启动 Jenkins 时,它会再次在您的用户主文件夹中创建 .jenkins 文件夹。

回答by lukaz

I was able to change the JENKINS_HOME variable following this http://tech.nitoyon.com/en/blog/2014/02/25/jenkins-home-win/

我能够在http://tech.nitoyon.com/en/blog/2014/02/25/jenkins-home-win/之后更改 JENKINS_HOME 变量

Setting JUST %JENKINS_HOME% as windows system wide environment variable didn't have any effect!

将 JUST %JENKINS_HOME% 设置为 Windows 系统范围的环境变量没有任何影响!

回答by Ian Grainger

We installed by dropping the .war into Tomcat, and could set home by justsetting the environment variable JENKINS_HOME(with a service restart).

我们安装通过删除的.war到Tomcat,并且可以被设为首页设置环境变量JENKINS_HOME(与服务重新启动)。