jenkinsci / github-autostatus-plugin

Jenkins plugin to provide automatic status for multibranch jobs
https://plugins.jenkins.io/github-autostatus/
MIT License
52 stars 34 forks source link

"Unauthorized"error upon attempt to write to InfluxDB #116

Open vbronfman opened 2 years ago

vbronfman commented 2 years ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.344 OS: Linux - 5.4.72-microsoft-standard-WSL2 --- ace-editor:1.1 ant:475.vf34069fef73c antisamy-markup-formatter:2.7 apache-httpcomponents-client-4-api:4.5.13-1.0 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.4 cloudbees-folder:6.714.v79e858ef76a_2 cobertura:1.17 code-coverage-api:2.0.4 command-launcher:81.v9c2cb_cb_db_392 credentials:1126.ve05618c41e62 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-1 email-ext:2.88 font-awesome-api:6.0.0-1 forensics-api:1.13.0 git:4.11.1 git-client:3.11.0 git-server:1.11 github:1.34.3 github-api:1.303-400.v35c2d8258028 github-autostatus:3.6.2 github-branch-source:1628.vb_2f51293cb_78 gradle:1.38 handlebars:3.0.8 influxdb:3.1.2 jackson2-api:2.13.2.20220328-281.v9ecc7a_5e834f jacoco:3.3.2 javax-activation-api:1.2.0-3 javax-mail-api:1.6.2-6 jaxb:2.3.6-1 jdk-tool:1.5 jjwt-api:0.11.2-71.v2722b_b_06a_2a_f jquery3-api:3.6.0-3 jsch:0.1.55.2 junit:1.63 ldap:2.9 lockable-resources:2.15 mailer:414.vcc4c33714601 matrix-auth:3.1.2 matrix-project:771.v574584b_39e60 metrics:4.1.6.2 momentjs:1.1.1 okhttp-api:4.9.3-105.vb96869f8ac3a pam-auth:1.8 pipeline-build-step:2.18 pipeline-github-lib:36.v4c01db_ca_ed16 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-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 popper2-api:2.11.5-1 prometheus:2.0.11 resource-disposer:0.19 scm-api:608.vfa_f971c5a_a_e9 script-security:1158.v7c1b_73a_69a_08 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 timestamper:1.17 token-macro:293.v283932a_0a_b_49 trilead-api:1.57.v6e90e07157e1 variant:1.4 workflow-aggregator:2.7 workflow-api:1153.vb_912c0e47fb_a_ workflow-basic-steps:948.v2c72a_091b_b_68 workflow-cps:2689.v434009a_31b_f1 workflow-cps-global-lib:575.v24fa_0a_b_f7383 workflow-durable-task-step:1139.v252a_e12e8463 workflow-job:1180.v04c4e75dce43 workflow-multibranch:712.vc169a_1387405 workflow-scm-step:400.v6b_89a_1317c9a_ 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)?

Jenkins server of docker image jenkins/jenkins:latest , reports to InfluxDB v2.2 Attempt to use In Jenkins -> Configure System -> Autostatus Config -> Send to InfluxDB returns {"code":"unauthorized","message":"unauthorized access"} in spite credentials are valid. https://docs.influxdata.com/influxdb/v2.2/write-data/troubleshoot/ specify possible reason: 401 Unauthorized: May indicate one of the following: Authorization: Token header is missing or malformed. API token value is missing from the header.

Reproduction steps

  1. Set jenkins server with 'Job and Stage monitoring' plugin installed.
  2. Set Autostatus Config
    • URL of InfluxDB
    • InfluxDB Credentials
    • InfluxDB Database
  3. InfluxDB v2.2
  4. Create and run pipeline.

Expected Results

Content of InfluxDB bucket updated with details of latest build.

Actual Results

Error in May 15, 2022 12:32:05 PM WARNING org.jenkinsci.plugins.githubautostatus.notifiers.InfluxDbNotifier log {"code":"unauthorized","message":"Unauthorized"}

Anything else?

Could it happen current version of plugin doesn't support interaction with InfluxDB v2.2

jeffpearce commented 2 years ago

Ah yeah, looks like they changed the way they do auth - it's an API token now instead of user/password. i'll have to figure out how to support both old and new auth methods. Thanks for the good repo steps - will make it easier

vbronfman commented 2 years ago

Superb! Quite a speculation but here is they note the way to connect is employ header "Authorization: Token YOUR_INFLUX_TOKEN" (see https://docs.influxdata.com/influxdb/v2.2/api/#tag/Authentication) It work for me via CLI.

andrikoz commented 1 year ago

Hello , we 've experienced the same issue. Do we have any update on that?

yoramshai commented 1 year ago

same here

jeffpearce commented 1 year ago

I finally had some time to look at it this weekend. I have a fix just about done, will publish an update to try in a day or two

yoramshai commented 1 year ago

@jeffpearce thank you ! Any update when the fix will be in ?

jeffpearce commented 1 year ago

@yoramshai thanks for your patience! I am actively working on this, but I don't have an ETA. The project was in need of an upgrade to newer deps, and it's taking a little bit of time to sort through it. I'll get it out as soon as possible.

yoramshai commented 1 year ago

Much appreciated!

mciecha commented 8 months ago

Any update on this one?