在 AWS CodeBuild 的构建项目中,可以在“项目配置” -> “高级设置” -> “GitHub 源代码”中设置访问私有回购库的信息。
以下是一些示例 yml 文件,用于在 AWS CodeBuild 中使用次要源代码仓库:
version: 0.2
env:
variables:
NODE_ENV: "production"
phases:
install:
commands:
- npm install
pre_build:
commands:
- git clone https://github.com/my-org/my-private-repo.git
- cd my-private-repo
- git checkout develop
build:
commands:
- npm run build
post_build:
commands:
- npm run deploy
version: 0.2
env:
variables:
NODE_ENV: "production"
phases:
install:
commands:
- npm install
pre_build:
commands:
- git config --global credential.helper '!aws codecommit credential-helper $@'
- git config --global credential.UseHttpPath true
- git clone https://git-codecommit.us-west-2.amazonaws.com/v1/repos/my-private-repo
- cd my-private-repo
- git checkout develop
build:
commands:
- npm run build
post_build:
commands:
- npm run deploy
这些示例文件演示了如何在 AWS CodeBuild 中使用次要源代码仓库,并可以通过访问私有存储库而进行安全的身份验证。