【问题标题】:AWS Codecommit - Codebuild pass branch name to buildspec.ymlAWS Codecommit - Codebuild 将分支名称传递给 buildspec.yml
【发布时间】: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。

有没有办法用我当前的配置获取分支的名称?

【问题讨论】:

标签: aws-codepipeline aws-codebuild aws-codecommit


【解决方案1】:

您可以使用所需的环境变量为每个分支/管道设置不同的 CodeBuild 项目。

【讨论】:

    猜你喜欢
    • 2022-11-22
    • 2022-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-28
    • 1970-01-01
    • 2019-02-10
    • 2012-10-02
    相关资源
    最近更新 更多