Skip to content

add CI_FORCE_PUSH variable

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Proposal

Please create a variable, $CI_FORCE_PUSH that is undefined for normal pushes and defined for force pushes.

When force pushing to a branch, Gitlab does not compare changed files correctly, see: #357394

If $CI_FORCE_PUSH was available, pipeline authors would be able to control what commit Gitlab is comparing files changes with. Here is an example usage:

some-job:
  script:  
    - some-script  
  rules:  
    - if: $CI_FORCE_PUSH
      changes:
        paths:
          - some-path
        compare_to: refs/heads/main
    - if: !$CI_FORCE_PUSH
      changes:
        - some-path
  stage: some-stage

(credit to: #369916 (comment 1365989412))

Edited by 🤖 GitLab Bot 🤖