在 Jenkins 中,如何将项目签出到特定目录中(使用 GIT) [英] In Jenkins, how to checkout a project into a specific directory (using GIT)

查看:26
本文介绍了在 Jenkins 中,如何将项目签出到特定目录中(使用 GIT)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于 'svn' 风格很抱歉 - 我们正在从 SVN 迁移到 GIT(包括我们的 CI Jenkins 环境).

Sorry for the 'svn' style - we are in a process of migration from SVN to GIT (including our CI Jenkins environment).

我们需要的是能够让 Jenkins 检出(或者我应该说是克隆?)GIT 项目(存储库?)到特定目录中.我们已经尝试了一些 refspecs 魔法,但理解和成功使用并不是很明显.

What we need is to be able to make Jenkins to checkout (or should I say clone?) the GIT project (repository?) into a specific directory. We've tried some refspecs magic but it wasn't too obvious to understand and use successfully.

此外,如果在同一个 Jenkins 项目中,我们需要将多个私有 GitHub 存储库签出到项目根目录下的多个单独目录中,我们该怎么做?

Furthermore, if in the same Jenkins project we need to checkout several private GitHub repositories into several separate dirs under a project root, how can we do it please?

我们已经安装了 GitHub 插件.希望我们的措辞是正确的.

We have GitHub plugin installed. Hope we've phrased the things right.

推荐答案

默认 git 插件 因为詹金斯做得很好.

The default git plugin for Jenkins does the job quite nicely.

添加一个新的git仓库(项目配置>源代码管理>勾选GIT选项)到项目底部的插件设置,就在仓库浏览器的上方em> 地区.应该有一个高级按钮.单击它后,应出现一个新表单,其值描述为本地子目录(可选).将此设置为 folder 将使插件将存储库检出到相对于您的工作区的文件夹中.通过这种方式,您可以根据需要在项目中拥有任意数量的存储库,所有存储库都位于不同的位置.

After adding a new git repository (project configuration > Source Code Management > check the GIT option) to the project navigate to the bottom of the plugin settings, just above Repository browser region. There should be an Advanced button. After clicking it a new form should appear, with a value described as Local subdirectory for repo (optional). Setting this to folder will make the plugin to check out the repository into the folder relative to your workspace. This way you can have as many repositories in your project as you need, all in separate locations.

或者,如果您使用的项目允许这样做,您可以使用 GIT 子模块,它们类似于 SVN 中的外部路径.在 GIT Book 中有一节专门介绍了该主题.如果这不会违反某些政策,子模块使用起来相当简单,为您提供了强大的方式来控制将导入的位置、版本/标签/分支,并且它将在您的本地存储库中可用,并为您提供更好的可移植性.

Alternatively, if the project you're using will allow that, you can use GIT sub modules, which are similar to external paths in SVN. In the GIT Book there is a section on that very topic. If that will not be against some policy, submodules are fairly simple to use, giving you powerful way to control the locations, versions/tags/branches that will be imported AND it will be available on your local repository as well giving you better portability.

显然 GIT 插件支持检出子模块,因此 Jenkins 可以非常有效地使用它们.

Obviously the GIT plugin supports checking out submodules, so Jenkins can work with them quite effectively.

这篇关于在 Jenkins 中,如何将项目签出到特定目录中(使用 GIT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆