Integration between Bitbucket and Azure DevOps

只愿长相守 提交于 2021-01-29 12:57:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!