When duplicate builds are unexpected
There could be several reasons why a CircleCI pipeline is triggered twice on a main branch. Here are a few possible explanations:
-
Multiple triggers: If you have set up multiple triggers for your CircleCI pipeline, such as both webhook and scheduled triggers, it is possible for the pipeline to be triggered multiple times. For example, a webhook trigger may occur due to a code push followed by a scheduled trigger that runs periodically.
-
Branch protection rules: If you have branch protection rules configured on your main branch in your version control system (e.g., GitHub or Bitbucket), certain actions like force-pushing or rebasing can result in the triggering of multiple pipeline runs.
-
Pull request related triggers: If your pipeline is configured to trigger on both push events and pull requests, it is possible for a pipeline to be triggered twice. This can occur if a pull request is opened or updated on the main branch, resulting in both push and pull request events being triggered. For this step, you can check this via the GitHub API as described here.
-
Workflow configuration: If your pipeline consists of multiple workflows and there are dependencies or conditions between them, it is possible for the main branch workflow to be triggered more than once if other dependent workflows are also triggered.
-
Configuration errors: Sometimes configuration errors or misconfigurations in your CircleCI pipeline configuration file (e.g.,
.circleci/config.yml
) can lead to unexpected behavior, including repeated triggering of pipelines.
To troubleshoot this issue, I would recommend reviewing your CircleCI pipeline configuration, trigger settings, and any branch protection rules on your version control system. Additionally, analyzing the CircleCI build logs and webhook event payloads can help identify the exact triggers and actions that are causing the pipeline to be triggered twice.
Solutions related to Webhook configuration
When you have duplicate builds triggering on every commit or push this can indicate that there is a problem with the webhook in GitHub.
Typically this means there are multiple webhooks added to the repository/project in GitHub for CircleCI.
Solution 1
We would recommend having an admin of the Github Organization follow these steps in order:
1. In GitHub, navigate to the impacted repository settings. https://github.com/OrgName/Repository
2. Select Webhooks
3. If there are multiple webhooks present here, remove all of the duplicate webhooks for CircleCI.
Solution 2
If this does not resolve the duplicate triggered builds issue, then your Organization Admin can entirely remove all webhooks for the repository, stop building, and then add the project back on CircleCI.
- Navigate to the repository settings/Webhooks as described above.
- Remove all of the webhooks for CircleCI.
- In CircleCI, stop building the project through "Project settings". https://app.circleci.com/settings/project/github/ORGNAME/PROJECTNAME
- Then, reconnect the project back on CircleCI.
Once this has been done you should only see one build being triggered with each push/commit.
A full walkthrough for removing a project/repository from CircleCI can be found here, including screenshots.
Additional Resources
Please contact support for more information about your duplicate builds.
Comments
Article is closed for comments.