Search code examples
gitgoogle-cloud-buildbitbucket-cloud

Cloud build with bitbucket repository sync


I'm using Cloud Build to deploy some cloud functions and the original repo is hosted on bitbucket cloud. I've mirrored the repo, created a trigger to start the build process and everything is working, but I have to do a manual sync to have the same content on both repos. Is there a way to have them synchronised automatically? I can always do a pull inside the Cloud Build script, but it doesn't work when I change the Cloud build .yaml file. Any other way to overcome this issue?

Thanks


Solution

  • A Cloud Build trigger automatically starts a build whenever you make any changes to your source code. You can configure the trigger to build your code on any changes to the source repository or only changes that match certain criteria.

    You can also refer to document on how to Automate builds in response to webhook events.

    As you have mentioned

    repo is hosted on bitbucket cloud. I've mirrored the repo

    I assume you are using cloud build 1st gen for mirroring your bitbucket cloud, However as mentioned here, In the backend cloud build uses cloud source repositories only to sync code changes.

    As stated here

    After you set up mirroring, Cloud Source Repositories automatically syncs your repository with the mirrored repository when a user commits a change. Cloud Source Repositories lets you view the last time your mirrored repository was synced and manually force a sync if necessary.

    It looks like an issue with sync between CSR(Cloud Source Repository) and Bitbucket cloud.

    Hence, Try to disconnect your BitBucket repository and then reconnect the repository by creating a new trigger or deleting the connection in Cloud Source Repository and then adding the same repository again.And also have a look at link which might help you.