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

Selected "Let Jenkins auto-manage hook URLs", but never adds webhook to enterprise github

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: github-plugin
    • Labels:
      None
    • Environment:
      Targeting Github Enterprise Version 11.10.315
      Jenkins version: 1.522
      Git server plugin: 1.1
      GitHub API Plugin: 1.42
      GitHub plugin: 1.7
      Jenkins GIT client plugin: 1.0.7
      Jenkins GIT plugin: 1.4.0
    • Similar Issues:

      Description

      Have set up github in jenkins configuration, providing:
      Let Jenkins auto-manage hook URLs
      API URL: http://github.mydomain.com/api/v3/
      username: jenkins
      Password: <the jenkins user's git password>
      OAuth token: <the jenkins user's oauth token>

      Clicking Test Credential says 'Verified'

      When I add a new job that connects to a repo on our github
      http://github.mydomain.com/MYORG/myproject.git

      and to only build:
      Build when a change is pushed to GitHub

      It doesn't get registered in the github enterprise hooks for that repository. Have ensured the jenkins user is in MYORG/owners team in github, which as full read/write/admin access.

      If I manually add the jenkins hook to the webhooks in github enterprise, it successfully kicks off builds when I push to github.

      Have tried turning on logging in jenkins to trace what is happening, but there doesn't seem to be any errors or warning anywhere in logs coming back:

      Have added logger with ALL on:
      com.cloudbees.jenkins.GitHubPushTrigger
      com.cloudbees.jenkins.GitHubRepositoryName
      org.kohsuke.github

      but the only output I get is:
      Jul 11, 2013 12:50:43 PM com.cloudbees.jenkins.GitHubRepositoryName create
      FINE: Object is GitHubRepository[host=github.mydomain.com,username=MYORG,repository=myproject]
      Jul 11, 2013 12:50:43 PM com.cloudbees.jenkins.GitHubRepositoryName create
      FINE: URL matches java.util.regex.Matcher[pattern=https?://([^/])/([^/])/([^/]+)\.git region=0,47 lastmatch=http://github.mydomain.com/MYORG/myproject.git]
      Jul 11, 2013 12:50:43 PM com.cloudbees.jenkins.GitHubRepositoryName create
      FINE: Constructing from URL http://github.mydomain.com/MYORG/myproject.git
      Jul 11, 2013 12:50:43 PM com.cloudbees.jenkins.GitHubRepositoryName create
      FINE: Object is GitHubRepository[host=github.mydomain.com,username=MYORG,repository=myproject]
      Jul 11, 2013 12:50:43 PM com.cloudbees.jenkins.GitHubRepositoryName create
      FINE: URL matches java.util.regex.Matcher[pattern=https?://([^/])/([^/])/([^/]+)\.git region=0,47 lastmatch=http://github.mydomain.com/MYORG/myproject.git]
      Jul 11, 2013 12:50:43 PM com.cloudbees.jenkins.GitHubRepositoryName create
      FINE: Constructing from URL http://github.mydomain.com/MYORG/myproject.git

        Attachments

          Activity

          Hide
          nathanm Nathan McDonald added a comment -

          Have debugged through the plugin. The adder seems to get stuck with empty collection of connections when it hits following code due to enterprise git using different hostname. This would explain why nothing appears in the logs, as most logging appears to be inside the for loops:

          com.cloudbees.jenkins.GitHubWebHook.java
          //snippet
              /**
               * Logs in as the given user and returns the connection object.
               */
              public Iterable<GitHub> login(String host, String userName) {
                  if (host.equals("github.com")) {
                      //do a whole log of logic
                  } else {
                      return Collections.<GitHub> emptyList();
                  }
              }
          
          Show
          nathanm Nathan McDonald added a comment - Have debugged through the plugin. The adder seems to get stuck with empty collection of connections when it hits following code due to enterprise git using different hostname. This would explain why nothing appears in the logs, as most logging appears to be inside the for loops: com.cloudbees.jenkins.GitHubWebHook.java //snippet /** * Logs in as the given user and returns the connection object. */ public Iterable<GitHub> login( String host, String userName) { if (host.equals( "github.com" )) { // do a whole log of logic } else { return Collections.<GitHub> emptyList(); } }
          Hide
          nathanm Nathan McDonald added a comment -

          Patched the plugin and removed the outer if condition so same code runs for our enterprise github. This seems to work for us and the hooks get added to github enterprise. Still not sure what the intended purpose of this if clause was, git history shows it was added ages ago when support for github enterprise was first being added, which would seem to suggest hooks have never been auto added for enterprise github instances...

          Show
          nathanm Nathan McDonald added a comment - Patched the plugin and removed the outer if condition so same code runs for our enterprise github. This seems to work for us and the hooks get added to github enterprise. Still not sure what the intended purpose of this if clause was, git history shows it was added ages ago when support for github enterprise was first being added, which would seem to suggest hooks have never been auto added for enterprise github instances...
          Hide
          nathanm Nathan McDonald added a comment -

          Pull request for fix we're using: https://github.com/jenkinsci/github-plugin/pull/31

          Show
          nathanm Nathan McDonald added a comment - Pull request for fix we're using: https://github.com/jenkinsci/github-plugin/pull/31
          Hide
          elordahl Eric Lordahl added a comment - - edited

          I made a pull request prior to seeing https://github.com/jenkinsci/github-plugin/pull/31. I will post to the dev list if it goes unanswered soon.

          Show
          elordahl Eric Lordahl added a comment - - edited I made a pull request prior to seeing https://github.com/jenkinsci/github-plugin/pull/31 . I will post to the dev list if it goes unanswered soon.
          Hide
          mattnelson Matt Nelson added a comment -

          This is also preventing the GitHubCommitNotifier from working because it is unable to resolve a GitHubRepositoryName into a GitHubRepository.

          Show
          mattnelson Matt Nelson added a comment - This is also preventing the GitHubCommitNotifier from working because it is unable to resolve a GitHubRepositoryName into a GitHubRepository.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          src/main/java/com/cloudbees/jenkins/GitHubWebHook.java
          http://jenkins-ci.org/commit/github-plugin/e0b8050d78dc836495ef403fec6988a970f6225b
          Log:
          [FIXED JENKINS-18710] merge pull request #31

          Compare: https://github.com/jenkinsci/github-plugin/compare/6553654a7884...e0b8050d78dc

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: src/main/java/com/cloudbees/jenkins/GitHubWebHook.java http://jenkins-ci.org/commit/github-plugin/e0b8050d78dc836495ef403fec6988a970f6225b Log: [FIXED JENKINS-18710] merge pull request #31 Compare: https://github.com/jenkinsci/github-plugin/compare/6553654a7884...e0b8050d78dc

            People

            • Assignee:
              Unassigned
              Reporter:
              nathanm Nathan McDonald
            • Votes:
              5 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: