[gitlab ci] Access previous HEAD info in CI job

When a CI build runs I can see in the output "Previous HEAD position was xxxxxxx". Now I'd like to access this value in a build script to do something like "git diff --name-only HEAD xxxxxxx". How can I do that? In one push there can be several commits, so just doing a "git diff --name-only HEAD HEAD~1" could probably miss some files...

Duplicates gitlab-org/gitlab-ci#393

Edited by Jason Yavorsky