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

gitlab oauth plugin:GitlabAPIException

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: gitlab-oauth-plugin
    • Labels:
      None
    • Environment:
      java version "1.7.0_101"
      Gitlab Authentication plugin 1.0.5
    • Similar Issues:

      Description

      After success in gitlab:

      Authorization required

      Authorize jenkins to use your account?

      You are an admin, which means granting access to jenkins will allow them to interact with GitLab as an admin as well. Proceed with caution.

      This application will be able to:

      Access your API

      it finally fail in jenkins:
      org.gitlab.api.GitlabAPIException
      at org.gitlab.api.http.GitlabHTTPRequestor.handleAPIError(GitlabHTTPRequestor.java:369)
      at org.gitlab.api.http.GitlabHTTPRequestor.to(GitlabHTTPRequestor.java:146)
      at org.gitlab.api.http.GitlabHTTPRequestor.to(GitlabHTTPRequestor.java:116)
      at org.gitlab.api.GitlabAPI.getUser(GitlabAPI.java:137)
      at org.jenkinsci.plugins.GitLabAuthenticationToken.<init>(GitLabAuthenticationToken.java:100)
      at org.jenkinsci.plugins.GitLabSecurityRealm.doFinishLogin(GitLabSecurityRealm.java:326)
      at sun.reflect.GeneratedMethodAccessor181.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:324)
      at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:167)
      at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:100)
      at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:124)
      at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
      at org.kohsuke.stapler.MetaClass$3.doDispatch(MetaClass.java:196)
      at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
      at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
      at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135)
      at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:126)

      maybe beacuse I use nignx to redirect gitlab?

        Attachments

          Activity

          Hide
          iorange John Stephen added a comment -

          Seems your jenkins has some trouble when connect to your GitLab.

          Show
          iorange John Stephen added a comment - Seems your jenkins has some trouble when connect to your GitLab.
          Hide
          mohamedelhabib Mohamed EL Habib added a comment -

          Hello,

          • Please can you test using a version 1.0.7 or 1.0.8. we update the used version of the gitlab-api
          • if you still have the problem, can you provide more details: http request/response for example.

          Thanks

          Show
          mohamedelhabib Mohamed EL Habib added a comment - Hello, Please can you test using a version 1.0.7 or 1.0.8. we update the used version of the gitlab-api if you still have the problem, can you provide more details: http request/response for example. Thanks
          Hide
          shorang Jairo Ricarte added a comment -

          I had the same problem with the oauth plugin.

          Hook executed successfully but returned HTTP 403 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Error 403 anonymous is missing the Job/Build permission</title> </head> <body><h2>HTTP ERROR 403</h2> <p>Problem accessing /project/test. Reason: <pre> anonymous is missing the Job/Build permission</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/> </body> </html>

          I solved adding the test condition below

          // Some comments here
          class GitLabRequireOrganizationMembershipACL
          public boolean hasPermission(Authentication a, Permission permission) {
          {
          
          ...
                          if (testBuildPermission(permission)) {
                              if (allowGitlabWebHookPermission &&
                                      (currentUriPathStartsWith("/project/") ||
                                       currentUriPathEquals("gitlab-webhook") ||
                                       currentUriPathEquals("gitlab-webhook/"))) {
                                  log.finest("Granting BUILD access for gitlab-webhook url: " + requestURI());
                                  return true;
                              }
                          }
          }
          
          Show
          shorang Jairo Ricarte added a comment - I had the same problem with the oauth plugin. Hook executed successfully but returned HTTP 403 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Error 403 anonymous is missing the Job/Build permission</title> </head> <body><h2>HTTP ERROR 403</h2> <p>Problem accessing /project/test. Reason: <pre> anonymous is missing the Job/Build permission</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/> </body> </html> I solved adding the test condition below // Some comments here class GitLabRequireOrganizationMembershipACL public boolean hasPermission(Authentication a, Permission permission) { { ... if (testBuildPermission(permission)) { if (allowGitlabWebHookPermission && (currentUriPathStartsWith( "/project/" ) || currentUriPathEquals( "gitlab-webhook" ) || currentUriPathEquals( "gitlab-webhook/" ))) { log.finest( "Granting BUILD access for gitlab-webhook url: " + requestURI()); return true ; } } }
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Jairo Ricarte
          Path:
          src/main/java/org/jenkinsci/plugins/GitLabRequireOrganizationMembershipACL.java
          http://jenkins-ci.org/commit/gitlab-oauth-plugin/9e1768a3cf3b85cf7d144b19be9a338280ff3375
          Log:
          JENKINS-37741 Testing /project path ont allowGitlabWebHookPermission check

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jairo Ricarte Path: src/main/java/org/jenkinsci/plugins/GitLabRequireOrganizationMembershipACL.java http://jenkins-ci.org/commit/gitlab-oauth-plugin/9e1768a3cf3b85cf7d144b19be9a338280ff3375 Log: JENKINS-37741 Testing /project path ont allowGitlabWebHookPermission check
          Hide
          mohamedelhabib Mohamed EL Habib added a comment -

          fixed into 1.0.9 version

          Show
          mohamedelhabib Mohamed EL Habib added a comment - fixed into 1.0.9 version

            People

            • Assignee:
              meepo Ye Deming
              Reporter:
              meepo Ye Deming
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: