[Support Guide] Linking a repository via API

Hi, @brunocc. You must also create a webhook for the site at Netlify and then add that webhook to GitLab so their service will trigger builds at Netlify when a push to the upstream repo occurs.

Our API cannot do this at GitLab. The GitLab APIs are used for this.

When you add a site using GitLab via the web UI we create the webhook using our API. We use your GitLab credential to make API calls at GitLab to add the new webhook to their service. This is how GitLab tells Netlify when a new commit occurs.

So, there are two extra steps:

  1. Make an API call at Netlify to make a new webhook for the site.
  2. Make an API call at GitLab to add that webhook to the repo.

If you do this in our web UI and open the browser devtools you will be able to see the exact API calls made to do this and what JSON content the API calls required in the Network tab.

When those steps are completed commits to the GitLab repo will trigger builds at Netlify. If there are questions about this, please let us know.

@fool it might be worth updating this post to explain that the repo id for bitbucket accounts consists of workspace/repoName rather than an integer id

great suggestion! Just updated that:

Note that there are two ID’s there - a GitHub repo ID (which you can get from their API ) - and similar ID’s are needed for GitLab and BitBucket as well - though for bitbucket at least the ID will have the format login/project instead of being a literal ID number.

Think that makes it clear enough? Do you think I need to call it out further anywhere else? You are my target audience so happy to take your suggestion, @shallow_alchemy :slight_smile:

I think that’s a perfect place to call it out, @fool . just one thing: mine isn’t login/project it’s workspaceName/project. My personal login has several workspaces.

thanks - updated per your advice - does that seem correct to you now? (I don’t use workspaces, so I think login/project is still correct for e.g. this repo of mine: Bitbucket)

1 Like