Bamboo build is failing with below error
Asked by Dayanand:

Hi team,

I have installed sonar plugin for bamboo but the bamboo plan is failing with the below error.

Unable to find executable at /opt/sonar-scanner-3.0.3/bin/sonar-scanner.  
simple 23-Jan-2018 17:03:11 Build sonar-plugin - sonar-plugin - Default Job #14 (SON-SON-JOB1-14) started building on agent Default Agent  
simple 23-Jan-2018 17:03:11  
simple 23-Jan-2018 17:03:11 Build working directory is /data/bamboo/data/xml-data/build-dir/SON-SON-JOB1  
simple 23-Jan-2018 17:03:11 Executing build sonar-plugin - sonar-plugin - Default Job #14 (SON-SON-JOB1-14)  
simple 23-Jan-2018 17:03:11 Starting task 'Checkout Default Repository' of type 'com.atlassian.bamboo.plugins.vcs:task.vcs.checkout'  
simple 23-Jan-2018 17:03:11 Updating source code to revision: 934034  
simple 23-Jan-2018 17:03:15 Updated source code to revision: 934034  
simple 23-Jan-2018 17:03:15 Finished task 'Checkout Default Repository' with result: Success  
simple 23-Jan-2018 17:03:15 Running pre-build action: VCS Version Collector  
simple 23-Jan-2018 17:03:15 Running pre-build action: Artifactory Release Staging  
simple 23-Jan-2018 17:03:15 Starting task 'sonar-task' of type 'ch.mibex.bamboo.sonar4bamboo:sonar4bamboo.sonarscannertask'  
error 23-Jan-2018 17:03:15 Unable to find executable at /opt/sonar-scanner-3.0.3/bin/sonar-scanner. Will try to run it anyway.  
command 23-Jan-2018 17:03:15 Beginning to execute external process for build 'sonar-plugin - sonar-plugin - Default Job #14 (SON-SON-JOB1-14)'\\n ... running command line: \\n/opt/sonar-scanner-3.0.3/bin/sonar-scanner -Dsonar.host.url=<http://uex-sonarqube.hq.k.grp:9000> -Dsonar.login=\*\*\*\*\*\* -Dsonar.password=\*\*\*\*\*\* ... in: /data/bamboo/data/xml-data/build-dir/SON-SON-JOB1\\n ... using extra environment variables: \\nbamboo_planRepository_1_port=p4-open-prx-cwm:1666\\nbamboo_repository_revision_number=934034\\nbamboo_resultsUrl=[https://atlassian-test.hq.k.grp/bamboo/browse/SON-SON-JOB1-14\\nbamboo_repository_3309569_name=Android](https://atlassian-test.hq.k.grp/bamboo/browse/SON-SON-JOB1-14\nbamboo_repository_3309569_name=Android) SDK 4 Source\\nbamboo_planRepository_1_name=Android SDK 4 Source\\nbamboo_build_working_directory=/data/bamboo/data/xml-data/build-dir/SON-SON-JOB1\\nbamboo_buildKey=SON-SON-JOB1\\nbamboo_shortPlanName=sonar-plugin\\nbamboo_capability_system_p4Executable=/usr/local/bin/p4\\nbamboo_repository_3309569_revision_number=934034\\nbamboo_planRepository_client=bamboo_beij_BEIJING_INT_NMPC_SDK_ANDROID_NGEN\\nbamboo_planRepository_port=p4-open-prx-cwm:1666\\nbamboo_planRepository_name=Android SDK 4 Source\\nbamboo_buildNumber=14\\nbamboo_capability_system_jdk_JDK_1_8_0_131=/usr/java/jdk1.8.0_131\\nbamboo_shortJobName=Default Job\\nbamboo_buildResultsUrl=[https://atlassian-test.hq.k.grp/bamboo/browse/SON-SON-JOB1-14\\nbamboo_custom_3309569_p4_port=p4-open-prx-cwm:1666\\nbamboo_agentId=196609\\nbamboo_planName=sonar-plugin](https://atlassian-test.hq.k.grp/bamboo/browse/SON-SON-JOB1-14\nbamboo_custom_3309569_p4_port=p4-open-prx-cwm:1666\nbamboo_agentId=196609\nbamboo_planName=sonar-plugin) - sonar-plugin\\nbamboo_planRepository_1_depot=//bamboo_beij_BEIJING_INT_NMPC_SDK_ANDROID_NGEN/...\\nbamboo_shortPlanKey=SON\\nbamboo_custom_3309569_p4_username=bamboo_beij\\nbamboo_shortJobKey=JOB1\\nbamboo_custom_3309569_p4_revision_number=934034\\nbamboo_planRepository_revision=934034\\nbamboo_custom_p4_client=bamboo_beij_BEIJING_INT_NMPC_SDK_ANDROID_NGEN\\nbamboo_repository_previous_revision_number=934032\\nbamboo_buildTimeStamp=2018-01-23T17:03:11.590+01:00\\nbamboo_capability_system_builder_command_npm=/usr/local/bin/npm\\nbamboo_planRepository_previousRevision=934032\\nbamboo_buildResultKey=SON-SON-JOB1-14\\nbamboo_buildPlanName=sonar-plugin - sonar-plugin - Default Job\\nbamboo_planRepository_1_revision=934034\\nbamboo_repository_name=Android SDK 4 Source\\nJAVA_HOME=/usr/java/jdk1.8.0_131\\nbamboo_custom_p4_username=bamboo_beij\\nbamboo_buildFailed=false\\nbamboo_planRepository_1_client=bamboo_beij_BEIJING_INT_NMPC_SDK_ANDROID_NGEN\\nbamboo_capability_system_builder_command_grunt=/usr/local/bin/grunt\\nbamboo_capability_system_builder_command_Bash=/bin/bash\\nbamboo_repository_3309569_previous_revision_number=934032\\nbamboo_agentWorkingDirectory=/data/bamboo/data/xml-data/build-dir\\nbamboo_planRepository_1_previousRevision=934032\\nbamboo_custom_p4_revision_number=934034\\nbamboo_planRepository_1_type=p4\\nbamboo_capability_system_jdk_JDK_1_8_0_152=/usr/java/jdk1.8.0_152\\nbamboo_planRepository_depot=//bamboo_beij_BEIJING_INT_NMPC_SDK_ANDROID_NGEN/...\\nbamboo_capability_system_builder_sos_sonar_scanner_3_0_3=/opt/sonar-scanner-3.0.3\\nbamboo_capability_system_builder_command_gradle_4_4_1=/opt/gradle-4.4.1/bin/gradle\\nbamboo_custom_p4_port=p4-open-prx-cwm:1666\\nbamboo_capability_system_jdk_JDK=/usr/java/jdk1.8.0_131\\nbamboo_plan_storageTag=plan-3145729\\nbamboo_planRepository_type=p4\\nbamboo_planRepository_1_username=bamboo_beij\\nbamboo_working_directory=/data/bamboo/data/xml-data/build-dir/SON-SON-JOB1\\nbamboo_planKey=SON-SON\\nbamboo_planRepository_username=bamboo_beij\\nbamboo_custom_3309569_p4_client=bamboo_beij_BEIJING_INT_NMPC_SDK_ANDROID_NGEN\\nbamboo_capability_system_jdk_JDK_1_8=/usr/java/jdk1.8.0_131\\nPATH=/usr/java/jdk1.8.0_131/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin\\n  
simple 23-Jan-2018 17:03:15 Failing task since return code of \[/opt/sonar-scanner-3.0.3/bin/sonar-scanner -Dsonar.host.url=<http://uex-sonarqube.hq.k.grp:9000> -Dsonar.login=\*\*\*\*\*\* -Dsonar.password=\*\*\*\*\*\* was -1 while expected 0  
simple 23-Jan-2018 17:03:15 SONAR4BAMBOO: was not able to find a SonarQube result URL

Even though I have installed sonar scanner at location /opt/sonar-scanner-3.0.3/bin/sonar-scanner

Bamboo version:6.1.6  
Sonar plugin for bamboo version: 1.7.2  
Sonar scanner version: 3.0.3  
Sonarqube version: 6.1

Please any help is appreciated.


Answers:
author: Dayanand
body: Hi,

I am not using remote agent sonar scanner installed on the Bamboo server itself.

Also as I said manually on machine i can able to use sonar scanner but when i do same from the bamboo plan it is throwing below error:

Unable to find executable at /opt/sonar-scanner-3.0.3/bin/sonar-scanner.

Even though i have installed /opt/sonar-scanner-3.0.3.

Some more information:

A directory listing including permissions of the location where you've installed Sonar: Yes.  
What user Bamboo is running as bamboo user.

<br />

Does the Bamboo user have permissions to see and/or execute the Sonar Scanner executable: yes (as shown below)

<br />

bash-4.4$ whoami  
bamboo  
bash-4.4$ /opt/sonar-scanner-3.0.3/bin/sonar-scanner --version  
INFO: Scanner configuration file: /opt/sonar-scanner-3.0.3/conf/sonar-scanner.properties  
INFO: Project root configuration file: NONE  
INFO: SonarQube Scanner 3.0.3.778  
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)  
INFO: Linux 3.10.0-514.26.2.el7.x86_64 amd64

Is the build being ran by a remote agent, local agent, or the Bamboo server instance: On the bamboo server itself.

If on a remote agent, is Sonar installed on the remote agent, or only the server: installed sonar scanner on bamboo server itself under /opt/sonar-scanner-3.0.3

If a remote agent, is the Sonar capability configured for the agent? not applicable since we are testing on the bamboo server itself.

Any help on this is appreciated.


author: atltools
body: sonar-scanner executable is working when i run on the machine as bamboo user:

bash-4.4$ /opt/sonar-scanner-3.0.3/bin/sonar-scanner --version  
INFO: Scanner configuration file: /opt/sonar-scanner-3.0.3/conf/sonar-scanner.properties  
INFO: Project root configuration file: NONE  
INFO: SonarQube Scanner 3.0.3.778  
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)  
INFO: Linux 3.10.0-514.26.2.el7.x86_64 amd64  
bash-4.4$

comments: author: Michael R?egg _Mibex Software_
body: Are you executing your Sonar analysis on a remote agent? If yes, could you please try to add

```
system.builder.sor.Sor=/opt/sonar-scanner-3.0.3
```

to

```
bamboo-agent-home/bin/bamboo-capabilities.properties?
```

?


author: atltools
body: HI Michael,

I am not using remote agent sonar scanner installed on the Bamboo server itself.

Also as I said manually on machine i can able to use sonar scanner but when i do same from the bamboo plan it is throwing below error:

Unable to find executable at /opt/sonar-scanner-3.0.3/bin/sonar-scanner.

Even though i have installed /opt/sonar-scanner-3.0.3.

Some more information:

A directory listing including permissions of the location where you've installed Sonar: Yes.  
What user Bamboo is running as: bamboo user.

<br />

Does the Bamboo user have permissions to see and/or execute the Sonar Scanner executable: yes (as shown below)

<br />

bash-4.4$ whoami  
bamboo  
bash-4.4$ /opt/sonar-scanner-3.0.3/bin/sonar-scanner --version  
INFO: Scanner configuration file: /opt/sonar-scanner-3.0.3/conf/sonar-scanner.properties  
INFO: Project root configuration file: NONE  
INFO: SonarQube Scanner 3.0.3.778  
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)  
INFO: Linux 3.10.0-514.26.2.el7.x86_64 amd64

Is the build being ran by a remote agent, local agent, or the Bamboo server instance: On the bamboo server itself.

If on a remote agent, is Sonar installed on the remote agent, or only the server: installed sonar scanner on bamboo server itself under /opt/sonar-scanner-3.0.3

If a remote agent, is the Sonar capability configured for the agent? not applicable since we are testing on the bamboo server itself.

Any help on this is appreciated.


author: atltools
body: Yes, I tried using home path also but still same error.

error 23-Jan-2018 17:03:15 Unable to find executable at /opt/sonar-scanner-3.0.3/bin/sonar-scanner. Will try to run it anyway.

Please help me i am blocked with this issue.


author: Michael R?egg _Mibex Software_
body: Hi,

Have you already tried to just use the home directory "/opt/sonar-scanner-3.0.3" for the SonarScanner executable instead of the full path to it?

Best regards,  
Michael from Mibex Software