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

Jenkins doesn't always build what was pushed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • github-plugin
    • None
    • 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

      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.

            lanwen Kirill Merkushev
            xyuri Yuri Kanivetsky
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: