gitlab-branch-source-plugin icon indicating copy to clipboard operation
gitlab-branch-source-plugin copied to clipboard

Private Repos are not listed in Projects Combobox in Multibranch Config

Open cyberjaws opened this issue 4 years ago • 8 comments

Create a private repo in GitLab named "Test1" for User X. Create a GitLab access token for User X. Create a new multibranch Pipeline in Jenkins. Source is of type GitLab Project. Add the credentials for X:Access Token. Add the Owner (X) in the owner field. The form ponders the input and intead of -None- in the field nothing is displayed. Hit Save.

Log from the subsequent Scan: Cannot deserialize instance of `org.gitlab4j.api.models.Project` out of START_ARRAY token.

If a public repo is added in GitLab and the process is repeated, the public repo is listed in the Projects selection combobox, but still not the private repo.

Plugin Version: 1.5.1 GitLab CE Version: 13.3.6 Jenkins Version: 2.235.5

cyberjaws avatar Jan 13 '21 17:01 cyberjaws

Have the same problem. Added the credentials of the user that does have access to the project, but nothing apart from public or internal projects is visible in the combobox.

aleksa2808 avatar Feb 26 '21 19:02 aleksa2808

@aleksa2808 Hello,

Did you manage to solve this issue? I cannot see my private gitlab Repositories in the projects tab.

amin224 avatar Sep 09 '21 12:09 amin224

@amin224 no, the "hotfix" of making all projects using this plugin "internal" is still in effect.

aleksa2808 avatar Sep 09 '21 15:09 aleksa2808

Gitlab personal access tokens start with the prefix glpat- and the general format of personal access tokens is: glpat-abc..... The actual significant section is 20 characters long. That's why gitlab-branch-source-plugin enforces 20 characters without prefix but we have checked the incoming HTTP request to GitLab server contains a private-token header with the actual value coming from credentials and without glpat- prefix. It causes 401 error.

As a workaround, we will try to bypass form validation using Jenkins Configuration as Code.

For the actual fix, we can either add a prefix to the HTTP header value or we can increase the token maximum length criteria to 26 characters.

firatkucuk avatar Jan 16 '23 11:01 firatkucuk

FWIW, I cannot reproduce this issue with current software versions:

  • GitLab CE 15.10.1
  • Jenkins 2.397
  • GitLab Branch Source ~~1703.vd5a_2b_29c6cdc~~ 647.vdee7766b_cfa_e
  1. Created a PAT with read_api & read_repository permission.
  2. Configured a GitLab connection with this PAT
  3. Create a multibranch pipeline job
  4. Select GitLab Project
  5. Enter Username into "Owner"
  6. Projects dropdown is filled with private, internal and public repositories

TobiX avatar Apr 03 '23 18:04 TobiX

Hey @TobiX, I tried to reproduce your non reproduction but GitLab Branch Source plugin does not exist in version 1703.vd5a_2b_29c6cdc

xaviou avatar Apr 04 '23 07:04 xaviou

@xaviou Sorry, copy & paste error. Ment to write 647.vdee7766b_cfa_e, which was released ~2 weeks ago (https://github.com/jenkinsci/gitlab-branch-source-plugin/releases)

TobiX avatar Apr 04 '23 09:04 TobiX