Using Sonar Scanner in Jenkins?

Hi sonarsource community!

I am trying to run the sonar scanner using sonar-scanner. I am using it in a Jenkinsfile, and im fairly new with both technologies so im hoping you guys can help me out.

My Jenkinsfile looks like this:

pipeline {
    agent any
    stages {
        stage('List folder') {
            steps {
                sh 'ls'
            }
        }

        stage('run scan') {
            steps {
                sh 'docker run -v $(pwd):/root/src newtmitch/sonar-scanner sonar-scanner -X \
                      -Dsonar.host.url=http://10.221.4.33:9000 \
                      -Dsonar.jdbc.url=jdbc:h2:tcp://sonarqube/sonar \
                      -Dsonar.projectKey=MyProjectKey \
                      -Dsonar.projectName="My Project Name" \
                      -Dsonar.projectVersion=1 \
                      -Dsonar.projectBaseDir=/root/src \
                      -Dsonar.sources=/root/src'

            }
        }
    }
}

When im trying to build the project, it should;

  1. Get sonar scanner image.
  2. Scan the gradle project…

however, this is the output(some of it)

00:28:11.990 DEBUG: Download plugin 'xml' to '/root/.sonar/_tmp/fileCache2364920702276699701.tmp'
00:28:11.995 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=xml&acceptCompressions=pack200 | time=4ms
00:28:12.014 DEBUG: Download plugin 'scmsvn' to '/root/.sonar/_tmp/fileCache2783407990070533789.tmp'
00:28:12.019 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=scmsvn&acceptCompressions=pack200 | time=5ms
00:28:12.074 INFO: Load/download plugins (done) | time=867ms
00:28:12.196 DEBUG: Plugins:
00:28:12.196 DEBUG:   * SonarPython 1.13.0.2922 (python)
00:28:12.196 DEBUG:   * SonarCSS 1.0.3.724 (cssfamily)
00:28:12.196 DEBUG:   * SonarClojure 1.8.1 (clojure)
00:28:12.196 DEBUG:   * JaCoCo 1.0.1.143 (jacoco)
00:28:12.196 DEBUG:   * SonarGo 1.1.0.1612 (go)
00:28:12.196 DEBUG:   * SonarKotlin 1.5.0.315 (kotlin)
00:28:12.196 DEBUG:   * Svn 1.9.0.1295 (scmsvn)
00:28:12.196 DEBUG:   * SonarJS 5.1.1.7506 (javascript)
00:28:12.197 DEBUG:   * SonarRuby 1.5.0.315 (ruby)
00:28:12.197 DEBUG:   * SonarScala 1.5.0.315 (sonarscala)
00:28:12.197 DEBUG:   * SonarC# 7.14.0.8411 (csharp)
00:28:12.197 DEBUG:   * SonarJava 5.12.1.17771 (java)
00:28:12.197 DEBUG:   * LDAP 2.2.0.608 (ldap)
00:28:12.197 DEBUG:   * SonarHTML 3.1.0.1615 (web)
00:28:12.197 DEBUG:   * Git 1.8.0.1574 (scmgit)
00:28:12.197 DEBUG:   * SonarFlex 2.4.0.1222 (flex)
00:28:12.197 DEBUG:   * SonarXML 2.0.1.2020 (xml)
00:28:12.197 DEBUG:   * SonarPHP 3.0.0.4537 (php)
00:28:12.197 DEBUG:   * SonarTS 1.9.0.3766 (typescript)
00:28:12.197 DEBUG:   * SonarVB 7.14.0.8411 (vbnet)
00:28:12.213 INFO: ------------------------------------------------------------------------
00:28:12.213 INFO: EXECUTION FAILURE
00:28:12.213 INFO: ------------------------------------------------------------------------
00:28:12.213 INFO: Total time: 1.828s
00:28:12.242 INFO: Final Memory: 7M/473M
00:28:12.242 INFO: ------------------------------------------------------------------------
00:28:12.242 ERROR: Error during SonarQube Scanner execution
00:28:12.242 ERROR: Tasks support was removed in SonarQube 7.6.

“Tasks support was removed in sonarqube 7.6”… What does that mean? I have tried googling but theres not a lot of information on the topic.

ok, i solved it myself. removed sonar-scanner -X from the docker run command seemed to do the trick. I have no clue why - but it now works as intended.