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

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

    • 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.

          [JENKINS-45120] GitHub plugin doesn't automatically add webhooks on GitHub for a Pipeline job

          Yuri Kanivetsky created issue -
          Yuri Kanivetsky made changes -
          Description Original: 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 repository URL.
           4.2. Check "GitHub hook trigger for GITScm polling."
           4.3. Click "Save."

          In System Log I see:
            
          {code:java}
          GitHub webhooks activated for job p1 with [] (events: [PUSH])
          {code}
          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:
          {code:java}
          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]>!
          {code}
          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?
          New: 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 repository URL.
           4.2. Check "GitHub hook trigger for GITScm polling."
           4.3. Click "Save."

          In System Log I see:
            
          {code:java}
          GitHub webhooks activated for job p1 with [] (events: [PUSH])
          {code}
          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:
          {code:java}
          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]>!
          {code}
          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?

          Andy Coates added a comment -

          I am seeing the exact same issue.  Brand new instance (2.73.2) with a similar Pipeline job, but all I see is:

          GitHub webhooks activated for job <jobname> with [] (events: [PUSH])

          If I check on the GitHub side there are no new webhooks added, even though there is a Global config server for GitHub with credentials that test successfully via the Test Connection button.

          Feels like something is missing from the workflow/documentation. 

          Andy Coates added a comment - I am seeing the exact same issue.  Brand new instance (2.73.2) with a similar Pipeline job, but all I see is: GitHub webhooks activated for job <jobname> with [] (events: [PUSH]) If I check on the GitHub side there are no new webhooks added, even though there is a Global config server for GitHub with credentials that test successfully via the Test Connection button. Feels like something is missing from the workflow/documentation. 

          Anurag Kalia added a comment -

          I am seeing the exact same issue in the latest version of the plugin (1.28.1). Came to report to see but this is already reported.

          Anurag Kalia added a comment - I am seeing the exact same issue in the latest version of the plugin (1.28.1). Came to report to see but this is already reported.

          hao wang added a comment -

          I am seeing this on jenkins 2.89.3

          hao wang added a comment - I am seeing this on jenkins 2.89.3

          Still exists on Jenkins ver. 2.107.1

          Balázs Bábos added a comment - Still exists on Jenkins ver. 2.107.1

          It looks like the pipeline jobs (flow-definitions) don't understand that the github repository is inside the <definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition"> section of the config.

          On my system it keeps trying to manage a hook on https://github.com/foo/bar when the project I'm working on is in https://github.com/foo/barbaz. It is driving me nuts.

          Christian Höltje added a comment - It looks like the pipeline jobs (flow-definitions) don't understand that the github repository is inside the <definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition"> section of the config. On my system it keeps trying to manage a hook on https://github.com/foo/bar when the project I'm working on is in https://github.com/foo/barbaz . It is driving me nuts.
          Yuri Kanivetsky made changes -
          Summary Original: GitHub plugin doesn't automatically add webhooks to GitHub for Pipeline job New: GitHub plugin doesn't automatically add webhooks on GitHub for Pipeline job
          Yuri Kanivetsky made changes -
          Description Original: 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 repository URL.
           4.2. Check "GitHub hook trigger for GITScm polling."
           4.3. Click "Save."

          In System Log I see:
            
          {code:java}
          GitHub webhooks activated for job p1 with [] (events: [PUSH])
          {code}
          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:
          {code:java}
          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]>!
          {code}
          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?
          New: 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 repository URL.
           4.2. Check "GitHub hook trigger for GITScm polling."
           4.3. Click "Save."

          In System Log I see:
            
          {code:java}
          GitHub webhooks activated for job p1 with [] (events: [PUSH])
          {code}
          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:
          {code:java}
          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]>!
          {code}
          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.

          * 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 > Configure System > GitHub > Add GitHub Server > GitHub Server
          ** Choose the credentials
          ** Test connection (succeeds)
          ** Check Manage hooks
          ** Save
          * 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
          * https://github.com/USER/REPO/settings/hooks

          No new hooks.
          Yuri Kanivetsky made changes -
          Description Original: 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 repository URL.
           4.2. Check "GitHub hook trigger for GITScm polling."
           4.3. Click "Save."

          In System Log I see:
            
          {code:java}
          GitHub webhooks activated for job p1 with [] (events: [PUSH])
          {code}
          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:
          {code:java}
          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]>!
          {code}
          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.

          * 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 > Configure System > GitHub > Add GitHub Server > GitHub Server
          ** Choose the credentials
          ** Test connection (succeeds)
          ** Check Manage hooks
          ** Save
          * 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
          * https://github.com/USER/REPO/settings/hooks

          No new hooks.
          New: 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 repository URL.
           4.2. Check "GitHub hook trigger for GITScm polling."
           4.3. Click "Save."

          In System Log I see:
            
          {code:java}
          GitHub webhooks activated for job p1 with [] (events: [PUSH])
          {code}
          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:
          {code:java}
          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]>!
          {code}
          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:
          {code}
          # docker-compose.yml
          version: '3'
          services:
              jenkins:
                  image: jenkins/jenkins:2.277
                  ports:
                      - 8080:8080
          {code}
          {code}
          $ docker-compose up
          {code}
          * 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 > Configure System > GitHub > Add GitHub Server > GitHub Server
          ** Choose the credentials
          ** Test connection (succeeds)
          ** Check Manage hooks
          ** Save
          * 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
          * 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: