Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 249
mahemoff Avatar asked Nov 15 '22 21:11

mahemoff


1 Answers

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
like image 134
dev Avatar answered Dec 22 '22 00:12

dev