如何让 Jenkins 不清理 git 工作区

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17637528/
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-19 08:46:28  来源:igfitidea点击:

How to have Jenkins not clean a git workspace

gitjenkinsworkspace

提问by Katjoek

Our Jenkins job that builds our project triggers on changes in the master of several GIT repositories. When it starts building it cleans the workspace of all the repo checkouts. We want to use the job only for clean build on request and by default for incremental builds. Some of our generated code is (still) generated inside the checkout, is therefor cleaned and therefor required to be regenerated and built each run. This takes quite a bit of time we would like to get rid of.

我们构建项目的 Jenkins 作业会在几个 GIT 存储库的 master 发生变化时触发。当它开始构建时,它会清理所有 repo checkout 的工作区。我们只想将作业用于根据请求进行干净构建,默认情况下用于增量构建。我们生成的一些代码(仍然)在结帐中生成,因此被清理,因此需要在每次运行时重新生成和构建。这需要我们想要摆脱的相当多的时间。

Note the last line of this part of the build log:

注意构建日志这部分的最后一行:

Started by user jenkins
Building on master
Checkout:WORK_PLATFORM3_REL_BUILD / /home/jenkins/data/WORK_PLATFORM3_REL_BUILD - hudson.remoting.LocalChannel@116fc35
Using strategy: Default
Last Built Revision: Revision 5479a644c63e128efb4fa61c00b4a708d8ae594f (origin/master)
Checkout:xxxxxx / /home/jenkins/data/WORK_PLATFORM3_REL_BUILD/xxxxxxx - hudson.remoting.LocalChannel@116fc35
Fetching changes from 1 remote Git repository
Fetching upstream changes from ssh://[email protected]:29418/xxxxxxx
Commencing build of Revision 5479a644c63e128efb4fa61c00b4a708d8ae594f (origin/master)
Checking out Revision 5479a644c63e128efb4fa61c00b4a708d8ae594f (origin/master)
Cleaning workspace

I cannot find a setting in the job's configuration to disable this "cleaning workspace" nor any global setting to change this.

我在作业的配置中找不到禁用此“清理工作区”的设置,也找不到任何全局设置来更改此设置。

Is there a solution?

有解决办法吗?

BTW, we're running Jenkins 1.410 (off topic: will upgrading to latest version be a trivial task?)

顺便说一句,我们正在运行 Jenkins 1.410(题外话:升级到最新版本是一项微不足道的任务吗?)

回答by harish

There is a check box 'clean after checkout' if you click the second 'Advanced' button under 'source code management' -> 'Git' settings in job configure page. Make sure this checkbox is not ticked for your case.

如果单击作业配置页面中“源代码管理”->“Git”设置下的第二个“高级”按钮,则会有一个复选框“结帐后清理”。确保没有为您的案例勾选此复选框。