简体   繁体   English

gitlab-ci中的增量更新

[英]Incremental update in gitlab-ci

Community! 社区!

Company I am working for is moving towards git and Gitlab-CI. 我正在工作的公司正在向git和Gitlab-CI迈进。 We have pretty large codebase - it takes ~10min to download sources, ~20 more minutes to download supplemental stuff from nexus, and then ~50min to build. 我们有相当大的代码库-下载源大约需要10分钟,从关联处下载补充内容大约需要20分钟,然后需要大约50分钟来构建。 So it is absolutely necessary to have incremental builds - thus we can get sources and build only updated files in a few minutes, rather than >1h. 因此,绝对有必要进行增量构建-因此我们可以在几分钟之内(而不是> 1h)获得源文件并仅构建更新的文件。

Unfortunately GitLab's CI default strategies (particularly fetch) do no work for incremental build as they have hardcoded 'git clean -ffdx' which removes all untracked files, so it requires a full rebuild. 不幸的是,GitLab的CI默认策略(尤其是访存)对增量构建不起作用,因为它们已经硬编码了“ git clean -ffdx”,它会删除所有未跟踪的文件,因此需要完全重建。 I ended up developing my own update sequence: 我最终开发了自己的更新序列:

  • git init git初始化
  • git fetch --tags $CI_REPOSITORY_URL +refs/heads/ :refs/remotes/origin/ git fetch --tags $ CI_REPOSITORY_URL + refs / heads / :refs / remotes / origin /
  • git config remote.origin.url $CI_REPOSITORY_URL git config remote.origin.url $ CI_REPOSITORY_URL
  • git checkout -B $CI_BRANCH_NAME origin/$CI_BRANCH_NAME git checkout -B $ CI_BRANCH_NAME原始人/ $ CI_BRANCH_NAME

This script seems to be working on a fresh computer (acts as clone), as well updating existing repo. 这个脚本似乎正在新的计算机上工作(充当克隆),以及更新现有的存储库。 At the same time I am not sure that it is working properly, as it works almost silently. 同时,我不确定它是否正常运行,因为它几乎可以静默运行。

Question 1: Is this correct sequence to checkout to an arbitrary branch? 问题1:检出到任意分支的顺序正确吗? Question 2: Does it require a git merge or git pull command after it? 问题2:它后面是否需要git merge或git pull命令? Question 3: Is there a way to get a list of changed files with this particular update (something like git pull does). 问题3:是否可以通过此特定更新来获取已更改文件的列表(类似于git pull所做的事情)。 This was extremely handy on our previous CI system to troubleshoot build issues Question 4 (relates to #3): Is there a way to get a list of commits in the current update? 这在我们以前的CI系统上解决构建问题非常方便。问题4(与#3相关):是否可以获取当前更新中的提交列表? This is irrelevant if moving between far branches, but could be very helpful when updating the same branch 如果在较远的分支之间移动,则这无关紧要,但是在更新同一分支时可能会非常有帮助

You should configure the cache property on your CI jobs for the untracked files that support incremental builds. 您应该在CI作业中为支持增量构建的未跟踪文件配置缓存属性。 The paths you list will be cached between jobs, so that you can do things like incremental builds. 您列出的路径将在作业之间进行缓存,以便您可以执行增量构建之类的操作。

As a quick start, you can cache all untracked files by simply untracked to true. 快速入门,您可以通过简单地将untracked为true来缓存所有未跟踪的文件。

ci_job:
  cache:
    untracked: true

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

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