Skip to content

Draft: Add CI variable CI_COMMIT_SAME_AS_DEFAULT_BRANCH

Furkan Ayhan requested to merge 15170-branch-commit-diff-variable into master

What does this MR do and why?

This MR adds a new CI variable CI_COMMIT_SAME_AS_DEFAULT_BRANCH, which is used for determining if the pipeline sha is the same as the main branch sha. It returns either true as a string or nothing.

It'll be mainly used for new branches with no new commits.

Related to #15170 (closed)

Screenshots or screen recordings

Example config:

echo:
  script:
    - echo $CI_COMMIT_SAME_AS_DEFAULT_BRANCH

test1:
  script: exit 0
  rules:
    - if: $CI_COMMIT_SAME_AS_DEFAULT_BRANCH

test2:
  script: exit 0
  rules:
    - if: '$CI_COMMIT_SAME_AS_DEFAULT_BRANCH'

test3:
  script: exit 0
  rules:
    - if: '$CI_COMMIT_SAME_AS_DEFAULT_BRANCH == "true"'

test4:
  script: exit 0
  rules:
    - if: '$CI_COMMIT_SAME_AS_DEFAULT_BRANCH != "true"'

When you run on the main branch: Screen_Shot_2022-02-08_at_12.58.43 Screen_Shot_2022-02-08_at_12.59.46

When you run on another branch with a new commit: Screen_Shot_2022-02-08_at_12.58.49 Screen_Shot_2022-02-08_at_12.59.50

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Furkan Ayhan

Merge request reports

Loading