jenkinsci / gitlab-branch-source-plugin

A Jenkins Plugin for GitLab Multibranch Pipeline jobs and Folder Organization
https://plugins.jenkins.io/gitlab-branch-source
MIT License
122 stars 87 forks source link

Plugin's PAT requirements don't match what gitlab generates #207

Closed jycchoi closed 2 years ago

jycchoi commented 2 years ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.332.3 OS: Linux - 4.18.0-305.el8.x86_64 --- ace-editor:1.1 analysis-model-api:10.10.1 ant:475.vf34069fef73c antisamy-markup-formatter:2.7 apache-httpcomponents-client-4-api:4.5.13-1.0 authorize-project:1.4.0 bootstrap4-api:4.6.0-4 bootstrap5-api:5.1.3-7 bouncycastle-api:2.25 branch-api:2.1046.v0ca_37783ecc5 build-discarder:60.v1747b0eb632a caffeine-api:2.9.3-65.v6a_47d0f4d1fe checks-api:1.7.4 cloudbees-folder:6.722.v8165b_a_cf25e9 command-launcher:81.v9c2cb_cb_db_392 config-file-provider:3.10.0 configuration-as-code:1429.v09b_044a_c93de credentials:1087.1089.v2f1b_9a_b_040e4 credentials-binding:523.vd859a_4b_122e6 data-tables-api:1.11.4-4 display-url-api:2.3.6 durable-task:496.va67c6f9eefa7 echarts-api:5.3.2-2 envinject:2.866.v5c0403e3d4df envinject-api:1.199.v3ce31253ed13 extended-read-permission:3.2 extended-security-settings:1.3 file-operations:1.11 font-awesome-api:6.1.1-1 forensics-api:1.13.0 git:4.11.3 git-client:3.11.0 git-forensics:1.8.0 git-server:1.11 github-api:1.303-400.v35c2d8258028 gitlab-api:5.0.1-72.vb_8c272862e86 gitlab-branch-source:625.v85cf3a_400cfe gitlab-plugin:1.5.32 gradle:1.38 h2-api:1.4.199 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 htmlpublisher:1.30 jackson2-api:2.13.3-285.vc03c0256d517 javax-activation-api:1.2.0-3 javax-mail-api:1.6.2-6 jaxb:2.3.6-1 jdk-tool:1.0 jersey2-api:2.35-8 job-dsl:1.79 jquery3-api:3.6.0-4 jsch:0.1.55.2 junit:1.60 ldap:2.10 locale:144.v1a_998824ddb_3 lockable-resources:2.14 mailer:414.vcc4c33714601 matrix-auth:3.1.1 matrix-project:771.v574584b_39e60 momentjs:1.1.1 multibranch-build-strategy-extension:1.0.10 okhttp-api:4.9.3-105.vb96869f8ac3a pipeline-build-step:2.18 pipeline-graph-analysis:188.v3a01e7973f2c pipeline-groovy-lib:589.vb_a_b_4a_a_8c443c pipeline-input-step:448.v37cea_9a_10a_70 pipeline-maven:3.10.0 pipeline-milestone-step:101.vd572fef9d926 pipeline-model-api:2.2081.v3919681ffc1e pipeline-model-definition:2.2081.v3919681ffc1e pipeline-model-extensions:2.2081.v3919681ffc1e pipeline-rest-api:2.22 pipeline-stage-step:293.v200037eefcd5 pipeline-stage-tags-metadata:2.2081.v3919681ffc1e pipeline-stage-view:2.22 pipeline-utility-steps:2.12.0 plain-credentials:1.8 plugin-util-api:2.17.0 popper-api:1.16.1-3 popper2-api:2.11.5-2 prism-api:1.28.0-2 publish-over:0.22 publish-over-ssh:1.24 role-strategy:3.2.0 scm-api:608.vfa_f971c5a_a_e9 script-security:1172.v35f6a_0b_8207e snakeyaml-api:1.30.1 ssh-credentials:277.v95c2fec1c047 ssh-slaves:1.814.vc82988f54b_10 sshd:3.237.v883d165a_c1d3 structs:318.va_f3ccb_729b_71 timestamper:1.17 token-macro:293.v283932a_0a_b_49 trilead-api:1.57.v6e90e07157e1 variant:1.4 versioncolumn:2.2 warnings-ng:9.12.0 workflow-aggregator:578.vf9a_f99755f4a_ workflow-api:1153.vb_912c0e47fb_a_ workflow-basic-steps:948.v2c72a_091b_b_68 workflow-cps:2692.v76b_089ccd026 workflow-cps-global-lib:588.v576c103a_ff86 workflow-durable-task-step:1139.v252a_e12e8463 workflow-job:1182.v60a_e6279b_579 workflow-multibranch:712.vc169a_1387405 workflow-scm-step:400.v6b_89a_1317c9a_ workflow-step-api:625.vd896b_f445a_f8 workflow-support:820.vd1a_6cc65ef33 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

RHEL 8

Reproduction steps

  1. Install GitLab plugin
  2. Go to Gitlab and generate a new Personal Access Token
  3. Go to Manage Jenkins/Configure System
  4. Add a credential to the Gitlab Server, choose type "Gitlab Personal Access Token"
  5. Paste in the new token you made.
  6. Observe a validation error because it is not 20 characters long.

Expected Results

Credential should be saved

Actual Results

cannot save

Anything else?

The credential has a prefix now. Where before the token might be "abcdeabcdeabcdeabcde" it is now "glpat-abcdeabcdeabcdeabcde"

Copied from: https://github.com/jenkinsci/gitlab-plugin/issues/1215

jmini commented 2 years ago

Our workaround until this is solved is to configure the prefix glpat- to be empty, so the generated access token are back to length == 20. https://docs.gitlab.com/ee/user/admin_area/settings/account_and_limit_settings.html#personal-access-token-prefix