我正在使用 codecommit、codebuild 和 codepipeline,这样每次我在分支上提交时,相关的管道都会从 codebuild 中的 codecommit 构建(然后是部署/失效)
我的 package.json 中有 3 个不同的脚本,分别称为 build-master、build-test 和 build-prod,分别与 master、test 和 prod 的 3 个分支相关联。
# buildspec.yml
phases:
install:
commands:
- yarn --dev
pre_build:
commands:
- aws configure set preview.cloudfront true
- bash -c 'echo "Build started `date` on bucket s3://xx.xxxxxx.$CODEBUILD_SOURCE_VERSION.web"'
build:
commands:
- bash -c 'yarn build-$CODEBUILD_SOURCE_VERSION'
artifacts:
files:
- '**/*'
base-directory: 'dist'
name: xxxx-xxxx.$(date +%Y-%m-%d-%h-%M-%s).$(CODEBUILD_SOURCE_VERSION)
$CODEBUILD_SOURCE_VERSION 给了我管道的 arn。我尝试了 codebuild 提供的其他变量,但无济于事。
我还尝试使用 bash -c 从 git 获取分支,但在 codebuild 中我无权访问 repo。
有没有办法用我当前的配置获取分支的名称?