【发布时间】:2021-08-06 21:01:24
【问题描述】:
我正在使用 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。
有没有办法用我当前的配置获取分支的名称?
【问题讨论】:
-
我尝试了很多东西,唯一有效的是:stackoverflow.com/a/58408951/8650621
-
您现在可以直接从 CodePipeline 将环境变量发送到 buildspec.yml aws.amazon.com/about-aws/whats-new/2019/10/…
标签: aws-codepipeline aws-codebuild aws-codecommit