I'm trying to mirror a bitbucket repo to gitlab and need to add a custom header, PRIVATE-TOKEN, containing my gitlab access token, in order to invoke gitlab's mirror pull API: https://gitlab.com/help/api/projects.md#start-the-pull-mirroring-process-for-a-project-starter.
There's no option for it in the webhook creation dialog. How can I do that?
-matthew
Hi @Matthew Adams ,
Welcome to the Atlassian Community!
Even if there is no possibility at the moment to add custom headers to Bitbucket Webhooks, the way to send authenticated WebHooks to Gitlab seems to be described in the below documentation page (from Gitlab):
In GitLab create a CI/CD for external repo, select Repo by URL and create the project.
GitLab will import the repository and enable Pull Mirroring.
In GitLab create a Personal Access Token with
api
scope. This will be used to authenticate requests from the web hook that will be created in Bitbucket to notify GitLab of new commits.In Bitbucket, from Settings > Webhooks, create a new web hook to notify GitLab of new commits.
The web hook URL should be set to the GitLab API to trigger pull mirroring, using the Personal Access Token we just generated for authentication.
https://gitlab.com/api/v4/projects/<PROJECT_ID>/mirror/pull?private_token=<PERSONAL_ACCESS_TOKEN>
The web hook Trigger should be set to ‘Repository Push’.
4. [....]
Together with the above one, you may want to also review below liks:
For the rest, it might be worth also mentioning that:
I hope this helps.
Cheers,
Dario
Hi @Dario B
Thanks for the suggestion. Adding the query string argument `private_token` to the gitlab url actually worked. Thanks!
-matthew
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is a compromise in this solution: the GitLab token is viewable in clear text by anyone who can see the project settings.
I'll see if I can chime in on the issues linked herein.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Honestly, custom headers are such an obvious feature, that is missing from webhooks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.