Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-56530

Duplicate build job when merging and deleting GitHub branch with web hook

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • None
    • Jenkins v 2.150.2
      Git client plugin v 2.7.6
      Git plugin v 3.9.3
      GitHub plugin v 1.29.3
      GitHub API plugin v 1.95

      I have a pipeline job that builds the dev branch from a single repository hosted on our GitHub Enterprise instance. The repository is configured to use the Manage Jenkins (GitHub plugin) web hook. (i.e. The only build trigger checked is the "GitHub hook trigger for GITScm polling.")

      After merging a feature branch branch into the dev branch and then deleting the feature branch, Jenkins started two concurrent builds for this pipeline. Both jobs were for the same commit. I expected it to only build the new commit once.

      From the http://ourjenkins:8080/log/all page:

      Mar 12, 2019 9:49:40 AM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber onEvent
      Received PushEvent for http://ourgithub/Org/OurProject from ourgithub ⇒ http://ourjenkins:8080/github-webhook/
      Mar 12, 2019 9:49:40 AM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
      Poked Our Project Pipeline Name
      Mar 12, 2019 9:49:42 AM INFO com.cloudbees.jenkins.GitHubPushTrigger$1 run
      SCM changes detected in Our Project Pipeline Name. Triggering #2
      Mar 12, 2019 9:50:14 AM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber onEvent
      Received PushEvent for http://ourgithub/Org/OurProject from ourgithub ⇒ http://ourjenkins:8080/github-webhook/
      Mar 12, 2019 9:50:14 AM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
      Poked Our Project Pipeline Name
      Mar 12, 2019 9:50:15 AM INFO com.cloudbees.jenkins.GitHubPushTrigger$1 run
      SCM changes detected in Our Project Pipeline Name. Triggering #3
      Mar 12, 2019 9:52:09 AM INFO org.jenkinsci.plugins.workflow.job.WorkflowRun finish
      Our Project Pipeline Name #2 completed: SUCCESS
      Mar 12, 2019 9:52:17 AM INFO org.jenkinsci.plugins.workflow.job.WorkflowRun finish
      Our Project Pipeline Name #3 completed: SUCCESS
      

      The logs for the individual jobs (#2 and #3) showed that they built the same remote head revision commit ID. They also compared it to the same "Last Built Revision" which was the commit ID built by job #1 a few days earlier.

      Speculation about what happened:

      1. I merged my change to the dev branch and pushed it to our GitHub.
      2. GitHub called the Jenkins web hook to let it know about the change.
      3. Jenkins polled GitHub and saw that there were changes to the dev branch since job #1 and started job #2.
      4. I deleted my feature branch on our GitHub.
      5. GitHub called the Jenkins web hook to let it know about the change.
      6. Jenkins polled GitHub and saw that there were changes to the dev branch since the last completed job #1, but failed to compare it to the in-progress job #2. As a result, it started the unnecessary job #3.

       

            Unassigned Unassigned
            prnei P N
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: