"fatal: not a git repository (or any of the parent directories): .git" in bitbucket-pipelines.yml
Asked by Larry Chiem:

I can't get past the "not a git repository" issue. {#toc-hId--354147002}
------------------------------------------------------------------------

1. I created a self-hosted windows runner in bitbucket.
2. I followed the commands from creating the self-hosted runner
   1. download the runner zip \[I downloaded it into my repo\]
   2. unzip the file \[within the repo\]
   3. launched the runner
3. Edited my bitbucket-pipelines.yml file to build and test:

Saw this documentation on [Configure your runner in bitbucket-pipelines.yml](https://support.atlassian.com/bitbucket-cloud/docs/configure-your-runner-in-bitbucket-pipelines-yml/)

Here's my **bitbucket-pipelines.yml**   

```
pipelines:

  default:

   - step:

      name: Build and Test with self.hosted runners

      runs-on:

        - self.hosted

        - windows

      clone:

        # disable SSL verification during git clone and allow using a self-signed certificate.
 
        skip-ssl-verify: true

        enabled: true

      script:

         - ls -R $BITBUCKET_CLONE_DIR
```

Pipeline failed.

*** ** * ** ***

+ $env:GIT_LFS_SKIP_SMUDGE = '1'; $env:GIT_SSL_NO_VERIFY = 'true'; git clone --branch='pipeline_larry' --depth 50 "[https://x-token-auth:$Env:REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/$env:BITBUCKET_REPO_FULL_NAME.git](https://x-token-auth:$Env%3AREPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/$env:BITBUCKET_REPO_FULL_NAME.git)" $env:BUILD_DIR  

<br />

<br />

Cloning into 'C:\caseSensitive\LarryNotes\atlassian-bitbucket-pipelines-runner\bin\..\temp\2888e4cb-a3e7-5f7e-b079-2dc61ee5f31a\1719575510684\build'...  

+ git reset --hard 431fada08becd292ba43d67ec2f08c6816bf3029  

<br />

fatal: not a git repository (or any of the parent directories): .git  

*** ** * ** ***

<br />

Why is this failing? Makes no sense to me.


Answers:
author: Theodora Boudale
body: Hi Larry and welcome to the community!

Can you please first check the **Prerequisites** for Windows runners listed on this page?

* <https://support.atlassian.com/bitbucket-cloud/docs/set-up-runners-for-windows/>

Please let me know if the Windows machine where you run the runner meets the requirements listed there and ensure to follow the steps in "Allow unsigned scripts to run in PowerShell".

<br />

You mention downloading the runner zip in the repo and unziping the file in the repo. This is not necessary, and I'm unsure if doing so may be causing that issue. When a Pipelines build runs with a Windows runner, the runner will clone the repo on the host machine and execute the script's command in that clone. When a step is finished, the runner will try to clean the build directory with the clone.

Can you please try downloading the zip elsewhere on that Windows machine (not in a clone of the repo)?  
Please also ensure that you open PowerShell as **administrator** before running the command that starts the runner.

<br />

On an unrelated note, environment variables in PowerShell are accessed with **$env:variable_name**, so you'll need to replace $BITBUCKET_CLONE_DIR in your script with $env:BITBUCKET_CLONE_DIR. This is not related to the error you get, but you'll need to change it so that the command works properly once the error is resolved.

Kind regards,  
Theodora


Tags: atl-pipelines

bitbucket-cloud

bitbucket-pipelines

cloud