简体   繁体   English

带有 Jenkins 管道的 Git 插件会自动为 git fetch 附加选项 --force

[英]Git plug-in with Jenkins pipeline attaches option --force for git fetch automatically

I noticed git-plugin behaviour is different between free style(usual) job and pipeline job.我注意到自由风格(通常)作业和管道作业之间的 git-plugin 行为是不同的。

Recently, I have been migrating jobs to pipeline.最近,我一直在将工作迁移到管道。 The git-plugin behaves followings with free style job. git-plugin 的行为遵循自由风格的工作。

C:\Program Files\Git\bin\git.exe fetch --no-tags --progress -- git@gitlabs.xxxx:xxxx/xxxx.git +refs/heads/*:refs/remotes/origin/* # timeout=30

On the other hand, The git-plugin behaves followings with pipeline.另一方面,git-plugin 的行为与管道有关。

C:\Program Files\Git\bin\git.exe fetch --no-tags --force --progress -- git@gitlabs.xxxx.xxxx:xxxx.git +refs/heads/*:refs/remotes/origin/* # timeout=30

With pipeline, git-plugin attaches --force option.使用管道,git-plugin 附加 --force 选项。 For my job, it need the local modification a little it rarely is changed.对于我的工作,它需要稍微进行本地修改,很少更改。

So I would like to remove this --force option.所以我想删除这个 --force 选项。 Is there the way to remove it?有办法去掉吗? The pipeline code of git is generated by snippet generator, the code is like this. git的pipeline代码是由snippet generator生成的,代码是这样的。

checkout changelog: false, poll: false, 
scm: [$class: 'GitSCM', 
branches: [[name: 'refs/heads/master']], browser: [$class: 'GitLab', repoUrl: 'https://gitlabs.xxxx.xxxx/xxxx.git', version: '10.8'], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: true, reference: '', shallow: false, timeout: 30]], 
submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'xxxx-xxxx-xxxx-xxxx-xxxx', url: 'git@gitlabs.xxxx.xxxx:xxxx.git']]] 

Thanks,谢谢,

You could execute a bat command just like this:您可以像这样执行 bat 命令:

bat label: '', script: 'C:\\Program Files\\Git\\bin\\git.exe fetch
--no-tags --progress -- git@gitlabs.xxxx:xxxx/xxxx.git +refs/heads/*:refs/remotes/origin/* # timeout=30' 

but the --force command doesn't wipe your already cached repository and clone it again.但是 --force 命令不会擦除您已经缓存的存储库并再次克隆它。 The --force option only applies to refspecs which do not start with the + option. --force选项仅适用于不以 + 选项开头的refspecs

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

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