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

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

问题描述

对不起'svn'风格 - 我们正在从SVN迁移到GIT(包括我们的CI Jenkins环境)。



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



此外,如果在同一个Jenkins项目中,我们需要签出几个私有的GitHub我们可以怎么做?



我们安装了GitHub插件。希望我们已经说了正确的话。 解决方案

默认 git插件对于Jenkins来说非常好。

添加新的git存储库(项目配置>源代码管理>检查GIT选项)到项目导航到插件设置,位于存储库浏览器区域的上方。应该有一个高级按钮。点击它后,应该会出现一个新的表单,其值描述为回购的本地子目录(可选)。将它设置为文件夹将使插件检出版本库到相对于你的工作区的文件夹中。这样,您可以根据需要在您的项目中拥有尽可能多的存储库,全部位于不同的位置。



另外,如果您正在使用的项目允许,您可以使用GIT子模块,这与SVN中的外部路径类似。在 GIT Book 中,有关于该主题的一节。如果这不会违反某些政策,子模块的使用相当简单,为您提供了强大的方法来控制位置,将导入的版本/标签/分支,并且可以在本地存储库上使用,并为您提供更好的可移植性。



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


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

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.

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?

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

解决方案

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

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.

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.

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

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

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