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

sonarqube integration doesn't authenticate

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Jenkins: 2.73.2.1-rolling

      InfluxDB plugin: 1.12.3

      Jenkins pipeline implementation.

      I am attempting to publish sonarqube results with the influxdb plugin, but I get the following error:

      [InfluxDB Plugin] Publishing data to: [url=http://influx.example.com, description=influxdb, username=jenkins, password=*****, database=jenkins]
      [InfluxDB Plugin] SonarQube data found. Writing to InfluxDB...
      [InfluxDB Plugin] Failed to collect data. Ignoring Exception:java.lang.RuntimeException: Failed : HTTP error code : 401
      [InfluxDB Plugin] Completed.

      This is because our sonarqube installation requires authentication. I have wrapped the step([$class: 'InfluxDbPublisher']), inside a withSonarQubeEnv block, which exposes a number of new environment variables, including SONAR_HOST_URL and SONAR_AUTH_TOKEN.

      It would be great if the influxdb plugin could utilize the exposed ENV variables to authenticate with Sonarqube (if available)

        Attachments

          Activity

          mgriffin Michael Griffin created issue -
          Hide
          aleksisimell Aleksi Simell added a comment -

          Improvement implemented and will be available in the next release.

          Show
          aleksisimell Aleksi Simell added a comment - Improvement implemented and will be available in the next release.
          aleksisimell Aleksi Simell made changes -
          Field Original Value New Value
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Done [ 10000 ]
          Hide
          jl68 Jonas Lindström added a comment - - edited

          I have tried the suggested solution with a withSonarQubeEnv block, i.e.

          withSonarQubeEnv(<SonarQube installation ID>) {
            step([$class : 'InfluxDbPublisher',
            customData : null,
            customDataMap : null,
            customPrefix : null,
            customProjectName: null,
            target : 'jenkins_data'])
          }

          Unfortunately I still get HTTP 401. I have verified that SONAR_AUTH_TOKEN is set inside the block, but it's not accessible to the InfluxDB plugin, it is still null. Perhaps I am doing something wrong. Have you been able to verify the fix with Jenkins pipeline, Aleksi Simell?

          Running plugin version 1.14.

          Show
          jl68 Jonas Lindström added a comment - - edited I have tried the suggested solution with a withSonarQubeEnv  block, i.e. withSonarQubeEnv(<SonarQube installation ID>) {   step([$class : 'InfluxDbPublisher' ,   customData : null ,   customDataMap : null ,   customPrefix : null ,   customProjectName: null ,   target : 'jenkins_data' ]) } Unfortunately I still get HTTP 401. I have verified that SONAR_AUTH_TOKEN is set inside the block, but it's not accessible to the InfluxDB plugin, it is still null . Perhaps I am doing something wrong. Have you been able to verify the fix with Jenkins pipeline, Aleksi Simell ? Running plugin version 1.14.
          Hide
          cwebbtw Christopher Webb added a comment -

          Confirmed that this doesn't work in a Jenkins declarative pipeline

          Show
          cwebbtw Christopher Webb added a comment - Confirmed that this doesn't work in a Jenkins declarative pipeline
          cwebbtw Christopher Webb made changes -
          Resolution Done [ 10000 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Hide
          rahulsharma1984 Rahul Sharma added a comment -

          Can someone post an example snippet on how to pass the Auth Token to the plugin in a jenkins Pipeline. It works fine if i add a JUnit in the code base but i am not able to pass it from Pipeline to the plugin in a real environment.

          Show
          rahulsharma1984 Rahul Sharma added a comment - Can someone post an example snippet on how to pass the Auth Token to the plugin in a jenkins Pipeline. It works fine if i add a JUnit in the code base but i am not able to pass it from Pipeline to the plugin in a real environment.
          Hide
          forster_ch Christoph Forster added a comment - - edited

          Problem still occurs with Plugin Version 1.20.

          Jenkins: 2.150

          SonarQube: 7.1

          The Token is valid and Environment Variable "SONAR_AUTH_TOKEN" is set with the correct value

          Show
          forster_ch Christoph Forster added a comment - - edited Problem still occurs with Plugin Version 1.20. Jenkins: 2.150 SonarQube: 7.1 The Token is valid and Environment Variable "SONAR_AUTH_TOKEN" is set with the correct value
          Hide
          forster_ch Christoph Forster added a comment - - edited

          I managed it to send the Authentication using a "Jenkins Global Environment Variable" named "SONAR_AUTH_TOKEN".

          Also it is important (using SonarQube  7.4 and InfluxDB Plugin 1.20.1) to set an Environment Variable "SONAR_HOST_URL".

          Show
          forster_ch Christoph Forster added a comment - - edited I managed it to send the Authentication using a "Jenkins Global Environment Variable" named "SONAR_AUTH_TOKEN". Also it is important (using SonarQube  7.4 and InfluxDB Plugin 1.20.1) to set an Environment Variable "SONAR_HOST_URL".
          Hide
          jl68 Jonas Lindström added a comment -

          Christoph Forster Are you using Jenkins Pipeline?

          Show
          jl68 Jonas Lindström added a comment - Christoph Forster Are you using Jenkins Pipeline?
          Hide
          forster_ch Christoph Forster added a comment -
          Show
          forster_ch Christoph Forster added a comment - Jonas Lindström : yes

            People

            • Assignee:
              aleksisimell Aleksi Simell
              Reporter:
              mgriffin Michael Griffin
            • Votes:
              2 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated: