We need to generate commit history file automatically when user commits code into git repository.
It can be done using Jenkins, Gitlab Webhooks and Jenkins Git Changelog plugin. Also, it can be created using below git command.
$ git log --pretty=format:'At %ci, %cN committed %h : %s' --decorate --graph >log.log
But, is there anyway we can generate commit history file using Gitlab CI/CD operations. The file can be saved in git repositry or local storage.
Sample Commit History File
* 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
I'm sure there are multiple ways of doing this in GitLab. Here's one:
.gitlab-ci.yamlfile at the root of your repository. You can do this locally or using GitLab's web UI.Paste this snippet into your
.gitlab-ci.yamlfile:Either commit and push locally or commit on GitLab's Web UI. The
changelogjob will be triggered.log.logfile will be available as an artifact of thechangelogjobEssentially, with this snippet you are setting up GitLab's CI/CD system to:
gitpreinstalledchangelogjob that will run your git commandlog.logartifact that will be generated as part of the job and stored, so that you can download it afterwards.I'd also recommend checking out the GitLab CI/CD quickstart