问题
My requirement is I want to integrate my Bitbucket repo with the Azure DevOps CI server so that as soon as I push code in the bitbucket repo my pipeline should trigger in the Azure DevOps CI server for that I have created a webhook in the Bitbucket repo.
I have added the Azure DevOps CI server URL in the URL section and added secret in a secret section of the webhook of Bitbucket. the secret is personal access token generated in Azure DevOps Server. But while creating a webhook I am getting
Resource not available for anonymous access. Client authentication required. - Azure DevOps server
Even though I have added a secret why it is giving client authentication required error? what could be the reason?
P.S. - There is a scarcity of documentation for integration between Bitbucket repo and Azure DevOps CI server
Update : I have already enabled continuous integration on the triggers tab as suggested by Vito Liu-MSFT in the answer but still my pipeline is not getting triggered automatically when I push my code to feature/POC branch in bitbucket.
Yml file is as follows
resources:
repositories:
- repository: myRepo
type: externalgit
name: 'myRepo'
endpoint: myrepo
ref: feature/POC
trigger:
- feature/POC
回答1:
I push code in the bitbucket repo my pipeline should trigger in the Azure DevOps CI server
We could create service connection in the Azure DevOps, create pipeline in the Azure DevOps and select Bitbucket Cloud as source, then select Enable continuous integration
on the Triggers
tab. We could refer to this doc for more details.
Update1
Yes, We do not need Webhook in the Bitbucket if we enable continuous integration on the triggers tab. I have shared my test result, you could check the pic below.
Update2
According to the pic, it seems that you are using Azure Repos Git as the source instead of Bitbucket Cloud, note the source icon
Update3
Create yaml pipeline in the Azure DevOps, we need select Bitbucket Cloud as the code resource.
Then select Bitbucket repository, it will save the yaml file in the Bitbucket Repo instead of Azure DevOps repo, then we could configure the CI trigger.
I am using default yaml template do the test.
Note: we need update the field trigger, Azure DevOps has update the default branch to main instead of master
Note: If the yml file save in the Azure DevOps repo, it will not trigger the build if we push code in the Bitbucket repo.
Result:
回答2:
I have finally created webhook from below URL by replacing values in {} braces. Now i got 200 response in webhook
https://{hostName}/{collectionName}/_apis/public/pipelines/webhooks/{projectName}/{buildDefinitionId}/{repositoryKey}?api-version=6.0-preview.1
来源:https://stackoverflow.com/questions/65598750/integration-between-bitbucket-and-azure-devops