Search code examples
google-apis-explorergoogle-cloud-build

How to Connect Bitbucket repos to Google cloud source repository using REST API


I'm using cloud build service for Continuous Integration and able to create bitbucket mirror in google cloud source repository but, I want to mirror all bitbucket repos to cloud source repository. I dont want to create manually all the time.

I saw [Rest API to Create mirror repos][1] this. but no idea how to do it.

below is body I have to pass to create mirror repos. please help me.

{
  "name": "",
  "size": 0,
  "url": "",
  "mirrorConfig": {
    "deployKeyId": "",
    "url": "",
    "webhookId": ""
  },
  "pubsubConfigs": {}
}```


  [1]: https://cloud.google.com/source-repositories/docs/reference/rest/v1/projects.repos/create

Solution

  • Hey @SHASHIKUMARKL have expereminted your idea using the rest api using the endpoint /v1/projects.repos/create , However, it won't work because the mirrorConfig properity is read only field. so you cannot change it to automate the process of mirroring between GCP and BitBucket. This endpoint /v1/projects.repos/create is intended to create repos not to mirror them. The only way to mirror repos is one by one following this guide