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

github-plugin does not work with "insteadOf" in git url

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Duplicate
    • Component/s: github-plugin
    • Labels:
    • Environment:
    • Similar Issues:

      Description

      Hello.

      I've properly configured the Github plugin in Jenkins to communicate with my Github Enterprise instance. In GHE I've installed the "Jenkins (github plugin)" service so that every push event sends a hook to the proper Jenkins URL. The hook is sent and is received by jenkins as I can see from the logs (I've replaced sensitive content):

      ```
      ...
      Received POST for https://github.example.com/foo/bar
      ...
      Mar 17, 2015 6:47:51 PM FINE com.cloudbees.jenkins.GitHubWebHook
      Considering to poke bar
      Mar 17, 2015 6:47:51 PM FINE com.cloudbees.jenkins.GitHubWebHook
      Skipped bar because it doesn't have a matching repository.
      ```

      It just that the plugin does not match the name, and I can see why this happens.
      In our Jenkins server, the .gitconfig contains this line:

      ```
      [url "deploy@<our-github-proxy>.com:"]
      insteadOf = deploy:
      ```

      This is a requirement since in our infrastructure we use a github proxy to implement ACLs (but that's irrelevant). So to clone a project Jenkins does a `git clone deploy:foo/bar.git`. Also in the github plugin settings I've configured it to be so.

      But the github url to the repo is this: https://github.example.com/foo/bar. So it's different from the setting in the github plugin, even though the 2 urls point to the same repo. I suspect that the plugin parses also the git url (not just the "foo/bar.git" part), therefore it can't correlate the repos, which actually is the same underlying repo (despite the url being different): https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/com/cloudbees/jenkins/GitHubRepositoryName.java#L26

      UPDATE: If I switch the "Repository URL" (in "Source Code Management" section) to point to https://github.example.com/foo/bar instead, then I can see in the logs that it "pokes bar", so it works that way, but this is not feasible in our setup, since jenkins clones and fetches via `git clone deploy:foo/bar` and not `git clone git@github.example.com/foo/bar`.

      I believe that the plugin should have an (advanced) setting for such cases.

      This are my current plugin settings (attached image).

        Attachments

          Issue Links

            Activity

            Hide
            integer Kanstantsin Shautsou added a comment -

            Plugin doesn't care about .gitconfig settings, because it's your local temp settings that unknown to jenkins and plugins. Plugin uses settings that you defined and obviously needs right url. I think nobody will be interested in hacking plugin with weird use case. Try configure your urls so they will match for triggering configuration and then try do any hacks that you want.

            Show
            integer Kanstantsin Shautsou added a comment - Plugin doesn't care about .gitconfig settings, because it's your local temp settings that unknown to jenkins and plugins. Plugin uses settings that you defined and obviously needs right url. I think nobody will be interested in hacking plugin with weird use case. Try configure your urls so they will match for triggering configuration and then try do any hacks that you want.
            Hide
            mandingueiro mandingueiro a added a comment - - edited

            It may be a not so usual case, but it's a valid one nonetheless. I think that the plugin doesn't have to be "hacked" it just can also check the "GitHub project" setting to match incoming github hooks with Jenkins jobs. Maybe that's a more sensible default too. After all, an HTTP URL to the repo may be totally different than it's git url.

            What do you think? Ι think the relevant code is here: https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/com/cloudbees/jenkins/GitHubRepositoryNameContributor.java#L60-L74

            The .gitconfig is irrelevant to this issue.

            Show
            mandingueiro mandingueiro a added a comment - - edited It may be a not so usual case, but it's a valid one nonetheless. I think that the plugin doesn't have to be "hacked" it just can also check the "GitHub project" setting to match incoming github hooks with Jenkins jobs. Maybe that's a more sensible default too. After all, an HTTP URL to the repo may be totally different than it's git url. What do you think? Ι think the relevant code is here: https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/com/cloudbees/jenkins/GitHubRepositoryNameContributor.java#L60-L74 The .gitconfig is irrelevant to this issue.
            Hide
            integer Kanstantsin Shautsou added a comment - - edited

            Could you PR proposed changes for further discussion?

            Show
            integer Kanstantsin Shautsou added a comment - - edited Could you PR proposed changes for further discussion?
            Hide
            lanwen Kirill Merkushev added a comment -

            Duplicates JENKINS-18298

            Show
            lanwen Kirill Merkushev added a comment - Duplicates JENKINS-18298

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              mandingueiro mandingueiro a
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: