3

I have the following git branch scenario:

     F0---F1---Fn (feature: checked out)
    /
---D0---          (dev)

When I issue the command git merge-base dev HEAD on my local repository it returns the commit SHA for D0.

On our build server, which is a GitLab Runner for GitLab pipelines CI/CD, it clones the repository when a build is triggered. For some reason that I cannot figure out the same command on the server returns nothing.

Any idea what the issue is or what I am missing?

steve dunning
  • 153
  • 2
  • 11
  • 2
    Does the CI runner maybe do a shallow clone with limited history (for performance reasons), and the merge base is not part of it? – sschuberth Dec 17 '19 at 20:40
  • 2
    Yes, it does perform shallow cloning and the clone depth is configurable. Good point, I can try increasing. – steve dunning Dec 18 '19 at 13:40

2 Answers2

2

Increasing the fetch depth was the answer.

steve dunning
  • 153
  • 2
  • 11
0

The issue is with fetch depth. You just need to add the 'GIT_DEPTH' variable to the Gitlab job in which you are executing the git command.

for example,

deploy_release:
  stage: deploy
  variables:
    GIT_DEPTH: 1000 // (Whatever the suitable value for you)
  script: