Mirroring Cloud Source Repositories to GitLab repositories - google-cloud-platform

Is it possible to mirror from Cloud Source Repositories to GitLab repositories. Like I want to host the code in index.js in google dialogflow in our enterprise gitlab repository.

Related

Mirror Bitbucket Server repo in Bitbucket Cloud?

As part of some infrastructure code I am writing with Terraform, I am trying to deploy a Google cloud function. However, in the terraform code for the function, it is mandatory to specify a Cloud Source Repositories repo that the function will pull the application code from, using the "source_repository" and "url" fields.
Currently, what I had set up in my sandbox, was a mirrored connection from cloud source repositories to my own bitbucket cloud repository where the application code was being commmited to, however once I tried to copy this to our company's bitbucket server account, I have realised there is no option to simply mirror a bitbucket server repository in cloud source repositories (it's only available for bitbucket cloud).
Therefore my plan was to mirror a bitbucket server repo, into a bitbucket cloud repo, into a Google Cloud Source Repository which my Cloud Function could pull the code from. Has anyone experimented with this - I already tried but there doesn't seem to be an option for a web hook to mirror it.
Any help appreciated. I have attached a diagram that might help explain the solution i am wanting. The part in green is what I want to add Bitbucket Mirror Image Architecture Diagram

Mirror Bitbucket Repositories to Google Cloud Source Repositories

I am trying to build CICD using cloud build in GCP. As a part of that, I am trying to mirror the repositories from Bitbucket into CSR. But I am not able to mirror the repositories. I am able to view the repositories that are present in the Bitbucket after authorizing to bitbucket from GCP.
https://cloud.google.com/build/docs/automating-builds/create-manage-triggers
https://cloud.google.com/source-repositories/docs/mirroring-a-bitbucket-repository
IAM Permissions:
I have Admin access for Source Repositories in GCP along with Cloud Build Service Account.
I have Admin access for the bitbucket repository and the workspace. The workspace in bitbucket is private.
Per the Cloud Source Repositories
If you are mirroring your Bitbucket repository to Cloud Source
Repositories to integrate with Cloud Build and do not need any other
Cloud Source Repositories features, follow the Cloud Build
instructions on building repositories from Bitbucket Cloud instead.
The referenced guide, Building repositories from Bitbucket Cloud, mentions that you need to create an SSH key in order to authenticate your connection to Bitbucket Cloud.
Bitbucket documenentation also confirms that the connection fails if there is no SSH key.
I have learned that the repositories in the Bitbucket are in Private Workspace and are IP restricted. So adding a set of Google Cloud's Public IPs solved this issue.

How to integrate cloudbuild (GCP) with CodeCommit

I have my source code in code commit and my new client is with GCP. They wanted to connect code-commit from google cloud-build, is there any option for that ?
Given the fact that GCP and AWS are competitor cloud providers I would say that you will not find a way to trigger Google Cloud Build from AWS CodeCommit, which is what I believe you mean with "integrate" both products.
What I would do in your scenario is replicate you CodeCommit repository in it's equivalent in GCP, which is Google Cloud Source Repositories. You can find a tutorial for how to setup
Build Triggers from Cloud Source Repositories in this documentation. Another option is pushing a container ready to be deployed into Cloud Registry and deploying that instead, you can follow these steps for that.

Google Cloud Build - Self hosted bitbucket server

In my company we are using Google Cloud to develop our application and we'd like to use Cloud Build for CD/CI. The problem is that our Bitbucket server is self hosted, not at Bitbucket's cloud. When we try to add a new repository, Google Cloud redirects us to Bitbucket's cloud and I don't find any way to connect our company repository.
Is this currently possible?
I'm stucked in this screen:
Thanks
Cloud Build's Bitbucket Server and Bitbucket Data Center integration is now in GCP. We can build repositories from Bitbucket Server and Bitbucket Data Center, including on-premises instances.
https://cloud.google.com/build/docs/automating-builds/build-repos-from-bitbucket-data-center

Problem mirroring Bitbucket repo to GCP Cloud Source Repo

I'm attempting to setup CICD for a GCP Cloud Function and App-Engine deployment. The repo is in Bitbucket and I am following the instructions found here to create a mirror between my Bitbucket repo and a GCP Cloud Source repo.
Using the GCP Cloud Source "Connect external repository" UI I am able to select my GCP project, select Bitbucket as the Git provider, connect to Bitbucket using my credentials (I am admin on the Bitbucket repo), and select the desired Bitbucket repo. Then when I click the "Connect selected repository" I get about a 30s delay and finally a simple "Failed to connect repositories" error message with no further explanation as to why. GCP logging shows nothing.
Any ideas would be appreciated.
Thanks
Ensure that you have enabled the source repos API. Retrospectively I guess this is obvious, because the Bitbucket webhooks need to call out to Google's API to announce when changes occur on the repo.
The GCP API is called Cloud Source Repositories API, and the service name is sourcerepo.googleapis.com
https://console.cloud.google.com/apis/api/sourcerepo.googleapis.com