1
votes

I'm trying to construct a CloudFormation YAML file for generating AWS CodeBuild project connecting to GitHub source using "Start a build under these conditions" section. Here's my YAML:

  CodeBuildProject:
  Type: AWS::CodeBuild::Project
  Properties:
    Name: RoiCalculator-EventPublisher-Master
    ServiceRole: XXXXXXXXXXXXXXX:role/CodeBuildRole
    Artifacts:
      Location: roicalculator-eventstore-deployment-artifacts
      Name: RoiCalculatorEventPublisher.zip
      Type: S3
    Environment:
      Type: LINUX_CONTAINER
      ComputeType: BUILD_GENERAL1_SMALL
      Image: aws/codebuild/standard:2.0
    Source:
      Type: GITHUB
      Location: https://github.com/XXXXXXXXXXX/RoiCalculator.EventStore
      BuildSpec: RoiCalculator.Serverless.EventPublisher/buildspec.yml
    Triggers:
      Webhook: true
      FilterGroups:
        - - Type: EVENT
            Pattern: PUSH
          - Type: FILE_PATH
            Pattern: RoiCalculator.Serverless.EventPublisher
            ExcludeMatchedPattern: true

When I run this CloudFormation YAML file, it's producing a CodeBuild project. However, it is applying filter to "Don't start a build under these conditions" section instead of "Start a build under these conditions" section. Here's what it is producing:

enter image description here

How do I get the FILE_PATH value to be applied to "Start a build under these conditions" section instead of "Don't start a build under these conditions" section?

If I manually modify the project and cut-and-paste FILE_PATH value from "Don't start a build under these conditions" section to "Start a build under these conditions" section then my CodeBuild project responds to GitHub events causing build to run as expected/desired.

1

1 Answers

2
votes

Just set the value of ExcludeMatchedPattern to false.

ExcludeMatchedPattern: Used to indicate that the pattern determines which webhook events do not trigger a build. If true, then a webhook event that does not match the pattern triggers a build. If false, then a webhook event that matches the pattern triggers a build.

      FilterGroups:
        - - Type: FILE_PATH
            Pattern: RoiCalculator.Serverless.EventPublisher
            ExcludeMatchedPattern: false