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

Gerrit server context path is ignored when accessing checks API

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • Gerrit version: 3.2.3
      Jenkins version: 2.249.1 (LTS)
      gerrit-code-review-plugin version: 0.4.4

      The gerrit code review plugin seems to ignore context path when accessing the checks API of a gerrit server and always use a path of /

       

      Steps to reproduce:

      Install a gerrit server with a context path other than / (ex: /myproject/gerrit/)

      Create a multibranch pipeline that checks out a project using the server address (e.g. https://myserver.mydomain/myproject/gerrit/a/myrepository)

       

      Result:

      Jenkins shows the following error:

      Unable to query for pending checks: com.google.gerrit.extensions.restapi.RestApiException: Failed to list pending checks:

       

      Logs from the reverse proxy indicate that jenkins tries to access an url starting with https://myserver.mydomain/a/plugins/checks/checks.pending/?query= instead of https://myserver.mydomain/myproject/gerrit/a/plugins/checks/checks.pending/?query=

       

      This is a problem especially when serving multiple gerrit servers with a single reverse proxy since there is no easy workaround in that case.

       

          [JENKINS-63887] Gerrit server context path is ignored when accessing checks API

          Alexander Ost added a comment - - edited

          I just ran into the same problem and I think I found the root cause. I created a pull request that fixes the problem for me, could you please review it?

          Alexander Ost added a comment - - edited I just ran into the same problem and I think I found the root cause. I created a pull request  that fixes the problem for me, could you please review it?

          Alexander Ost added a comment -

          New PR that also fixes the tests: #59

          Alexander Ost added a comment - New PR that also fixes the tests: #59

          Marco added a comment -

          I'm having the same problem.
          Gerrit is running via a reverse proxy and is available at: http://example.local/gerrit/
          The reverse proxy is connecting to Gerrit via: http://127.0.0.1:8081/gerrit/
          The repository URL is defines as: http://JenkinsCI@example.local/gerrit/a/Some/Project

          The REST API calls are always made to http://example.local/a/plugins/....
          and fail.

          I've build the plugin with the mentioned PR, but this didn't work either.

          Any further suggestions?

          Marco added a comment - I'm having the same problem. Gerrit is running via a reverse proxy and is available at: http://example.local/gerrit/ The reverse proxy is connecting to Gerrit via: http://127.0.0.1:8081/gerrit/ The repository URL is defines as: http://JenkinsCI@example.local/gerrit/a/Some/Project The REST API calls are always made to http://example.local/a/plugins/ .... and fail. I've build the plugin with the mentioned PR, but this didn't work either. Any further suggestions?

          Alexander Ost added a comment - - edited

          My pull request did not fix the issue in all places (e.g., search for open check would fail). I updated the PR – hope it works for you.

          Alexander Ost added a comment - - edited My pull request did not fix the issue in all places (e.g., search for open check would fail). I updated the PR – hope it works for you.

          Marco added a comment -

          I've tested your new PR. Now it's working and Jenkins is able to search for open check requests.

          Marco added a comment - I've tested your new PR. Now it's working and Jenkins is able to search for open check requests.

          Alexander Ost added a comment -

          Thanks – glad to hear that it works for you. lucamilanesio, could you please check the PR? This issue breaks the plugin for anyone running Gerrit with a non-root context path. 

          Alexander Ost added a comment - Thanks – glad to hear that it works for you. lucamilanesio , could you please check the PR ? This issue breaks the plugin for anyone running Gerrit with a non-root context path. 

            lucamilanesio Luca Domenico Milanesio
            sgrimard Sebastien GRIMARD
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: