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

GitHub plugin doesn't automatically add webhooks on GitHub for a Pipeline job

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • github-plugin
    • None
    • Ubuntu 16.04.2 (Xenial)
      Jenkins 2.60.1
      GitHub plugin 1.27.0

      WORKAROUND After creating a job, make a build, then Manage Jenkins > Configure System > GitHub > Advanced > Re-register hooks for all jobs.

      Steps to reproduce:

      1. Generate personal access token on GitHub with repo and admin:repo_hook scopes.
      2. Add "Secret text" credentials with the token from the previous step.
      3. In Manage Jenkins > Configure System add GitHub server with credentials from the previous step.
      4. Create Pipeline job.
      4.1. Check "GitHub project" and specify a repository URL.
      4.2. Check "GitHub hook trigger for GITScm polling."
      4.3. Click "Save."

      In System Log I see:

      GitHub webhooks activated for job p1 with [] (events: [PUSH])
      

      When I create Freestyle Project with repository URL and credentials specified on Source Code Management tab and "GitHub hook trigger for GITScm polling" checked, I see:

      GitHub webhooks activated for job fsp1 with [GitHubRepositoryName[host=github.com,username=user,repository=repo]] (events: [PUSH])
       PING webhook received from repo <[https://github.com/user/repo]>!
      

      I must admit that even for Freestyle project just checking "GitHub project" and specifying repository URL doesn't cut it. Which is strange. Isn't that enough info to create a webhook?

      UPD I was about to report it again, but found this issue. So let me report again after all.

      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.

      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
      • https://github.com/settings/tokens
        • Generate new token
        • Scopes: repo, admin:repo_hook
        • Generate token
      • Manage Jenkins > Manage Credentials > (Jenkins/global) > Add credentials
        • Kind: Secret text
        • Scope: System
        • Secret: (the token)
        • OK
      • Manage Jenkins > Manage Credentials > (Jenkins/global) Add credentials
        • Kind: Username with password
        • Scope: Global
        • Username: (email)
        • Password: (password)
      • Manage Jenkins > Configure System > GitHub > Add GitHub Server > GitHub Server
        • Choose the token credentials
        • Test connection (succeeds)
        • Check Manage hooks
        • Save
      • 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'
                    }
                }
            }
        }
        
      • New Item
        • Enter an item name
        • Pipeline
        • OK
        • Check GitHub project
        • Enter the URL: https://github.com/USER/REPO
        • Check GitHub hook trigger for GITScm polling
        • Pipeline: Pipeline from SCM
        • SCM: Git
        • Repository URL: https://github.com/USER/REPO
        • Credentials: (credentials)
        • Branch specifier: */master (the default)
        • Save
      • https://github.com/USER/REPO/settings/hooks

      No new hooks.

            lanwen Kirill Merkushev
            xyuri Yuri Kanivetsky
            Votes:
            10 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated: