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

Mercurial URL hook for triggering polling doesn't work with user/pass set in the repository URL

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Component/s: mercurial-plugin
    • Labels:
      None

      Description

      This is basically the equivalent of JENKINS-13410 for the Mercurial plugin.

      If I set the repo URL to something on the lines of https://user:pass@url/repo, if I use the notifyCommit hook provided since 1.38 I get a "No mercurial jobs found" message from the server.

      Command line is:
      $ curl https://jenkins/mercurial/notifyCommit?url=https://user:pass@url/repo (copy pasted from the actual URL in the job setup)

      1. strip-credentials.patch
        0.8 kB
        Gonzalo Sainz-Trapaga

        Issue Links

          Activity

          Hide
          gomox Gonzalo Sainz-Trapaga added a comment - - edited

          Posted trivial patch to correct this behaviour. All it does is stripping the user:pass@ or user@ part out of the repository URL before matching against the URL in the API request. Therefore posting to notifyCommit with an https://server/repo/address should trigger a poll on a mercurial repo with an https://user:pass@server/repo/address as well.

          Another possibly good change is swapping the line that says:
          if (url.equals(repository)) urlFound = true; else continue;

          With:
          if (repository.startswith(url)) urlFound = true; else continue;

          This would allow for a single API call to http://jenkins/mercurial/notifyCommit?url=http://server/ to trigger a poll on all repos on that server, or to specific repository groups located at http://server/group1/etc. Good on tools like Rhodecode that only allow you to define system-wide hooks, not repo-specific ones.

          I tested the regex in the patch above and it does what it's supposed to, but I don't have a build system to actually test this out.

          Show
          gomox Gonzalo Sainz-Trapaga added a comment - - edited Posted trivial patch to correct this behaviour. All it does is stripping the user:pass@ or user@ part out of the repository URL before matching against the URL in the API request. Therefore posting to notifyCommit with an https://server/repo/address should trigger a poll on a mercurial repo with an https://user:pass@server/repo/address as well. Another possibly good change is swapping the line that says: if (url.equals(repository)) urlFound = true; else continue; With: if (repository.startswith(url)) urlFound = true; else continue; This would allow for a single API call to http://jenkins/mercurial/notifyCommit?url=http://server/ to trigger a poll on all repos on that server, or to specific repository groups located at http://server/group1/etc . Good on tools like Rhodecode that only allow you to define system-wide hooks, not repo-specific ones. I tested the regex in the patch above and it does what it's supposed to, but I don't have a build system to actually test this out.
          Hide
          gomox Gonzalo Sainz-Trapaga added a comment -

          ¿Can someone try this out? It's a big annoyance and a trivial patch.

          Show
          gomox Gonzalo Sainz-Trapaga added a comment - ¿Can someone try this out? It's a big annoyance and a trivial patch.
          Hide
          jglick Jesse Glick added a comment -
          Show
          jglick Jesse Glick added a comment - https://github.com/jenkinsci/mercurial-plugin/commit/dc37e17 in 1.44 already fixed this.
          Hide
          jglick Jesse Glick added a comment -

          Anyway I am working on Credentials integration, meaning that you will not need to put your username and password in the URL anyway.

          Show
          jglick Jesse Glick added a comment - Anyway I am working on Credentials integration, meaning that you will not need to put your username and password in the URL anyway.

            People

            • Assignee:
              jglick Jesse Glick
              Reporter:
              gomox Gonzalo Sainz-Trapaga
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: