Add CI_COMMIT_FORCE_PUSH variable
What does this MR do and why?
This (untested) change exposes a variable to CI pipelines that allow conditional branching when a force push occurs. The current version of gitlab incorrectly determines the list of files changed when a force push occurs. It would be possible to work around this incorrect handling by giving pipeline authors a variable for branching when a force push has occurred. This MR implements that variable.
- Related to add CI_FORCE_PUSH variable (#409307)
- Related to CI_COMMIT_BEFORE_SHA takes wrong value upon bra... (#357394)
How to set up and validate locally
Configure a .gitlab-ci.yml file with the following:
test:
stage: test
script:
- echo $CI_COMMIT_FORCE_PUSH
Run the following:
git init
touch foo
git add .
git commit -m "foo"
touch bar
git commit -m "bar"
git push origin main
git reset --hard HEAD~1
touch baz
git add .
git commit -m "baz"
git push origin main --force
Observe that the final push triggers a pipeline wherein CI_COMMIT_FORCE_PUSH is set to "true".
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Marcel Amirault