简体   繁体   English

Gitlab CI:获取自上次运行以来更改的文件列表

[英]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 what HEAD 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.

相关问题 我怎样才能获得自从我上次使用Git以来在远程服务器上更改的唯一文件列表 - How can I get JUST a unique list of files that changed on remote server since my last pull with Git 自上次使用git / gerrit在Jenkins / Hudson中生成以来,如何获取已更改文件的列表 - How to get list of changed files since last build in Jenkins/Hudson with git/gerrit 获取自上次提交以来已删除文件的列表 - Get a list of the deleted files since the last commit 如果存在合并,如何显示自上次提交以来已更改文件的列表? - How to show a list of changed files since last commit if there was a merge? Git:获取自上次推送以来所有更改的文件 - Git: Get all changed files since the last push gitlab CI 中的 LFTP:文件不会在 FTP 服务器上更新,即使它们在最后一次提交中被更改 - LFTP in gitlab CI: files are not updated on FTP server even if they are changed in the last commit 自从在git中创建分支以来如何获取已更改文件的列表 - How to get the list of changed files since the creation of a branch in git 如何获取自创建分支以来更改文件的当前文件路径列表 - How to get list of current filepaths of changed files since creation of branch GitLab CI/CD:仅在特定目录中的文件发生更改时运行作业 - GitLab CI/CD: Run jobs only when files in a specific directory have changed 我们如何创建自上次部署以来已更改的文件列表? 使用Git - How do we create a list of files which have changed since the last deployment? Using Git
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM