Hi,
I’m trying to link a private Gitlab repository to Netlify with Netlify API (with curl).
First I create deploy key with endpoint /deploy_keys.
Then I add Netlify webhook to my Gitlab project with these params :
url=https:%2F%2Fapi.netlify.com%2Fhooks%2Fgitlab&confidential_issues_events=false&confidential_note_events=false&deployment_events=false&enable_ssl_verification=true&issues_events=false&job_events=false&merge_request_events=true¬e_events=false&pipeline_events=false&push_events=true&releases_events=false&tag_push_events=false&wiki_page_events=false
→ webhook is added and if I test a push event from gitlab i’m getting a 204, so it seems to work
→ I tried before with token param set to Netlify deploy public key but webhook was not added
Then, I update Netlify site with these params:
{"build_settings":{"env":{"NODE_VERSION":"14"}},"repo":{"provider":"gitlab","id":XXXXXXXX,"repo_path":"my-private-repo-path","public_repo":false,"private_logs":true,"repo_branch":"prod","cmd":"npm\u0020run\u0020generate","dir":"dist","deploy_key_id":"XXXXXXXXXXXXX"}}
→ it seems to work but when I go to deploys page I can see deploy failed with these details :
6:49:44 PM: Build ready to start
6:49:46 PM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)
6:49:46 PM: build-image tag: v4.5.3
6:49:46 PM: buildbot version: 94cf4881e10a7b2d529971a176d6ede22bcaeb38
6:49:46 PM: Fetching cached dependencies
6:49:46 PM: Failed to fetch cache, continuing with build
6:49:46 PM: Starting to prepare the repo for build
6:49:47 PM: User git error while checking for ref refs/heads/prod
6:49:47 PM: Creating deploy upload records
6:49:47 PM: Failing build: Failed to prepare repo
6:49:47 PM: Failed during stage 'preparing repo': error checking for ref: Warning: Permanently added 'gitlab.com' (ECDSA) to the list of known hosts.
git@gitlab.com: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
: exit status 128
6:49:47 PM: Finished processing build request in 914.953513ms
With another Netlify site, I linked another private repository manually using Neltify UI and it works fine, when I compare both configurations on Netlify and Gitlab all seems to be equal.
Could you tell me what I’m doing wrong please?
@fool you said on your first post “you’ll need to put the public_key
in place at your git provider”, but where do I have to do that? In my Gitlab profile in ssh keys? I didn’t do that with the Netlify/Gitlab link I added manually and it works…
Thanks for your help!