如何在CI期间在CodeBuild项目中设置CodeCommit repo分支名称

问题描述 投票:0回答:2

CodeCommit repo用作CodeBuild项目的源代码,但我希望构建一个特定的分支(例如:test),而不是默认分支(例如:dev)。我尝试设置构建命令如下,但仍采用默认分支:

version: 0.2
env:
  variables:
  CODEBUILD_SOURCE_VERSION: "test"

phases:
  build:
    commands:
     - echo Build started on `date`
 post_build:
    commands:
     - echo Build completed on `date`
     - echo This is the BranchName $CODEBUILD_SOURCE_VERSION
     - mvn clean -f ProjectName/pom.xml package
artifacts:
  files:
     - ProjectName/target/project.war
discard-paths: yes
git amazon-web-services aws-codebuild aws-codecommit
2个回答
0
投票

您将需要set sourceVersion in StartBuild来选择所需的分支。


0
投票

正如Unsigned所说,你需要在StartBuild中设置sourceVersion。如果您计划使用CloudWatch触发器基于提交分支进行构建,则默认使用主分支。要根据提交更改要部署的分支,请参阅下文。

根据目标:

  1. 配置输入
  2. 常量(JSON文本)
  3. {“sourceVersion”:“你的分支到构建”}

Image of Target Config

© www.soinside.com 2019 - 2024. All rights reserved.