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

GitLab Branch Source unable to download project avatar

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • Jenkins 2.263.3, GitLab Branch Source plugin 1.5.4 , GitLab 13.9.0-pre 80a6f1bf66f

    Description

      Preconditions

      Steps

      • Install Jenkins and Gitlab branch source plugin (versions mentioned in the environment field)
      • Setup necessary credentials for GitLab integration (private token with API access && ssh creds.)
      • Create a Multi branch pipeline
      • Observe the logo/avatar displayed in the dashboard

      Outcome

      • The logo/avatar seem to be a randomly generated one
      • The logs show that the attempt to fetch project's logo fails
        Feb 07, 2021 10:16:48 PM INFO io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage call
        
        Server returned HTTP response code: 401 for URL: https://gitlab.com/uploads/-/system/project/avatar/XXXXXXXX/IMG.png
        java.io.IOException: Server returned HTTP response code: 401 for URL: https://gitlab.com/uploads/-/system/project/avatar/XXXXXXXX/IMG.png
        	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1924)
        	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
        	at java.base/sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3099)
        	at java.base/java.net.URLConnection.getContentType(URLConnection.java:519)
        	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getContentType(HttpsURLConnectionImpl.java:402)
        	at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:506)
        Caused: java.io.IOException: Server returned HTTP response code: 401 for URL: https://gitlab.com/uploads/-/system/project/avatar/XXXXXXXX/IMG.png
        	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        	at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1974)
        	at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1969)
        	at java.base/java.security.AccessController.doPrivileged(Native Method)
        	at java.base/sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1968)
        	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1536)
        	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
        	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)
        	at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:513)
        	at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:490)
        	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        	at java.base/java.lang.Thread.run(Thread.java:834)
        

      Notes

      • The project builds normally otherwise and build status is correctly pushed to GitLab
      • Trying the failing URL (from logs) in the browser actually provides the project logo/avatar

      Attachments

        Activity

          iancotton Ian added a comment -

          I'm seeing exactly the same issue.

          Gitlab version 13.9

          Jenkins 2.277.4

          Gitlab branch source plugin 1.5.7

          2021-05-24 12:31:33.310+0000 [id=28171] INFO i.j.p.g.h.GitLabAvatarCache$FetchImage#call: Server returned HTTP response code: 401 for URL: https://thgitlab.helpsystems.com/uploads/-/system/group/avatar/21/gateway.jpg
          java.io.IOException: Server returned HTTP response code: 401 for URL: https://thgitlab.helpsystems.com/uploads/-/system/group/avatar/21/gateway.jpg
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1900)
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
          at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3057)
          at java.net.URLConnection.getContentType(URLConnection.java:512)
          at sun.net.www.protocol.https.HttpsURLConnectionImpl.getContentType(HttpsURLConnectionImpl.java:420)
          at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:506)
          Caused: java.io.IOException: Server returned HTTP response code: 401 for URL: https://thgitlab.helpsystems.com/uploads/-/system/group/avatar/21/gateway.jpg
          at sun.reflect.GeneratedConstructorAccessor493.newInstance(Unknown Source)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
          at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1950)
          at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1945)
          at java.security.AccessController.doPrivileged(Native Method)
          at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1944)
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1514)
          at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
          at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
          at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:513)
          at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:490)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          at java.lang.Thread.run(Thread.java:748)

           

          iancotton Ian added a comment - I'm seeing exactly the same issue. Gitlab version 13.9 Jenkins 2.277.4 Gitlab branch source plugin 1.5.7 2021-05-24 12:31:33.310+0000 [id=28171] INFO i.j.p.g.h.GitLabAvatarCache$FetchImage#call: Server returned HTTP response code: 401 for URL: https://thgitlab.helpsystems.com/uploads/-/system/group/avatar/21/gateway.jpg java.io.IOException: Server returned HTTP response code: 401 for URL: https://thgitlab.helpsystems.com/uploads/-/system/group/avatar/21/gateway.jpg at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1900) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498) at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3057) at java.net.URLConnection.getContentType(URLConnection.java:512) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getContentType(HttpsURLConnectionImpl.java:420) at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:506) Caused: java.io.IOException: Server returned HTTP response code: 401 for URL: https://thgitlab.helpsystems.com/uploads/-/system/group/avatar/21/gateway.jpg at sun.reflect.GeneratedConstructorAccessor493.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1950) at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1945) at java.security.AccessController.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1944) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1514) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268) at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:513) at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:490) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)  
          robross0606 rross added a comment - - edited

          I think I'm seeing the same problem.  My configuration is set to download avatars from GitLab but I'm seeing random ones instead.  Same error in system logs:

          Jan 11, 2022 2:47:03 PM INFO io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage call
          Server returned HTTP response code: 401 for URL: https://git.mycompany.com/uploads/-/system/project/avatar/32/1949580-200.png
          java.io.IOException: Server returned HTTP response code: 401 for URL: https://git.mycompany.com/uploads/-/system/project/avatar/32/1949580-200.png
          	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1897)
          	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1495)
          	at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3058)
          	at java.net.URLConnection.getContentType(URLConnection.java:512)
          	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getContentType(HttpsURLConnectionImpl.java:420)
          	at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:506)
          Caused: java.io.IOException: Server returned HTTP response code: 401 for URL: https://git.mycompany.com/uploads/-/system/project/avatar/32/1949580-200.png
          	at sun.reflect.GeneratedConstructorAccessor571.newInstance(Unknown Source)
          	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
          	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1947)
          	at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1942)
          	at java.security.AccessController.doPrivileged(Native Method)
          	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1941)
          	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1511)
          	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1495)
          	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
          	at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:513)
          	at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:490)
          	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          	at java.lang.Thread.run(Thread.java:748)
          

          I have confirmed that the URL being shown in the error does indeed point to the correct avatar image. I can see it manually via a browser with my own credentials. The credentials I've configured in Jenkins have full maintainer role in an on-prem GitLab instance so it should also be able to see the avatar.

          robross0606 rross added a comment - - edited I think I'm seeing the same problem.  My configuration is set to download avatars from GitLab but I'm seeing random ones instead.  Same error in system logs: Jan 11, 2022 2:47:03 PM INFO io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage call Server returned HTTP response code: 401 for URL: https://git.mycompany.com/uploads/-/system/project/avatar/32/1949580-200.png java.io.IOException: Server returned HTTP response code: 401 for URL: https://git.mycompany.com/uploads/-/system/project/avatar/32/1949580-200.png at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1897) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1495) at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3058) at java.net.URLConnection.getContentType(URLConnection.java:512) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getContentType(HttpsURLConnectionImpl.java:420) at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:506) Caused: java.io.IOException: Server returned HTTP response code: 401 for URL: https://git.mycompany.com/uploads/-/system/project/avatar/32/1949580-200.png at sun.reflect.GeneratedConstructorAccessor571.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1947) at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1942) at java.security.AccessController.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1941) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1511) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1495) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268) at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:513) at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabAvatarCache$FetchImage.call(GitLabAvatarCache.java:490) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) I have confirmed that the URL being shown in the error does indeed point to the correct avatar image. I can see it manually via a browser with my own credentials. The credentials I've configured in Jenkins have full maintainer role in an on-prem GitLab instance so it should also be able to see the avatar.
          materigoprecitec Mate Rigo added a comment - - edited

          The avatar seems only to  show up if the visibility setting in the repository is set to public.

          The credentials only apply to Rest API, which is basically just loading json back and forth. The avatar on the other hand is a plain html response, which requires session cookies and whatnot about being logged on, hence the 401 html response.

          I am not sure if this can be handled alone on the plugin site.

          I guess if someone can come up how to get the image via the Rest API, then it can be implemented in the plugin.

           

          Edit:

          Ok, this info is also in the official documentation:

          materigoprecitec Mate Rigo added a comment - - edited The avatar seems only to  show up if the visibility setting in the repository is set to public. The credentials only apply to Rest API, which is basically just loading json back and forth. The avatar on the other hand is a plain html response, which requires session cookies and whatnot about being logged on, hence the 401 html response. I am not sure if this can be handled alone on the plugin site. I guess if someone can come up how to get the image via the Rest API, then it can be implemented in the plugin.   Edit: Ok, this info is also in the official documentation:

          People

            baymac Parichay Barpanda
            ytux Ytux
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: