Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do you add custom HTTP headers to a webhook? Edited

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

 

1 answer

1 accepted

1 vote
Answer accepted
Dario B Atlassian Team Mar 04, 2020

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):

  • Using GitLab CI/CD with a Bitbucket Cloud repository
    1. In GitLab create a CI/CD for external repo, select Repo by URL and create the project.

      Create project

      GitLab will import the repository and enable Pull Mirroring.

    2. 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.

    3. 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:

  1. Two way integration can also be achieved by using the add-on: "Sync Bitbucket with GitLab"
  2. There are the below feature requests open in our system that you may want to vote for, and watch for updates:

 

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

Like Dario B likes this

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.

Like Dario B likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,869 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you