The sonar-scanner building fails on Travis CI for Node.js application

Hello everyone. :slight_smile:

I’m trying to get Sonar Qube working in Sonar Cloud via Travis CI for a Node.js application, and here is the relevant information. (Please do let me know if I’m not providing enough information, even if you don’t know how to help.):

.travis.yml file:

language: node_js
node_js:
- 'lts/*'
- 'node'

dist: trusty

addons:
  sonarcloud:
    organization: "sonarcloud" # the key of the org you chose at step #3
    token:
      secure: "*********" # encrypted value of your token
script:
  # other script steps might be done before running the actual analysis
  - sonar-scanner -X

sonar-project.properties file:

sonar.projectKey=denizakcal_SOEN341_Project
sonar.organization=sonarcloud

# this is the name and version displayed in the SonarCloud UI.
sonar.projectName=SOEN341_Project
sonar.projectVersion=1.0
 
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set. 
sonar.sources=.
 
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

Raw job log from Travis CI:
http://dpaste.com/02YWX9H#wrap

It seems that it’s not connecting to the server and that I should set sonar.login and sonar.password values, I’m guessing in sonar-project.properties, but I don’t know which values to put for those (since I used my GitHub account to log into Sonar Cloud), and I’m not sure there is more that I’d need to do after setting those values for the sonar-scanner utility to work.

If someone could help me figure out how to get this all to work, I would greatly appreciate it!

try to generate security token and put it as sonar.login (see https://docs.sonarqube.org/latest/user-guide/user-token/)

2 Likes

Thanks for your response. :slight_smile:

I did what I think was your suggestion, but it’s still not working. :frowning:

The relevant information can be found below.:
.travis.yml file:

language: node_js

node_js:
- 'lts/*'
- 'node'

dist: trusty

addons:
    sonarcloud:
        organization: "sonar-key-for-koady"
        token:
            secure: "cJsLsl9XIHY959vqoZFDdAnaIqssK2jAt2qOcniar/v/hFEyHXh1uXLkAZ2XQ0ienu7l5KG8ckS5+dkLFWrhAuq2vakig6P3dEDStJwgTPVeuilZC2oImyvuniqQFBQDSfrR7nXtm9IdhJV7yd9zVvmRVSqI3pHtTtyeAvqfk7DkYwkexgG2B/bEzoJ58z68qyd0UUeIm2ca/ZS5mI/qlHnVZLwoJ8vIf7SaWFxqya66BoEo4PpHaSz9unWbJhUbEPqEYZu7nn8VsOS8eSjLRJaGK3wRqNSB+XAuQHBPNDW+bNfhgkXbMWZpNAsZe1zQgCMZtScsiPYzbPOcxQKosNU3/KLINWpk8sF9I8/vshm0u/WXdhIR/7PmmrtlmpBB2aAB62rSVzs0ZC4vEX8dBd5wsnEt++UVXeVtm43T2RqLcGKk1SdOqZE6qDmKHEBnAxbNSAK2ZTKcx/6wgpoFflQO/SyHCHSELvg/jKXMp55TuRFtfxu8dHxVyY4FhYy33BqOEA9yMwoh/Vygq+BrmnbnEZenpFDOHck3w1BASfzROPNGB23mcQKQV7iVapzIDOZTWdi12yoyYQ6bb+Zqut/HUux47Ye9cgZA7G6njlZdlGkkwXKdsfIl7FUvjOTNFMylfYKH03z86HPXM+gwOu//bnmhnWL+KNujsza/ElA="

script:
- sonar-scanner -X

sonar-project.properties file (One attempt):

sonar.projectKey=denizakcal_SOEN341_Project
sonar.organization=sonar-key-for-koady

# this is the name and version displayed in the SonarCloud UI.
sonar.projectName=SOEN341_Project
sonar.projectVersion=1.0
 
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set. 
sonar.sources=./src
 
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

sonar.login="1bbb3d5ea93bc47ab061e8611aacb9c3cfcf8cd8" # From part, "New token "sonarcloudtokennameforlogin" has been created. Make sure you copy it now, you won't be able to see it again!"

sonar-project.properties file (Another attempt):

sonar.projectKey=denizakcal_SOEN341_Project
sonar.organization=sonar-key-for-koady

# this is the name and version displayed in the SonarCloud UI.
sonar.projectName=SOEN341_Project
sonar.projectVersion=1.0
 
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set. 
sonar.sources=./src
 
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

sonar.login="cJsLsl9XIHY959vqoZFDdAnaIqssK2jAt2qOcniar/v/hFEyHXh1uXLkAZ2XQ0ienu7l5KG8ckS5+dkLFWrhAuq2vakig6P3dEDStJwgTPVeuilZC2oImyvuniqQFBQDSfrR7nXtm9IdhJV7yd9zVvmRVSqI3pHtTtyeAvqfk7DkYwkexgG2B/bEzoJ58z68qyd0UUeIm2ca/ZS5mI/qlHnVZLwoJ8vIf7SaWFxqya66BoEo4PpHaSz9unWbJhUbEPqEYZu7nn8VsOS8eSjLRJaGK3wRqNSB+XAuQHBPNDW+bNfhgkXbMWZpNAsZe1zQgCMZtScsiPYzbPOcxQKosNU3/KLINWpk8sF9I8/vshm0u/WXdhIR/7PmmrtlmpBB2aAB62rSVzs0ZC4vEX8dBd5wsnEt++UVXeVtm43T2RqLcGKk1SdOqZE6qDmKHEBnAxbNSAK2ZTKcx/6wgpoFflQO/SyHCHSELvg/jKXMp55TuRFtfxu8dHxVyY4FhYy33BqOEA9yMwoh/Vygq+BrmnbnEZenpFDOHck3w1BASfzROPNGB23mcQKQV7iVapzIDOZTWdi12yoyYQ6bb+Zqut/HUux47Ye9cgZA7G6njlZdlGkkwXKdsfIl7FUvjOTNFMylfYKH03z86HPXM+gwOu//bnmhnWL+KNujsza/ElA="

But, I keep getting the following message (from the sonar-scanner -X command (which is run by Travis CI)).:
Caused by: Not authorized. Please check the properties sonar.login and sonar.password.
( Full details: http://dpaste.com/1578BGD#wrap )

Did I misunderstand you? Do you have any other suggestions?

P.S.
Unless I’m mistaken (since I’ve done very many attempts), I’ve tried the values with and without the double quotes.

Actually, I don’t know what I was doing wrong before, but the website’s instructions along with what you said worked this time! Thanks!