Gitversion: Can't find the .git directory in /repo (Docker, Gitlab CI)

Created on 30 Jun 2019  路  3Comments  路  Source: GitTools/GitVersion

For a few days now, my Gitlab CI build has not been working.

I go through the Docker image "5.0.0.0-linux-debian-9-netcoreapp2.2".
Here is the error in these logs:

Fetching changes with git depth set to 1...
Initialized empty Git repository in /builds/developpeur/ci-project/.git/
Created fresh repository.
From http://gitlab.bee2link.local/developpeur/wafy-api
 * [new branch]      feature/ci -> origin/feature/ci
Checking out c320aefc as feature/ci...

Skipping Git submodules setup
$ docker run --rm --volume $PWD:/repo gittools/gitversion:5.0.0-linux-debian-9-netcoreapp2.2 /repo -output json -showvariable FullSemVer
INFO [06/30/19 12:35:12:70] Working directory: /repo
INFO [06/30/19 12:35:12:70] IsDynamicGitRepository: False
ERROR [06/30/19 12:35:12:73] An unexpected error occurred:
System.IO.DirectoryNotFoundException: Can't find the .git directory in /repo
   at GitVersion.GitPreparer.GetDotGitDirectory() in /home/vsts/work/1/s/src/GitVersionCore/GitPreparer.cs:line 154
   at GitVersion.GitPreparer.GetProjectRootDirectory() in /home/vsts/work/1/s/src/GitVersionCore/GitPreparer.cs:line 172
   at GitVersion.ConfigurationProvider.Verify(GitPreparer gitPreparer, IFileSystem fileSystem) in /home/vsts/work/1/s/src/GitVersionCore/Configuration/ConfigurationProvider.cs:line 282
   at GitVersion.Program.VerifyArgumentsAndRun() in /home/vsts/work/1/s/src/GitVersionExe/Program.cs:line 97
INFO [06/30/19 12:35:12:74] 
INFO [06/30/19 12:35:12:74] Attempting to show the current git graph (please include in issue): 
INFO [06/30/19 12:35:12:74] Showing max of 100 commits
ERROR: Job failed: exit code 1

My .gitlab-ci.yml is represented like this :

image: docker:stable

services:
  - name: docker:stable-dind

variables:
  DOCKER_DRIVER: overlay2

stages:
  - prepare

gitversion:
  stage: prepare
  variables:
    GIT_DEPTH: "1"
  before_script:
    - apk add git
  script:
    - docker run --rm
      --volume $PWD:/repo gittools/gitversion:5.0.0-linux-debian-9-netcoreapp2.2 /repo
      -output json -showvariable FullSemVer

Most helpful comment

@Scharpp could you please explain the cause with a little more detail? I'm currently facing the same issue.

All 3 comments

Are you certain the .git folder is within $PWD before you execute docker run? Can you do a tree command or similar to ensure that the .git folder is infact there?

Issue caused by concurrent execution with docker:dind service. Solved.

@Scharpp could you please explain the cause with a little more detail? I'm currently facing the same issue.

Was this page helpful?
0 / 5 - 0 ratings