mahemoff
mahemoff

Reputation: 46409

AWS Codebuild - proceed to build only if commit message includes a string

I'm trying to do something like CircleCI's [ci skip] tag, which lets developers "opt in" to building the project, i.e. the commit message determines whether a build proceeds. A buildit string in commit message would make the build proceed, otherwise it terminates in pre-build stage.

I'm aware of this project: https://github.com/thii/aws-codebuild-extras. It provides the git message as an environment variable, but not sure how to add an if statement in the buildspec.yml which would terminate the build early if buildit is absent from the message.

Upvotes: 7

Views: 1452

Answers (1)

dev
dev

Reputation: 41

To at least have an IF statement in the buildspec file.

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

Upvotes: 1

Related Questions