选择其他分支而不是 master 作为 AWS CodeBuild 上的源存储库

Selecting other branch instead of master as a source repository on AWS CodeBuild

如何在使用 Github 作为源提供程序时在 AWS 代码部署上指定不同的分支而不是 master 分支?我看到在 select 分支的控制台中没有 select 的选项(可能是我错过了)。

我在 pre_build 阶段试图结帐到不同的分支,但它在 下载源 阶段失败了,因为 master分支没有 YAML 文件。

version: 0.1
phases:
  install:
    commands:
      - apt-get update -y
  pre_build:
    commands:
      - git checkout testbranch

您可以在开始构建时在 "source version" 字段中指定分支。它将接受 "git checkout" 接受的任何内容:提交 ID、分支、标签等

如果您想将默认分支(当不在单个构建中提供版本时)从 master 更改为其他分支,您必须使用 AWS CLI,因为 UI 中显然没有选项:

aws codebuild update-project --name your_project_name --source-version your_default_branch

在构建时添加新的源版本仍将根据文档覆盖此值:

If sourceVersion is specified at the project level, then this sourceVersion (at the build level) takes precedence.

https://docs.aws.amazon.com/codebuild/latest/APIReference/API_StartBuild.html#CodeBuild-StartBuild-request-sourceVersion