Trigger bamboo from bitbucket Webhooks

Hamed Beiranvand July 24, 2019

Hi guys,

I spent a couple of hours to figure out why I'm not able to trigger a webhook from bitbucket to bamboo,  I found nothing yet 

Issue:
I want to detect when a PR is merged or a branch is deleted which as I see I'm not able to track these need from bamboo, so I need to have a webhook in bitbucket and call a bamboo reset api  base on this page
https://confluence.atlassian.com/bamboo/triggering-a-bamboo-build-from-bitbucket-cloud-using-webhooks-873949130.html

But this solution is now working because each time I got this error message

{"message":"Anonymous user can't access this resource. If it should be available, modify anonymous user permissions at Administration > Security settings","status-code":401}

 
The only access we have for Anonymous group is view which I see this is not enough to call this API from bitbucket
https://confluence.atlassian.com/bamboo/bamboo-permissions-369296034.html



So I don't know what to do and how to track if a PR is merged or a branch is deleted.

I would appreciate to tell me what the problem is


FYI: bamboo and bitbucket version is the latest one

1 answer

1 accepted

1 vote
Answer accepted
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 30, 2019

Hi @Hamed Beiranvand

To allow an anonymous user to trigger change detection you need to enable the following security option:

  • Admin >> Security settings >> [ ]Allow anonymous users to trigger remote repository change detection and Bamboo Specs detection

Your instance should be able to get the branch deletion even if there is no webhook configured. Bamboo has a feature for that. The branch detection feature is enabled by default and has the check interval configured in:

  • Admin >> General configuration >> Branch detection interval

Let me know if after configuring the security property you get it working.

Hamed Beiranvand August 1, 2019

@Daniel Santos Thank you for your reply. I really appreciate it.


About anonymous user, I think it's not a good idea in security perspective because it will enable the public to trigger the plan.


And about the branch deletion, I do not know the way to trigger a plan when a branch is deleted.


let me tell you what I want to do, for each PR a new environment would be created which it's supposed to be deleted when the PR is merged or deleted.

So I created a new plan for this case, but I need to trigger it when the PR is merged or deleted.

Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 13, 2019

Hi @Hamed Beiranvand

I'm not sure if I really understood you from the beginning.

About anonymous user, I think it's not a good idea in security perspective because it will enable the public to trigger the plan.

It would not be free to everyone. Only the IPs configured in the repository trigger will be able to use the resource, but I understand your concern.


And about the branch deletion, I do not know the way to trigger a plan when a branch is deleted.

If I understand you correctly you are trying run a build to check the changes of a pull request, is that correct? I think I didn't get that from the first message.

Have you tried the Plan configuration >> Branches >> When pull request is created configuration?

let me tell you what I want to do, for each PR a new environment would be created which it's supposed to be deleted when the PR is merged or deleted.

So I created a new plan for this case, but I need to trigger it when the PR is merged or deleted.

 Please check that configuration. It should work for what you need.

Hamed Beiranvand August 20, 2019

I already know about this part

 

Plan configuration >> Branches >> When pull request

 

and about 

 


It would not be free to everyone. Only the IPs configured in the repository trigger will be able to use the resource

 


we do not allow to this solution for security stuff 


but anyway I really appreciate for your time to spent to answer my question

Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 26, 2019

Hi @Hamed Beiranvand

sorry about the late reply, but I have a question for you.

  • Have you tried adding user and password in your request URL in bitbucket webhook?
    It would be something like:
    https://<USER>:<PASSWROD>@BAMBOO_URL/rest/triggers/1.0/remote/changeDetection?planKey=PLAN-KEY&skipBranches=false

I just wanted to make sure you tried this option before giving up.
Let me know if that is an option to move forward.

tuimazy2008 February 18, 2021

Hello @Daniel Santos , It seems that I have same issue, I can't trigger bamboo plan using Bitbucket webhook, I tried your last suggestion:  

/<USER>:<PASSWROD>@BAMBOO_URL

 But unfortunately it not helped

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events