Fix GIT_DEPTH variable precedence in git operations

What does this MR do?

This MR fixes the issue where the GIT_DEPTH variable does not follow CI/CD variable precedence rules when set in .gitlab-ci.yml vs project/pipeline variables.

Related issues

Closes #28894 (closed)

Author's checklist

  • Follow the Contribution Guidelines
  • If this MR is the resolution of a security issue, I have read the security process for developers and understand I must not share details of this security issue outside of this MR
  • This change is backward compatible. If not, please include steps to communicate to our users
  • Tests added for new functionality. If not, please raise an issue to follow up
  • Documentation added/updated, if needed

How to test

  1. Create a project with a .gitlab-ci.yml that sets GIT_DEPTH: 5
  2. Set a project CI/CD variable GIT_DEPTH with value 2
  3. Run a pipeline and check the job log
  4. The log should show "Fetching changes with git depth set to 2..." (project variable takes precedence)

What are the relevant issue numbers?

Closes #28894 (closed)

Does this MR meet the acceptance criteria?

  • Code review guidelines
  • Merge request performance guidelines
  • Style guides
  • Database guides
  • Separation of EE specific content

Merge request checklist

  • Tests
    • Added for this feature/bug
    • All builds are passing
  • Changelog entry
  • Documentation (if required)
  • Code review

Merge request reports

Loading