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
121 stars 87 forks source link

"Exception caught: 401 Unauthorized" when sending MR updates #200

Closed ghost closed 2 months ago

ghost commented 2 years ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.332.2 OS: Linux - 5.16.18-200.fc35.x86_64 --- ace-editor:1.1 ansicolor:1.0.1 antisamy-markup-formatter:2.7 apache-httpcomponents-client-4-api:4.5.13-1.0 authentication-tokens:1.4 authorize-project:1.4.0 aws-credentials:191.vcb_f183ce58b_9 aws-java-sdk-ec2:1.12.201-326.veb_6ce41104a_e aws-java-sdk-minimal:1.12.201-326.veb_6ce41104a_e bitbucket:223.vd12f2bca5430 bootstrap4-api:4.6.0-5 bootstrap5-api:5.1.3-6 bouncycastle-api:2.26 branch-api:2.1046.v0ca_37783ecc5 build-timeout:1.20 caffeine-api:2.9.3-65.v6a_47d0f4d1fe checks-api:1.7.3 cloudbees-bitbucket-branch-source:765.v5a_2d6a_23c01d cloudbees-folder:6.714.v79e858ef76a_2 command-launcher:81.v9c2cb_cb_db_392 config-file-provider:3.10.0 credentials:1087.1089.v2f1b_9a_b_040e4 credentials-binding:523.vd859a_4b_122e6 custom-folder-icon:1.9 dark-theme:156.v6cf16af6f9ef display-url-api:2.3.6 docker-commons:1.19 docker-workflow:1.28 durable-task:496.va67c6f9eefa7 ec2:1.68 echarts-api:5.3.2-1 font-awesome-api:6.0.0-1 git:4.11.1 git-client:3.11.0 git-server:1.11 gitlab-api:5.0.1-69.vcdc19e779072 gitlab-branch-source:625.v85cf3a_400cfe gitlab-plugin:1.5.31 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 jackson2-api:2.13.2.20220328-273.v11d70a_b_a_1a_52 javax-activation-api:1.2.0-3 javax-mail-api:1.6.2-6 jaxb:2.3.0.1 jdk-tool:1.5 jersey2-api:2.35-7 jquery3-api:3.6.0-3 jsch:0.1.55.2 junit:1.63 lockable-resources:2.14 mailer:414.vcc4c33714601 matrix-auth:3.1.2 matrix-project:771.v574584b_39e60 mercurial:2.16 momentjs:1.1.1 node-iterator-api:1.5.1 pipeline-build-step:2.18 pipeline-graph-analysis:195.v5812d95a_a_2f9 pipeline-input-step:448.v37cea_9a_10a_70 pipeline-milestone-step:101.vd572fef9d926 pipeline-model-api:2.2077.vc78ec45162f1 pipeline-model-definition:2.2077.vc78ec45162f1 pipeline-model-extensions:2.2077.vc78ec45162f1 pipeline-multibranch-defaults:2.1 pipeline-rest-api:2.24 pipeline-stage-step:293.v200037eefcd5 pipeline-stage-tags-metadata:2.2077.vc78ec45162f1 pipeline-stage-view:2.24 plain-credentials:1.8 plugin-util-api:2.16.0 popper-api:1.16.1-3 popper2-api:2.11.5-1 resource-disposer:0.19 role-strategy:3.2.0 saml:2.296.v0016349946db_ scm-api:608.vfa_f971c5a_a_e9 script-security:1158.v7c1b_73a_69a_08 simple-theme-plugin:103.va_161d09c38c7 snakeyaml-api:1.30.1 ssh-credentials:277.v95c2fec1c047 ssh-slaves:1.814.vc82988f54b_10 sshd:3.228.v4c9f9e652c86 structs:318.va_f3ccb_729b_71 theme-manager:0.6 timestamper:1.17 token-macro:293.v283932a_0a_b_49 trilead-api:1.57.v6e90e07157e1 variant:1.4 workflow-aggregator:2.7 workflow-api:1144.v61c3180fa_03f workflow-basic-steps:948.v2c72a_091b_b_68 workflow-cps:2689.v434009a_31b_f1 workflow-cps-global-lib:570.v21311f4951f8 workflow-durable-task-step:1130.v8fd69d0b_8857 workflow-job:1180.v04c4e75dce43 workflow-multibranch:712.vc169a_1387405 workflow-scm-step:399.v9b_8f4da_65061 workflow-step-api:625.vd896b_f445a_f8 workflow-support:819.v37d707a_71d9b_ ws-cleanup:0.42 ```

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

Linux; jenkins-master in docker

Reproduction steps

  1. Setup the plugin configuration: working.
  2. Setup credentials and hit the test button: working.
  3. Setup multibranch pipeline: all working.
  4. Build status on gitlab: not working.

Expected Results

Build status on gitlab.com

Actual Results

Not build status on gitlab.com

Anything else?

Logs says:

May 05, 2022 9:23:43 PM WARNING io.jenkins.plugins.gitlabbranchsource.helpers.GitLabPipelineStatusNotifier sendNotifications
Exception caught: 401 Unauthorized

I want to emphasize: credentials works. Test button says: Credentials verified for user XXX. The Personal Access Token gives access to everything gitlab.com can authorize.

drakenfly commented 2 years ago

I had to give the user administrator rights in our gitlab installation (Gitlab CE Omnibus - Docker Image) to make it work. Probably those APIs are not accessible to "simple" users.

Janfy commented 2 years ago

Hi @gui-don , i had the same issue and solved it by changing scope of my GitLab Personal Access Token credential from SYSTEM to GLOBAL.

Turiok commented 2 years ago

duplicate of #221

ghost commented 2 months ago

I’m not seeing this problem anymore, so I’m gonna close.