jenkinsci / jenkinsci/git-plugin

[JENKINS-45280] duplicate build triggered by same github push notification when there is long scm polling

Open
#3,135 9 comments 0 reactions 0 assignees View on GitHub
component:git-plugin component:github-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
694
Forks
1.1k
Avg merge
1h 29m
Merged PRs (30d)
3

Description

we have a github repo that contains close to 5000 git tags, the jenkins job is configured to be triggered by webhook push and recent upgrade of jenkins we hit this change https://github.com/jenkinsci/git-plugin/commit/31fedce9c41c9006c886835e03c9fe825d49aba6 which caused our scm polling time increases from 20 seconds to up to 5 minutes because we set some regex filter for branches matching and that change now extend that matching to tags too. and as a result I've seen duplicate build being triggered by the same github push notification.

All duplicated build jobs has the same scm polling log (same webhook notification) which lead me believe that there are multiple polling threads responding to the same webhook notification and they are not acting in a thread safeway to decide if there are new changes to build. I am looking at this line: https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/com/cloudbees/jenkins/GitHubPushTrigger.java#L109 and suspect that this could be the potential cause, since multiple thread can enter the poll and trigger the new build before the lastBuild being updated (I am not super familiar with the code base so apologize if I am missing the target here)

one more thing to mention is that after I drop all the branch matching in my jenkins job configuration to put the scm polling time back too less than 1 sec, there will no longer be any duplicated build.

---
Originally reported by shiqiyang, imported from: duplicate build triggered by same github push notification when there is long scm polling


  • status: Open
  • priority: Minor
  • component(s): git-plugin, github-plugin
  • resolution: Unresolved
  • votes: 8
  • watchers: 11
  • imported: 2025-12-02

Raw content of original issue

we have a github repo that contains close to 5000 git tags, the jenkins job is configured to be triggered by webhook push and recent upgrade of jenkins we hit this change https://github.com/jenkinsci/git-plugin/commit/31fedce9c41c9006c886835e03c9fe825d49aba6 which caused our scm polling time increases from 20 seconds to up to 5 minutes because we set some regex filter for branches matching and that change now extend that matching to tags too. and as a result I've seen duplicate build being triggered by the same github push notification.

All duplicated build jobs has the same scm polling log (same webhook notification) which lead me believe that there are multiple polling threads responding to the same webhook notification and they are not acting in a thread safeway to decide if there are new changes to build. I am looking at this line: https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/com/cloudbees/jenkins/GitHubPushTrigger.java#L109 and suspect that this could be the potential cause, since multiple thread can enter the poll and trigger the new build before the lastBuild being updated (I am not super familiar with the code base so apologize if I am missing the target here)

one more thing to mention is that after I drop all the branch matching in my jenkins job configuration to put the scm polling time back too less than 1 sec, there will no longer be any duplicated build.

  • environment: jenkins:2.46.3, github-plugin: 1.27.0, git-plugin: 3.3.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.