I am trying to create an automatic pipeline in gitlab-runner that will apply all the changes in the most recent git push
. It is picking up the latest commit in the push (using $CI_COMMIT_SHA variable in gitlab-runner). However, if a push had multiple commits, it ignores the older ones. Thus, all the changes are not applied in the application.
I have the following queries:
- Is there any Id assigned to each git push? Basically given a git push Id, is there a way to find all the underlying commits?
- Is there a way in gitlab-runner to find all the files committed in the latest git push? Also, I would prefer to maintain the order in which they were committed.
- I saw that
git cherry
can give me the list of unpushed commits. Is there a way, I can pass the info to gitlab-runner via variables?
Thanks in advance
I solved this by getting the latest push event through GitLab API, getting the latest commits by spawning the git CLI tool locally, and then cross-checking them.
Push event will have
push_data
property, which will tell you which commit range was in the push. https://docs.gitlab.com/ee/api/events.html#list-a-projects-visible-eventsMy shortened node.js code: