简体   繁体   English

如何连接 Terraform 以创建从 GCP 中的私有 bitbucket 回购中提取的云构建触发器

[英]How to hook up Terraform to create Cloud Build Triggers that pull from a private bitbucket Repo In the GCP

I am setting up a terraform plan in order to create a cloud build trigger in the google cloud provider.我正在设置一个 terraform 计划,以便在谷歌云提供商中创建一个云构建触发器。 However the steps outlined in the terraform documentation are for public git repositories.但是,terraform 文档中概述的步骤适用于公共 git 存储库。 When I tried hooking up a private bitbucket repository I got a "repo not found" error.当我尝试连接私有 bitbucket 存储库时,出现“未找到存储库”错误。

resource "google_cloudbuild_trigger" "cloudbuild-trigger" {
  trigger_template {
    branch_name = "staging"
    repo_name = "BITBUCKET_TEAM_NAME/repo_name"
    dir = "site_dir"
  }

  filename = "cloudbuild.yml"
}

To provide access for a private repository — BitBucket provides an App Password .为了提供对私有存储库的访问——BitBucket 提供了一个应用密码

After creating such password with “Repository Read” permission you can form a URI with your App Password to the provide access for your repository.使用“存储库读取”权限创建此类密码后,您可以使用您的应用程序密码形成一个 URI,为您的存储库提供访问权限。

For example: https://YOUR_USERNAME:YOUR_APP_PASSWORD@bitbucket.org/YOUR-TEAM/YOUR-REPO.git and that URI will provide access for reading your repository without asking password.例如: https://YOUR_USERNAME:YOUR_APP_PASSWORD@bitbucket.org/YOUR-TEAM/YOUR-REPO.git并且该 URI 将提供读取存储库的访问权限,而无需询问密码。 Of course, you must understand the consequences of credentials exposure.当然,您必须了解凭据暴露的后果。

repo_name expects the name of the Cloud Source Repository not the bitbucket repo. repo_name需要 Cloud Source Repository 的名称,而不是 bitbucket 存储库。 Initially from the UI, we can connect cloud build to our bitbucket repo(private).最初从 UI 开始,我们可以将云构建连接到我们的 bitbucket 存储库(私有)。

In the setup, we can opt to mirror our repo in Cloud Source.在设置中,我们可以选择在 Cloud Source 中镜像我们的存储库。 We can then provide the Cloud Source repo name ti terraform.然后,我们可以提供 Cloud Source 存储库名称 ti terraform。 In this case, We don't have to pass any bitbucket credentials to terraform.在这种情况下,我们不必将任何 bitbucket 凭据传递给 terraform。

Fully featured Cloud Build triggers for BitBucket which react to events and show their results in BitBucket like you can create them in the UI or via REST API are not yet supported by the GCP Terraform provider. GCP Terraform 提供商尚不支持 BitBucket 的全功能 Cloud Build 触发器,它对事件做出反应并在 BitBucket 中显示其结果,就像您可以在 UI 中或通过 REST API 创建它们一样。

For external BitBucket servers there is an open GitHub issue to add this functionality.对于外部 BitBucket 服务器,有一个开放的GitHub 问题来添加此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 Terraform Cloud Build Triggers 构建步骤配置到 GCP 项目 - Provisioning Terraform Cloud Build Triggers build step to GCP project 如何将 API 参数传递给 GCP 云构建触发器 - How to pass API parameters to GCP cloud build triggers 将Bitbucket存储库镜像到GCP云源存储库时出现问题 - Problem mirroring Bitbucket repo to GCP Cloud Source Repo 想要使用 terraform 在 gcp 中的单独 vpc 上创建具有私有和公共 ip 的云 sql 实例 - Want to create a cloud sql instance with private and public ip on a separate vpc in gcp using terraform 无法在 GCP 云 MySQL 中创建触发器 - Unable to create triggers in GCP cloud MySQL 如何在云运行构建中访问私有 git 存储库 - How to access a private git repo in cloud run build 如何在 GCP Cloud Build 的 Terraform Docker Provider 中构建和推送 docker 映像 - How to build and push a docker image in a Terraform Docker Provider by GCP Cloud Build 为 Terraform Cloud 设置 Google Cloud Platform (GCP) 身份验证 - Set up Google Cloud Platform (GCP) authentication for Terraform Cloud 无法通过 Terraform 使用 GCP Cloud Build 对 GitHub 存储库进行身份验证 - Cannot authenticate GitHub repository with GCP Cloud Build via Terraform 使用 GCP、Cloud Build 和 Terraform 工作区的临时环境 - Ephemeral environments using GCP, Cloud Build and Terraform workspaces
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM