签出多个git回收到相同的Jenkins工作区 [英] Checkout multiple git repos into same Jenkins workspace

查看:519
本文介绍了签出多个git回收到相同的Jenkins工作区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Jenkins 1.501和Jenkins Git插件1.1.26

我有3个不同的git仓库,每个仓库都有多个项目。



现在我需要将3 git repos中的所有项目签出到Jenkins从站的同一工作区中。我已经定义了每个git仓库:源代码管理:多个SCM 。但是,每次检出回购时,以前的回购(及其相关项目)都会被删除。



我已阅读此文件:

http:// jenkins.361315.n4.nabble.com/multiple-git-repos-in-one-job-td4633300.html



但它并不真正帮助。我试图在本地子目录的repo(可选)下为所有回购指定相同的文件夹,但它给出相同的结果。



如果这使用Jenkins简直是不可能的我猜想可以使用一些预构建步骤/脚本将项目移动到正确的位置。它不是修改项目的构建配置的选项。

解决方案

一次检出多个回购单作为解决方法,您可以拥有多个上游作业,每个上传作业每个检出一个回购单元,然后复制到最终的项目工作空间(在许多层面上存在问题),或者您可以设置一个shell脚本步骤,在构建时检查每个需要的repo到作业工作区。



我肯定会推荐后一种方法,因为您不必担心工作区位置是否发生变化(您可以使用$ WORKSPACE环境变量)。



2014编辑:此答案已经出来的日期,并不再反映最佳做法。请参阅下面有关 Multiple SCM 插件的答案。



2016 EDIT2:多个SCM插件已弃用。从Multiple SCM插件页面:用户应该迁移到 https:// wiki。 jenkins-ci.org/display/JENKINS/Pipeline+Plugin 。Pipeline提供了一种更好的检查多个SCM的方法,并且由Jenkins核心开发团队支持。


Using Jenkins 1.501 and Jenkins Git plugin 1.1.26

I have 3 different git repos each with multiple projects.

Now I need to checkout all projects from the 3 git repos into the same workspace on a Jenkins slave. I have defined each git repo in: Source code Management: Multiple SCMs. But each time a repo is checked out the previous repo (and its associated projects) is deleted.

I have read this:

http://jenkins.361315.n4.nabble.com/multiple-git-repos-in-one-job-td4633300.html

but its does not really help. I have tried to specify the same folder under Local subdirectory for repo (optional) for all repos but it gives the same result.

If this is simply impossible using Jenkins I guess some pre-build step/scripting could be used to move the projects into the right location. Its not an option to modify the build configuration of the projects.

解决方案

Checking out more than one repo at a time in a single workspace is not possible with Jenkins + Git Plugin.

As a workaround, you can either have multiple upstream jobs which checkout a single repo each and then copy to your final project workspace (Problematic on a number of levels), or you can set up a shell scripting step which checks out each needed repo to the job workspace at build time.

I would definitely recommend the latter approach as you won't have to worry if the workspace location changes (You can use the $WORKSPACE environment variable).

2014 EDIT: This answer is out of date, and no longer reflects best practices. Please see the answers below regarding the Multiple SCM's plugin.

2016 EDIT2: The Multiple SCM plugin is deprecated. From the Multiple SCM plugin page: "Users should migrate to https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin . Pipeline offers a better way of checking out of multiple SCMs, and is supported by the Jenkins core development team."

这篇关于签出多个git回收到相同的Jenkins工作区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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