如何从一个本地 git 存储库获得多个 Jenkins 构建? [英] How can I get multiple Jenkins builds to work from one local git repo?

查看:22
本文介绍了如何从一个本地 git 存储库获得多个 Jenkins 构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的 GitHub 存储库,其中包含几个可独立构建的位.如果我为 Jenkins 中的每一个配置一个(或两个)作业,我最终不得不多次提取千兆字节的数据(每个作业的一个 repo 克隆).

I have a GitHub repo that's big and contains several independently build-able bits. If I configure Jenkins with a job (or two) for each of these, I end up with having to pull gigabytes of data multiple times (one clone of the repo for each job).

这需要磁盘空间和带宽.

This takes both diskspace and bandwidth.

我想做的是拥有克隆 github 一次的刷新本地存储库"作业,然后配置每个作业以从该存储库克隆自己,然后构建.然后通过将子作业设置为依赖构建,我可以运行刷新本地存储库",让它从 GitHub 中提取所有最新内容,然后运行每个构建.

What I'd like to do is have "Refresh local repo" job that clones github once, then configure each of the jobs to clone themselves from that repo, and build. Then by setting up the sub-jobs as dependent builds, I can run "Refresh local repo", have it pull all the latest stuff from GitHub, then have each of the builds run.

到目前为止,我已经让刷新本地存储库"工作 - 它成功克隆,如果我转到工作区,我会看到它具有 origin/master 的 HEAD 提交.

So far I've got the "Refresh local repo" working - it clones successfully, and if I go to the workspace, I see that it has the HEAD commit of origin/master.

问题是其他工作 - 这些似乎没有更新.以下是我如何配置其中之一:

The problem is the other jobs - these don't seem to be picking up updates. Here's how I've got one of them configured:

Git
 Repository URL file:////Users/malcolmbox/.jenkins/jobs/Refresh Local repo/workspace
 Branches to build  master

不是更新到最新提交,而是在过去几天卡住了.

Instead of this updating to the latest commit, it's stuck several days in the past.

我怎样才能让它拉动提示并做正确的事情?

How can I get it to pull the tip and do the right thing?

澄清:.../Refresh Local repo/workspace has commit 6b20268389064590147d5c73d2b6aceb6ba5fe70 提交 28/3

To clarify: the .../Refresh Local repo/workspace has commit 6b20268389064590147d5c73d2b6aceb6ba5fe70 submitted 28/3

依赖构建,在运行构建后(所以大概是执行 git clone/pull 步骤)被检出到 79a25992cc192376522bcb634ee0f7eb3033fc7e 提交 26/3 - 所以它落后了几天.

The dependent build, after running a build (so presumably doing a git clone/pull step) is checked out to 79a25992cc192376522bcb634ee0f7eb3033fc7e submitted 26/3 - so it's a couple of days behind.

推荐答案

如果打开作业配置,点击git SCM配置的Advanced按钮,会看到一个地方指定使用的引用repo的路径克隆期间(可选)".

If you open the job configuration and click on the Advanced button of the git SCM configuration, you will see a place to specify "Path of the reference repo to use during clone (optional)".

如果您有存储库的本地克隆,请将路径添加到引用存储库字段.

If you have a local clone of your repository, add the path to the reference repo field.

然后 Git 将使用本地克隆并共享磁盘上的大部分 git 对象,并仅从 github 中提取本地克隆中缺少的内容,从而实现闪电般的快速克隆并节省磁盘空间.

Git will then use the local clone and share most of the git objects on the disk and pulling from github only what is missing from the local clone resulting in lightning fast clones and saved disk space.

或者这正是您配置工作的方式并且它没有选择最新的提交?如果是这样,请提供更多详细信息.考虑发布您的作业配置.

Or is this exactly how you have configured your job and it is not picking up latest commits? If that is so, please provide more details. Consider publishing your job configuration.

这篇关于如何从一个本地 git 存储库获得多个 Jenkins 构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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