aosapps / drone-sonar-plugin

The plugin of Drone CI to integrate with SonarQube (previously called Sonar), which is an open source code quality management platform.
MIT License
30 stars 51 forks source link

Error during SonarQube Scanner execution #3

Closed meodemsao closed 5 years ago

meodemsao commented 5 years ago

I have issue run lastest drone-sonar-plugin

my config



- name: code analysis
    image: aosapps/drone-sonar-plugin    
    settings:      
      sonar_host:
        from_secret: sonar_host
      sonar_token:
        from_secret: sonar_token     
      key: project-key
      name:  project-name
      ver: 1.0
      timeout: 20
      sources: .
      level: DEBUG
      showProfiling: true
      exclusions: "**/static/**/*,**/dist/**/*.js"
`

error log

```console

==> Code Analysis Result: INFO: Scanner configuration file: /bin/sonar-scanner-3.2.0.1227/conf/sonar-scanner.properties
--
3 | INFO: Project root configuration file: NONE
4 | 08:48:30.266 INFO: SonarQube Scanner 3.2.0.1227
5 | 08:48:30.271 INFO: Java 1.8.0_171 Oracle Corporation (64-bit)
6 | 08:48:30.271 INFO: Linux 5.0.0-2.el7.elrepo.x86_64 amd64
7 | 08:48:30.545 DEBUG: keyStore is :
8 | 08:48:30.545 DEBUG: keyStore type is : jks
9 | 08:48:30.546 DEBUG: keyStore provider is :
10 | 08:48:30.546 DEBUG: init keystore
11 | 08:48:30.546 DEBUG: init keymanager of type SunX509
12 | 08:48:30.725 DEBUG: Create: /root/.sonar/cache
13 | 08:48:30.733 INFO: User cache: /root/.sonar/cache
14 | 08:48:30.733 DEBUG: Create: /root/.sonar/cache/_tmp
15 | 08:48:30.741 DEBUG: Extract sonar-scanner-api-batch in temp...
16 | 08:48:30.759 DEBUG: Get bootstrap index...
17 | 08:48:30.759 DEBUG: Download: /batch/index
18 | 08:48:30.764 ERROR: SonarQube server [] can not be reached
19 | 08:48:30.765 INFO: ------------------------------------------------------------------------
20 | 08:48:30.765 INFO: EXECUTION FAILURE
21 | 08:48:30.765 INFO: ------------------------------------------------------------------------
22 | 08:48:30.765 INFO: Total time: 0.652s
23 | 08:48:30.839 INFO: Final Memory: 4M/151M
24 | 08:48:30.839 INFO: ------------------------------------------------------------------------
25 | 08:48:30.840 ERROR: Error during SonarQube Scanner execution
26 | 08:48:30.840 ERROR: Unable to execute SonarQube
27 | 08:48:30.840 ERROR: Caused by: Fail to get bootstrap index from server
28 | 08:48:30.840 ERROR: Caused by: unexpected url: /batch/index
29 | 08:48:30.840 ERROR:
30 | 08:48:30.840 ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
31 |  
32 | exit status 1
`
roganw commented 5 years ago

Please check whether your SonarQube is accessable. For example, request the url of sonar_host/batch/index in your localhost or Drone server.

meodemsao commented 5 years ago

@roganw i request sonar_host/batch/index return

sonar-scanner-engine-shaded-7.6-all.jar|993f707e3af7ba4f46f121039128516b

fptiangco commented 5 years ago

And if you do find that SonarQube is accessible, check to see if you're pulling the right drone-sonar-plugin image for your version of drone. I'm using v1 of drone and I found out that I needed to pull a tagged version of this plugin, as below: image: aosapps/drone-sonar-plugin:1.0

meodemsao commented 5 years ago

@fptiangco I using drone v1 with image: aosapps/drone-sonar-plugin:1.0 and have same error


02:27:27.962 DEBUG: Extract sonar-scanner-api-batch in temp...
15 | 02:27:27.977 DEBUG: Get bootstrap index...
16 | 02:27:27.978 DEBUG: Download: http://x.x.x.x:9001/batch/index
17 | 02:27:28.031 ERROR: SonarQube server [http://x.x.x.x:9001] can not be reached
18 | 02:27:28.031 INFO: ------------------------------------------------------------------------
19 | 02:27:28.031 INFO: EXECUTION FAILURE
20 | 02:27:28.031 INFO: ------------------------------------------------------------------------
21 | 02:27:28.032 INFO: Total time: 0.550s
22 | 02:27:28.064 INFO: Final Memory: 4M/151M
23 | 02:27:28.065 INFO: ------------------------------------------------------------------------
24 | 02:27:28.065 ERROR: Error during SonarQube Scanner execution
25 | 02:27:28.065 ERROR: Unable to execute SonarQube
26 | 02:27:28.065 ERROR: Caused by: Fail to get bootstrap index from server
27 | 02:27:28.065 ERROR: Caused by: Status returned by url [http://x.x.x.x:9001/batch/index] is not valid: [404]
28 | 02:27:28.065 ERROR:
29 | 02:27:28.065 ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.`

 And my sonar docker-compose config

```yaml

version: "3"

services:
  sonarqube:
    image: sonarqube
    ports:
      - 9001:9000
    networks:
      - sonarnet
    environment:
      - sonar.jdbc.url=jdbc:postgresql://db:5432/sonar
    volumes:
      - sonarqube_conf:/opt/sonarqube/conf
      - sonarqube_data:/opt/sonarqube/data
      - sonarqube_extensions:/opt/sonarqube/extensions

  db:
    image: postgres
    networks:
      - sonarnet
    environment:
      - POSTGRES_USER=sonar
      - POSTGRES_PASSWORD=sonar
    volumes:
      - postgresql:/var/lib/postgresql
      # This needs explicit mapping due to https://github.com/docker-library/postgres/blob/4e48e3228a30763913ece952c611e5e9b95c8759/Dockerfile.template#L52
      - postgresql_data:/var/lib/postgresql/data

networks:
  sonarnet:
    driver: bridge

volumes:
  sonarqube_conf:
  sonarqube_data:
  sonarqube_extensions:
  postgresql:
  postgresql_data:`
NickCarton commented 5 years ago

I fixed this by using the following config

 - name: code-analysis
    image: aosapps/drone-sonar-plugin
    environment:
      SONAR_HOST:
        from_secret: sonar_host
      SONAR_TOKEN:
        from_secret: sonar_token

That being said; The plugins.drone.io information definitely needs to be updated

NickCarton commented 5 years ago

Found the actual issue: https://hub.docker.com/r/aosapps/drone-sonar-plugin/tags

latest has not been updated for 7 months, use the 1.0 tag

roganw commented 5 years ago

@meodemsao It's 404 while requesting [http://x.x.x.x:9001/batch/index] in your Drone Server.

Status returned by url [http://x.x.x.x:9001/batch/index] is not valid: [404]

meodemsao commented 5 years ago

@roganw i using browser return

sonar-scanner-engine-shaded-7.6-all.jar|993f707e3af7ba4f46f121039128516b