Self hosted gitlab support

I am trying out deployment using netlify cli option from self hosted gitlab repository to build. However I can link the site from the repository but unable to build the site from the my private repository hosted under the my own gitlab service in my premise. I followed this link,

I am getting the following error in deploy log,

1:10:47 PM: Build ready to start

1:10:49 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63

1:10:49 PM: build-image tag: v3.3.2

1:10:49 PM: buildbot version: 75cd99f62ada9e21edea53208e8baf0eab85a045

1:10:49 PM: Fetching cached dependencies

1:10:49 PM: Failed to fetch cache, continuing with build

1:10:49 PM: Starting to prepare the repo for build

1:10:49 PM: git ref refs/heads/master does not exist or you do not have permission

1:10:49 PM: Failing build: Failed to prepare repo

1:10:49 PM: failed during stage ‘preparing repo’: git ref refs/heads/master does not exist

Also under the Build settings, the repository value dont have the git url (only username/reponame)

Build settings

Repository: rinshad_ka/test.git

I am trying from repo in self hosted private gitlab service. please help


That sounds like you weren’t able to set up the deploy key successfully, @rinshadka. You’ll want to check that you have set the deploy key correctly so that our buildbots have access to your repo.

You can read more about this in our netlify-cli docs.

I had the same issue with my self hosted gitlab repo.
After looking at the source of the netlify CLI, I found a workaround:

  1. Create a site via CLI with netlify sites:create -c -m
  2. cd into the repo directory
  3. netlify init -m
  4. Manually select the site created before

After this steps, the build settings on the admin page for the site showed the correct gitlab url like and everything works now.


I just discovered @tommmlij as well. A bit frustrating as I spent several days figuring out a workaround using the API, and before that we thought we couldn’t use Netlify’s CI integration because it wasn’t playing nice with our GitLab. The existence of netlify sites:create -c -m is rather hidden - not even mentioned on the netlify init command docs (which is almost the same functionality AFAIK).

In our case we just had to do netlify sites:create --with-ci --manual, and enter the SSH url for the repo. We didn’t do the second netlify init -m command.

Hi, Thanks for the updates. Really sorry for the trouble. I’m passing this thread along to our CLI team so they can get this documented better.

Just wanted to report that we’ve got a bug filed to fix the misbehavior of netlify init --manual if you want to track it here:

Thanks so much for helping us get this sorted out!