sonar runner authorization error - jenkins

I'm trying to send a job to sonarqube from jenkins. However I'm getting an error saying te following when I run the job
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: Not authorized. Please check the properties sonar.login and sonar.password.
The system I'm using is as follows. I have jenkins 2.7.1, SonarQube 5.6 and SonarQube Runner 2.4 is installed on my server as well.
To log in to jenkins and sonarqube I'm using a ldap that only holds ldap users, no local users exists.
In my jenkins settings I set up SonarQube as follows
the token was created in a admin account in SonarQube
When I created the job I made a new build step for a sonarqube scanner. Inside my project I created a sonar-project.properties file that holds the following information
sonar.projectKey=org.sonarqube:php-ut-sq-scanner
sonar.projectName=vanbenthem :: PHPUnit :: SonarQube Scanner
sonar.projectVersion=1.0
sonar.sources=src
sonar.tests=tests
sonar.language=php
sonar.sourceEncoding=UTF-8
# Reusing PHPUnit reports
sonar.php.coverage.reportPath=reports/phpunit.coverage.xml
sonar.php.tests.reportPath=reports/phpunit.xml
Can anyone tell me what I'm doing wrong? To my understanding I shouldn't be giving a login and password since SonarQube 5.4
Hope someone will be able to help me out
per nicloas' request
Here are the console output from jenkins and my sonar settings regarding my ldap.

Well, I faced the same issue with Bitbucket pipelines and Sonarqube. It turned out that the Sonarqube authentication token I was using was incorrect. It is configured as SONAR_TOKEN in Bitbucket's repository variables and correcting it solved the issue.
Please make sure to double check the Server authentication token you are entering here.

Make sure the token provided by Sonarqube and stored in Jenkins is correct

Related

Sonar-Gerrit integration shows error in Jenkins

There is a Jenkins freestyle job that is triggered by some Gerrit events.In response to triggers, it downloads the changes and runs a Sonarqube Analysis. The Sonarqube comments detailing the results are to be posted on Gerrit after the analysis is complete.This is the expected behaviour.
As of now, In Jenkins, the Sonarqube execution is success. But the build is failed mentioning the error " *ERROR: Build step failed with exception java.lang.IllegalArgumentException: Gerrit change number is empty*
Could anyone please help on this?
Reference:https://plugins.jenkins.io/sonar-gerrit/
Followed the same steps as mentioned in the above document.
Jenkins console output
Expected: The Sonarqube should post the comments to the respective Gerrit change,whether the Sonar-verified is +1/-1.

Jenkins not able to connect sonarqube server

I'm running Ubuntu on Oracle VM from my Windows 10 machine.
On Ubuntu, I'm running Jenkins in a docker container.
In this I've created a job which in which a I've added a SonarScanner build step.
In sonar configurations, I've mentioned a remote URL of my sonar server. Same URL can be opened in web browser without any problem.
I've also mentioned sonar project properties in the build step.
But when I execute the build, I get error, that jenkins is not able to connect sonar server.
But it's fishy since, I'm able to open same URL from my browser.
The jenkins setup & sonar configurations also seems to correct as same I've used in my native window's jenkins setup & it worked.
So I think it is something to do with VM, but not sure exactly what.
Any suggestions.
Also, on Ubuntu I'm working as a default user with admin access. (Not as root user)
Thank you
Error Trace:
10:34:27.358 ERROR: Error during SonarQube Scanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:167)
at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:113)
at org.sonarsource.scanner.cli.Main.execute(Main.java:73)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)
at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
... 7 more
Caused by: java.net.UnknownHostException: sonarqube.intranet.myhost.com: Name or service not known
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
at java.net.InetAddress.getAllByName(InetAddress.java:1192)
at java.net.InetAddress.getAllByName(InetAddress.java:1126)
at org.sonarsource.scanner.api.internal.shaded.okhttp.Dns$1.lookup(Dns.java:39)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:171)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RouteSelector.nextProxy(RouteSelector.java:137)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RouteSelector.next(RouteSelector.java:82)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:171)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:69)
at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:113)
at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:98)
at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:39)
... 10 more
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE

When I am running Execute SonarQube Scanner on Jenkins, job always fails

I am running Execute SonarQube Scanner on Jenkins, but the job always fails.
The job log shows:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:
sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project
helpRequestMgmtUI: Not authorized. Please check the properties
sonar.login and sonar.password. -> [Help 1]
In job configuration, I added the following into Analysis properties:
sonar.projectKey=org.sonarqube:javascript-lcov-sq-scanner
sonar.projectName=My project
sonar.projectVersion=1.0
sonar.language=js
sonar.sources=webapp
sonar.sourceEncoding=UTF-8
sonar.javascript.coveragePlugin=jacoco
sonar.login=admin
sonar.password=admin
In the last two lines I have already added user name and password but it does not work for executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603
However, the SonarQube dashboard is created successfully.
How do I avoid this authorization exception, when analysing my project?

Jenkins + Sonar create project

I'm having problem with the execution of sonar analysis from Jenkins jobs. I have Jenkins ver. 1.621 and sonar Version 5.1.
I had this tools working and executing sonar analysis from Jenkins til I define user authentication with LDAP in both applications. There is no error in the execution of jobs and I can see the execution of sonar command task in Jenkins project log but when I check sonar the analysis never happened. I just check "everything" but I don't know what could be, I thinking could be role/permissions but I checked this and it seem right.
Any idea about What could be happened?
These are my specification:
Jenkins
Project-Sonar. This is the content of "Analysis properties" defined in the Post Steps->Invoke StandAlone SonarQube Analysis.
# Required metadata
sonar.projectKey=plandecuentas
sonar.projectName=plandecuentas
sonar.projectVersion=1.0
# Set modules IDs
#sonar.modules=src
# Comma-separated paths to directories with sources (required)
sonar.sources=src
# Language
sonar.language=java
# Encoding of the source files
sonar.sourceEncoding=UTF-8
Jenkins-Sonar Library:
Sonar-Qube Plugin 2.2.1
I have configured this libraries with the same info before enable LDAP authentication.

Jenkins - Integrating JIRA with Jenkins, for creating ticket automatically when build fails, in Jenkins

I am using Jenkins to run jobs and want to create/update tickets in JIRA, whenever build fails. I have downloaded JIRA plugin, Jira Issue Updater, JiraTestResultReporter plugins and configured URL and credentials, under Manage Jenkins/Configure System.
In the job am running, under Post-build Actions, I added 'Create Jira Issue' with project key, assignee name etc and 'Jira Test Result Reporter' with all required credentials.
I get the following error in the console:
ERROR: Publisher 'Jira Test Result Reporter' aborted due to exception:
java.lang.NoSuchMethodError: hudson.model.AbstractBuild.getTestResultAction()Lhudson/tasks/test/AbstractTestResultAction;
at JiraTestResultReporter.JiraReporter.perform(JiraReporter.java:105)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
at hudson.model.Run.execute(Run.java:1769)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:374)
Finished: FAILURE
Any idea whats going wrong? Is it not able to find the project? I have access to create ticket in the project specified, in jira.
It is generally possible to create tickets in JIRA programmatically, for example via their REST API.
Regarding your error, this behavior was introduced when the method signature of getTestResultAction() changed to return an Action instead of an AbstractTestResultAction.
The effect on the JiraTestResultReporter plugin is a known issue and is tracked at JENKINS-25140.
The error was fixed in the source of the plugin a while ago, but is still pending a release.
Solution:
As a workaround, Daniel Beck suggests to build and install a snapshot of the current JiraTestResultReporter plugin which seems to solve this particular error (see comments to the Jenkins ticket mentioned above).

Resources