排查问题

本页面介绍了如何解决 Secure Source Manager 的问题。

创建代码库时显示错误消息

尝试创建代码库时,系统会显示以下错误:

There was an error while loading /repo/create. Try refreshing the page.

此问题会在以下情况下出现:

  • 您的项目中未启用 Secure Source Manager API。
  • 您没有项目的代码库管理员角色,也没有在 Secure Source Manager 实例中创建代码库的权限。

要解决此问题,请执行以下操作:

  • 在项目中启用 Secure Source Manager API
  • 请让管理员为您授予以下角色:
    • 您项目的 Repo Admin (roles/securesourcemanager.repoAdmin) 角色。
    • Secure Source Manager 实例上的 Instance Accessor (roles/securesourcemanager.instanceAccessor)。
    • Secure Source Manager 实例上的实例代码库创建者 (roles/securesourcemanager.instanceRepositoryCreator)。

如需了解详情,请参阅使用 IAM 进行访问权限控制

在 Mac 上克隆代码库时收到错误消息

尝试克隆代码库时,系统会显示以下错误:

git: 'credential-gcloud.sh' is not a git command.  See 'git --help'.
fatal: Authentication failed for [repo-url]

此问题会在以下情况下出现:

  • gcloud CLI 是使用 Homebrew 或其他非标准安装方式安装的。
  • git-credential-gcloud.sh 未添加到您的 PATH 中。

要解决此问题,请执行以下操作:

  • 运行 source $HOMEBREW_PREFIX/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc
  • 运行以下命令,检查 git-credential-gcloud.sh 是否位于您的路径中:

    which git-credential-gcloud.sh
    

Git HTTPS 请求失败,并显示“权限遭拒”或“未经授权”错误

当尝试通过 HTTPS 运行 Git 命令时,系统会显示“权限遭拒”或“未经授权”错误消息。

如果出现以下情况之一,则会发生此问题:

  • 全局 Git 配置文件缺少 Secure Source Manager 身份验证帮助程序。
  • Git 的内置凭据存储区正在使用,而不是调用 Secure Source Manager 身份验证帮助程序来获取新凭据。
  • 系统凭据帮助程序正在使用中,而不是调用 Secure Source Manager 身份验证帮助程序来获取新凭据。
  • 使用 HTTPS 与 Secure Source Manager 代码库交互时,会使用旧版 Google Cloud CLI。Secure Source Manager 需要 Google Cloud CLI 395.0.0 版或更高版本。

要解决此问题,请执行以下操作:

  1. 运行以下命令以确定全局 Git 配置的内容。

    git config --list | grep credential
    
  2. 如果您在 macOS 上看到任何类似于 *credential*.helper=store 的行,或在 Windows 操作系统上看到任何类似于 credential.helper = manager 的行,请移除这些行,然后使用 gcloud auth login 重新进行身份验证,然后再尝试执行 Git 命令。

  3. 如果响应不包含 credential.https://*.*.sourcemanager.dev.helper=gcloud.sh(在 macOS 或 Linux 上)或 credential.https://*.*.sourcemanager.dev.helper=gcloud.cmd(在 Windows 上),请将 Secure Source Manager 身份验证帮助程序添加到您的全局 Git 配置中:

    Linux

    1. 如需将 Secure Source Manager 身份验证帮助程序添加到全局 Git 配置,请运行以下命令:

      git config --global credential.'https://*.*.sourcemanager.dev'.helper gcloud.sh
      
    2. 运行以下命令,验证身份验证帮助程序行是否已添加到您的全局 Git 配置中:

      git config --list | grep credential
      

      输出应包含 credential.https://*.*.sourcemanager.dev.helper=gcloud.sh

    3. 运行 gcloud auth login 进行身份验证。

    4. 运行 Git 命令以测试身份验证。

    Windows

    1. 按照安装 Git 和 Google Cloud CLI 说明检查您的 gcloud CLI 版本。
    2. 如需将 Secure Source Manager 身份验证帮助程序添加到全局 Git 配置,请运行以下命令:

      git config --global credential.https://*.*.sourcemanager.dev.helper gcloud.cmd
      
    3. 运行以下命令,验证身份验证帮助程序行是否已添加到您的全局 Git 配置中:

      git config --list | grep credential
      

      输出应包含 credential.https://*.*.sourcemanager.dev.helper=gcloud.cmd

    4. 运行 gcloud auth login 进行身份验证。

    5. 运行 Git 命令以测试身份验证。

Git HTTPS 请求因令牌无效而失败

需要提供有效的 OAuth 令牌作为 Git HTTPS 操作的密码。这通常由 Git 凭据帮助程序处理,但它也可以与使用其他方法(例如应用默认凭据)生成的 OAuth 令牌搭配使用。

如果 Git 请求因令牌无效而被拒绝,通常意味着无法从传入的令牌中提取用户信息,此错误可能有多种原因:

  • 您的 gcloud CLI 登录会话可能已过期

    使用 gcloud auth login 重新登录。

  • 您的令牌的范围不足。OAuth 令牌应具有以下范围:

    • https://www.googleapis.com/auth/cloud-platform
    • https://www.googleapis.com/auth/userinfo.email

    您可以通过调用 curl https://oauth2.googleapis.com/tokeninfo?access_token=${TOKEN} 来检查令牌范围

  • 您使用的是通过 GKE 舰队工作负载身份生成的令牌:

  • 您拥有组织政策,可防止在特定安全边界之外使用令牌,例如情境感知访问权限:

    Secure Source Manager 本身不支持情境感知访问权限,请与支持团队联系以了解后续步骤。

项目未显示在网页界面产品选择器中

使用 Secure Source Manager 网页界面产品选择器时,您的项目未显示。

如果您有多个 Secure Source Manager 登录凭据,就会出现此问题。

要解决此问题,请执行以下操作:

  • 通过将以下内容附加到 Secure Source Manager 实例网址来清除 Cookie: /_oauth/consent

    例如,如果您的实例网址为 https://my-instance-098765432123.us-central1.sourcemanager.dev/,请在浏览器地址栏中输入 https://my-instance-098765432123.us-central1.sourcemanager.dev/_oauth/consent,然后使用正确的凭据登录。

触发器文件不触发构建

如果您提交触发器文件后,构建未按预期触发,则可能存在以下问题之一:

  • 触发器文件不在默认分支中。如需解决此问题,请将触发器文件移至默认分支。
  • 触发器文件的格式无效。如果代码库页面中显示一条横幅,内容为 Build triggers configuration error: ...,则表示存在此错误。 如需解决此问题,请参阅触发器文件架构。如果触发器文件配置正确,代码库页面中的横幅会显示 Valid build triggers configuration

构建触发器配置错误

triggers.yaml 文件提交到 Secure Source Manager 代码库后,系统会在横幅中显示以下错误:

Build cannot be created.

出现此问题的原因如下:

  • Cloud Build 配置文件包含无效选项。
  • Cloud Build 配置文件的格式无效。
  • Secure Source Manager 服务账号没有使用用户指定的 Cloud Build 服务账号所需的权限。

要解决此问题,请按以下步骤操作:

执行期间构建失败

如果成功触发了 build,但在执行期间失败,则关联的提交会具有“失败”提交状态。

如需排查构建失败问题,请在代码库页面中,点击失败的提交状态旁边的详情

系统会打开 Cloud Build 执行日志。如需详细了解如何排查 Cloud Build 中的 build 问题,请参阅排查 build 错误