AWS Codebuild - 仅当提交消息包含字符串时才继续构建

mah*_*off 7 git continuous-integration amazon-web-services aws-codebuild

我正在尝试做类似 CircleCI 的 [ci skip] 标签的事情,它可以让开发人员“选择加入”构建项目,即提交消息决定构建是否继续。提交消息中的字符串buildit将使构建继续进行,否则它将在预构建阶段终止。

我知道这个项目: https: //github.com/thii/aws-codebuild-extras。它提供 git 消息作为环境变量,但不确定如何在 buildspec.yml 中添加,如果消息中缺少if statement该消息,则会提前终止构建。buildit

小智 1

构建规范文件中至少有一个 IF 语句。

version: 0.2
phases:
  pre_build:
    commands:
      - echo Installing source NPM dependencies...
      - npm install
      - |
        if [ "$TEST_ONLY" -ne "TRUE" ] ; then 
          echo "NEED TO SET $ENV"
          exit 1
        fi
Run Code Online (Sandbox Code Playgroud)