[英]Gitlab CI: get list of files changed since last run
I'm currently working on CI with Gitlab CI.我目前正在使用 Gitlab CI 进行 CI 工作。
I am able to get a list of modified files between last two commmit using:我能够使用以下命令获取最后两次提交之间的修改文件列表:
git log -m -1 --name-only --pretty="format:" HEAD
But I would like to have the list of files changed since last Gitlab CI run, that may include more than one commit.但我希望自上次 Gitlab CI 运行以来更改文件列表,其中可能包含多个提交。 Is there any way to get such list?有没有办法得到这样的清单?
This looks exactly like [ gitlab-org/gitlab
issue 17822][1] which requested, 4 years ago (Apr. 2017) a CI_PREV_COMMIT_SHA
这看起来与 [ gitlab-org/gitlab
issue 17822][1] 一模一样,它在 4 年前(2017 年 4 月)请求了CI_PREV_COMMIT_SHA
In our GitLab setup we have CI jobs configured for
only: master
(although this issue is relevant outside that scope).在我们的 GitLab 设置中,我们only: master
配置了 CI 作业(尽管这个问题在该范围之外是相关的)。The problem we have is that we want some jobs to know what the "previous HEAD" was prior to the current job.我们遇到的问题是,我们希望某些作业在当前作业之前知道“前一个 HEAD”是什么。
This would be relatively easy to get with a git log for MRs because the previous HEAD would simply be
HEAD^
.使用 MR 的 git log 相对容易获得,因为以前的 HEAD 只是HEAD^
。
However, we also have privileged Master users who periodically push a series of commits to master all at once.但是,我们也有特权 Master 用户,他们会定期将一系列提交一次性推送到 Master。 In this scenario there is no way to figure out whatHEAD
was prior to the push.在这种情况下,无法确定推送之前的HEAD
是什么。For this reason I was hoping we could get a variable like
CI_PREV_COMMIT_SHA
or something similar which would provide this bit of information to the runner.出于这个原因,我希望我们能得到一个像CI_PREV_COMMIT_SHA
这样的变量或类似的东西,它可以为跑步者提供这一点信息。Prior to using GitLab, we were running automation with a post-receive hook in the bare repo, and this hook script is provided with both a previous and current REV.在使用 GitLab 之前,我们在裸存储库中使用 post-receive 钩子运行自动化,并且此钩子脚本与以前和当前的 REV 一起提供。
Now with GitLab CI runners, we have no way to replicate our script behavior without knowing what the previous REV was.现在有了 GitLab CI runners,我们无法在不知道以前的 REV 的情况下复制我们的脚本行为。
That has not been implemented yet though: you might need (as a crude workaround) to store that information in a file, with a shared folder accessible from your build environment: you might then be able to read that file on the next occurrence of your job.但这还没有实现:您可能需要(作为一种粗略的解决方法)将该信息存储在一个文件中,并从您的构建环境访问一个共享文件夹:然后您可能能够在下次出现您的文件时读取该文件工作。 [1]: https://gitlab.com/gitlab-org/gitlab/-/issues/17822 [1]: https : //gitlab.com/gitlab-org/gitlab/-/issues/17822
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.