github-plugin icon indicating copy to clipboard operation
github-plugin copied to clipboard

[JENKINS-64722] Jenkins doesn't always build what was pushed

Open jenkins-infra-bot opened this issue 4 years ago • 0 comments

Steps to reproduce:

# docker-compose.yml
version: '3'
services:
    jenkins:
image: jenkins/jenkins:2.277
ports:
    - 8080:8080
$ docker-compose up
  • Unlock Jenkins
  • Install suggested plugins
  • Create a user
  • Create a public repository on GitHub with the following Jenkinsfile in the master branch:
    pipeline {
        agent any
        stages {
    stage('Stage 1') {
        steps {
    sh 'echo $GIT_COMMIT'
        }
    }
        }
    }
    
<li><a href="https://github.com/USER/REPO/settings/hooks" class="external-link" target="_blank" rel="nofollow noopener">https://github.com/USER/REPO/settings/hooks</a>
<ul>
	<li>Add webhook</li>
	<li>Payload URL: <tt>$JENKINS_BASE_URL/github-webhook/</tt> (trailing slash is important)</li>
	<li>Add webook</li>
</ul>
</li>
<li>Manage Jenkins > Manage Credentials > (Jenkins/global) > Add credentials
<ul>
	<li>Kind: Username with password</li>
	<li>Scope: System</li>
	<li>Username: (email)</li>
	<li>Password: (password)</li>
</ul>
</li>
<li>New Item
<ul>
	<li>Enter an item name</li>
	<li>Pipeline</li>
	<li>OK</li>
	<li>Check GitHub project</li>
	<li>Enter the URL: <a href="https://github.com/REPO/NAME" class="external-link" target="_blank" rel="nofollow noopener">https://github.com/REPO/NAME</a></li>
	<li>Check GitHub hook trigger for GITScm polling</li>
	<li>Pipeline: Pipeline from SCM</li>
	<li>SCM: Git</li>
	<li>Repository URL: <a href="https://github.com/REPO/NAME" class="external-link" target="_blank" rel="nofollow noopener">https://github.com/REPO/NAME</a></li>
	<li>Credentials: (credentials)</li>
	<li>Branch specifier: <tt>*/master</tt> (the default)</li>
	<li>Save</li>
</ul>
</li>
<li>Build Now (to make GitHub plugin work)</li>
$ n=a; echo "$n" > "$n"; git add "$n"; git commit -m "$n"
$ git push origin HEAD

It built the pushed commit (a).

$ git checkout -b master2
$ n=b; echo "$n" > "$n"; git add "$n"; git commit -m "$n"
$ git push origin HEAD

The build hasn't started (as expected).

  • Configure > Pipeline > Branches to build
    • Branch specifier: */master*
    • Save
$ git checkout master
$ n=c; echo "$n" > "$n"; git add "$n"; git commit -m "$n"
$ git push origin HEAD

The build has started but it builds commit b, not c.

$ n=d; echo "$n" > "$n"; git add "$n"; git commit -m "$n"
$ git push origin HEAD

And now it built c and d.


Originally reported by xyuri, imported from: Jenkins doesn't always build what was pushed
  • assignee: lanwen
  • status: Open
  • priority: Minor
  • component(s): github-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-08
Raw content of original issue

Steps to reproduce:

# docker-compose.yml
version: '3'
services:
    jenkins:
        image: jenkins/jenkins:2.277
        ports:
            - 8080:8080
$ docker-compose up
  • Unlock Jenkins
  • Install suggested plugins
  • Create a user
  • Create a public repository on GitHub with the following Jenkinsfile in the master branch:
    pipeline {
        agent any
        stages {
            stage('Stage 1') {
                steps {
                    sh 'echo $GIT_COMMIT'
                }
            }
        }
    }
    
  • https://github.com/USER/REPO/settings/hooks
    • Add webhook
    • Payload URL: $JENKINS_BASE_URL/github-webhook/ (trailing slash is important)
    • Add webook
  • Manage Jenkins > Manage Credentials > (Jenkins/global) > Add credentials
    • Kind: Username with password
    • Scope: System
    • Username: (email)
    • Password: (password)
  • New Item
    • Enter an item name
    • Pipeline
    • OK
    • Check GitHub project
    • Enter the URL: https://github.com/REPO/NAME
    • Check GitHub hook trigger for GITScm polling
    • Pipeline: Pipeline from SCM
    • SCM: Git
    • Repository URL: https://github.com/REPO/NAME
    • Credentials: (credentials)
    • Branch specifier: */master (the default)
    • Save
  • Build Now (to make GitHub plugin work)
$ n=a; echo "$n" > "$n"; git add "$n"; git commit -m "$n"
$ git push origin HEAD

It built the pushed commit (a).

$ git checkout -b master2
$ n=b; echo "$n" > "$n"; git add "$n"; git commit -m "$n"
$ git push origin HEAD

The build hasn't started (as expected).

  • Configure > Pipeline > Branches to build
    • Branch specifier: */master*
    • Save
$ git checkout master
$ n=c; echo "$n" > "$n"; git add "$n"; git commit -m "$n"
$ git push origin HEAD

The build has started but it builds commit b, not c.

$ n=d; echo "$n" > "$n"; git add "$n"; git commit -m "$n"
$ git push origin HEAD

And now it built c and d.

  • environment: Jenkins 2.277, Docker version 18.06.3-ce build d7080c1, Debian GNU/Linux 8, GitHub API Plugin 1.122, GitHub plugin 1.32.0

jenkins-infra-bot avatar Jan 26 '21 22:01 jenkins-infra-bot