2

I setup a test environment Codebuild + Github and am facing an issue: Every time I make a commit in Github, Codebuild will trigger 3 identical builds.

My buildspec.yml:

version: 0.2

phases:
  pre_build:
    commands:
      # Taskfile
      - curl -sL https://taskfile.dev/install.sh | sh

  build:
    commands:
        - ./bin/task build

  post_build:
    commands:
      - zip -r trigger.zip trigger

artifacts:
  files:
    - 'trigger.zip'
  discard-paths: yes

My code build config: Codebuild Config

And my build history: Build History

A few notable things:

  1. Manual builds only trigger one build
  2. The three builds are from the same hook and source version
  3. In github, the commit is only referencing the first of the 3 builds (latest commit points to build 13, previous commit points to build 9, etc).
  4. My project only has one branch (master)

Do you have any idea why this is happening, and how I can prevent this from happening again?

Eric
  • 477
  • 3
  • 17

2 Answers2

2

Thank you for using AWS CodeBuild.

Can you please check the responses of the webhook deliveries in GitHub webhook page? For every webhook delivery that triggered a build, CodeBuild will return a response with message "Webhook received and build started: [the link to the build]". You can check what webhook events triggered the builds, and then apply filters on the events.

Linghao Zhu
  • 661
  • 5
  • 3
2

The problem was with the github hooks: there were three of them.

I'm using Pulumi (terraform) to provision my AWS resources, including CodeBuild, and it looks like destroying the stack in Pulumi doesn't remove the github hook. The two extra hooks were leftovers from previous destroyed stacks.

I will investigate this further, but this is outside of the scope of this question.

Eric
  • 477
  • 3
  • 17
  • 1
    Had the exact same problem while using Terraform. I was working on this CodeBuild setup and had to apply/destroy the stack a couple of times. There were 2 wehbooks instead of 1. – Diogo Simões Apr 11 '22 at 15:45