Eric
Eric

Reputation: 537

One github commit creates multiple Codebuild builds

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?

Upvotes: 2

Views: 1016

Answers (2)

Eric
Eric

Reputation: 537

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.

Upvotes: 2

Linghao Zhu
Linghao Zhu

Reputation: 736

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.

Upvotes: 2

Related Questions