使用Gitlab CI创建Git日志
当用户将代码提交到git存储库时,我们需要自动生成提交历史文件 可以使用Jenkins、Gitlab Webhooks和Jenkins Git Changelog插件完成。此外,还可以使用下面的git命令创建它使用Gitlab CI创建Git日志,gitlab,gitlab-ci,git-commit,git-log,git-webhooks,Gitlab,Gitlab Ci,Git Commit,Git Log,Git Webhooks,当用户将代码提交到git存储库时,我们需要自动生成提交历史文件 可以使用Jenkins、Gitlab Webhooks和Jenkins Git Changelog插件完成。此外,还可以使用下面的git命令创建它 $ git log --pretty=format:'At %ci, %cN committed %h : %s' --decorate --graph >log.log 但是,我们是否可以使用Gitlab CI/CD操作生成提交历史文件。该文件可以保存在git Reposito
$ git log --pretty=format:'At %ci, %cN committed %h : %s' --decorate --graph >log.log
但是,我们是否可以使用Gitlab CI/CD操作生成提交历史文件。该文件可以保存在git Repository或本地存储中
提交历史文件示例
* At 2018-11-16 18:02:21, kRiZ committed 1714a95 : Commit 4
* At 2018-11-15 16:06:06, kRiZ committed bab5c0c : Commit 3
* At 2018-11-14 18:05:09, kRiZ committed b3c9d86 : Commit 2
* At 2018-11-14 06:47:34, kRiZ committed 8e6ee30 : Add README.md
我相信在GitLab中有多种方法可以做到这一点。这里有一个:
.gitlab ci.yaml
文件。您可以在本地或使用GitLab的web UI来执行此操作.gitlab ci.yaml
文件中:
changelog:
image: docker:git
script:
- git log --pretty=format:'At %ci, %cN committed %h - %s' --decorate --graph >log.log
artifacts:
paths: [log.log]
changelog
作业log.log
文件将作为changelog
作业的工件提供- 与预安装了git的Docker映像一起使用
- 定义一个运行git命令的
changelog
- 定义将作为作业的一部分生成并存储的
,以便以后可以下载log.log
npx git-changelog-command-line -std -tec "
# Changelog
Changelog for {{ownerName}} {{repoName}}.
{{#tags}}
## {{name}}
{{#issues}}
{{#hasIssue}}
{{#hasLink}}
### {{name}} [{{issue}}]({{link}}) {{title}} {{#hasIssueType}} *{{issueType}}* {{/hasIssueType}} {{#hasLabels}} {{#labels}} *{{.}}* {{/labels}} {{/hasLabels}}
{{/hasLink}}
{{^hasLink}}
### {{name}} {{issue}} {{title}} {{#hasIssueType}} *{{issueType}}* {{/hasIssueType}} {{#hasLabels}} {{#labels}} *{{.}}* {{/labels}} {{/hasLabels}}
{{/hasLink}}
{{/hasIssue}}
{{^hasIssue}}
### {{name}}
{{/hasIssue}}
{{#commits}}
**{{{messageTitle}}}**
{{#messageBodyItems}}
* {{.}}
{{/messageBodyItems}}
[{{hash}}](https://github.com/{{ownerName}}/{{repoName}}/commit/{{hash}}) {{authorName}} *{{commitTime}}*
{{/commits}}
{{/issues}}
{{/tags}}
"
但是,我们是否有办法更新gitlab存储库中的日志文件?或者除了在服务器或工件中保存日志文件之外的其他方式?