Error in Travis Log: "You're not authorized to run analysis. Please contact the project administrator" and Travis CI org not sending Jacoco reports to SonarCloud

Hi @TomVanBraband,

I resolved code coverage problem! and now i have 100%

However i have problem with token :slight_smile:

Below Steps i have followed :

Step 1:

In pom i have below configuration for sonar.

image

It is worked perfectly : below is the result:

For Step 1 , Token i have taken from below location :

image

Step 1 worked perfectly!!!

Step 2:

with same token i generated secure token using following way.

Step 3:

i made change in Pom file:

I put just only below config of sonar in pom
image
Rest all sonar related configuration removed

Step 4:

Configured .travis.yml with below configuration

matrix:
include:
# always build this environment
- os: linux
dist: xenial
jdk: openjdk8
env: ADDITIONAL_MAVEN_ARGS="-Pjacoco coveralls:report"
# only on PR
- os: linux
dist: xenial
jdk: openjdk8
if: type IN (pull_request)
# only on PR or after merging a PR
- os: osx
osx_image: xcode10.1
if: type IN (pull_request) OR commit_message =~ /^Merge pull request/

addons:
sonarcloud:
organization: “josephthachilgeorge”
token:
secure: “XXXXXXXXXXXXXX” # encrypted value of your token

install: true
cache:
directories:
- $HOME/.m2
script:

  • mvn -f spring-project/pom.xml clean verify $ADDITIONAL_MAVEN_ARGS
  • mvn -f spring-project/pom.xml clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar -Dsonar.projectKey=JosephThachilGeorge_ATTSD

Result in Travis build:

Kindly let me know where i have done mistake? thanks for your help

Hi @TomVanBraband

Thanks a lot for your reply!

Below you can see my java version

Then i tried below steps

Travis result was same as shown below :

Then i made below change in .travis.yml

Then i had same result, with same error

Kindly let me know is there anything missing

Hello @JosephThachilGeorge,

It seems that we now have established that the token works when you supply it as a plain text value, however when you supply it to TravisCI with an encrypted value it fails.

This makes me sure that something went wrong during the encryption of the token.

Could you try to login before generating the token? You can do this by executing travis login and it will then ask for your credentials?

Do you confirm that you are using travis-ci.org instead of travis-ci.com? If that is not the case you have to login before generation the token by executing travis login --pro and you also have to add the --pro flag when generating the token: travis encrypt --pro SOMEVAR="secretvalue". See the documentation here.

Hi @TomVanBraband,
I am using https://travis-ci.org/
below you can see the steps that i have done

Then encrypted key i copied and pasted in travis.yml

same error has come

Hi @JosephThachilGeorge,

The SOMEVAR= in
travis encrypt SOMEVAR="secretvalue"
was just an example they used in the travis docs. In your situation you would have to use
travis encrypt VALUE_OF_TOKEN without any SOMEVAR= in the command.

Could you try that?

Hi @TomVanBraband,
I tried that as you can see below


i found same error

Hi @TomVanBraband,
Please note that above step as you suggested i run without any SOMEVAR= in the command. thanks a lot.

Please try without double-quotes around the token. (I vaguely remember something about the behavior of double-quotes in DOS shell, but I’m not sure. I think this is worth a shot.)

Hi @janos,
Thanks a lot for your reply!!!
I tried as per your suggestion without double quote

.travis.yml configured as below

matrix:
include:
# always build this environment
- os: linux
matrix:
include:
# always build this environment
- os: linux
dist: xenial
jdk: openjdk8
env: ADDITIONAL_MAVEN_ARGS="-Pjacoco coveralls:report"
# only on PR
- os: linux
dist: xenial
jdk: openjdk8
if: type IN (pull_request)
# only on PR or after merging a PR
- os: osx
osx_image: xcode10.1
if: type IN (pull_request) OR commit_message =~ /^Merge pull request/
addons:
sonarcloud:
organization: “josephthachilgeorge”
token:
secure: “key”
install: true
cache:
directories:
- $HOME/.m2

script:

  • mvn -f spring-project/pom.xml clean verify $ADDITIONAL_MAVEN_ARGS
  • mvn -f spring-project/pom.xml clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar -Dsonar.projectKey=JosephThachilGeorge_ATTSD_Project

Then Below result i got

Build is OK, however my code coverage for Sonar and coveralls become Zero

It was 100% if i configure token in pom xml

I know i am close to the solution , but something is missing

Hi @janos,

Thanks a lot for your help. Do i need to do any further steps ?

Hello @JosephThachilGeorge,

You need to point the scanner to the coverage report files that are generated by jacoco.

From your initial post I can see that you have set the property sonar.jacoco.reportPaths in your pom.xml, however this property is deprecated as you can see here. Could you try changing the property key sonar.jacoco.reportPaths to sonar.coverage.jacoco.xmlReportPaths, the value of this property should be the same as what you have set in jacoco.report.path.

Please let me know if this resolves your issue.

Hi @TomVanBraband,

Thanks a lot for your reply!
Sorry i did not understand your comments ,could you please explain little more details

my pom file is given below , what change i have to make in pom file ?

Hi @TomVanBraband
I have made below change in pom

Result was same , the code coverage is 0% in sonar

Hello @JosephThachilGeorge,

Could you please post the logs of the scanner?

here is my pom file

[INFO]

1047[INFO] Results:

1048[INFO]

1049[INFO] Tests run: 39, Failures: 0, Errors: 0, Skipped: 0

1050[INFO]

1051[INFO]

1052[INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) @ spring-project ---

1053[INFO] Building jar: /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/spring-project-0.0.1-SNAPSHOT.jar

1054[INFO]

1055[INFO] --- spring-boot-maven-plugin:2.1.4.RELEASE:repackage (repackage) @ spring-project ---

1056[INFO] Replacing main artifact with repackaged archive

1057[INFO]

1058[INFO] --- spring-boot-maven-plugin:2.1.4.RELEASE:repackage (default) @ spring-project ---

1059[INFO] Replacing main artifact with repackaged archive

1060[INFO]

1061[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ spring-project ---

1062[INFO] Installing /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/spring-project-0.0.1-SNAPSHOT.jar to /home/travis/.m2/repository/attsd/exam/project/spring-project/0.0.1-SNAPSHOT/spring-project-0.0.1-SNAPSHOT.jar

1063[INFO] Installing /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/pom.xml to /home/travis/.m2/repository/attsd/exam/project/spring-project/0.0.1-SNAPSHOT/spring-project-0.0.1-SNAPSHOT.pom

1064[INFO]

1065[INFO] -----------------< attsd.exam.project:spring-project >------------------

1066[INFO] Building spring-project 0.0.1-SNAPSHOT

1067[INFO] --------------------------------[ jar ]---------------------------------

1068[WARNING] The POM for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available

1069[WARNING] Failed to retrieve plugin descriptor for org.eclipse.m2e:lifecycle-mapping:1.0.0: Plugin org.eclipse.m2e:lifecycle-mapping:1.0.0 or one of its dependencies could not be resolved: Failure to find org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 in https://maven-central.storage-download.googleapis.com/maven2/ was cached in the local repository, resolution will not be reattempted until the update interval of google-maven-central has elapsed or updates are forced

1070[INFO]

1071[INFO] --- sonar-maven-plugin:3.7.0.1746:sonar (default-cli) @ spring-project ---

1072[INFO] User cache: /home/travis/.sonar/cache

1073[INFO] SonarQube version: 8.0.0

1074[INFO] Default locale: "en_US", source code encoding: "UTF-8"

1075[INFO] Load global settings

1076[INFO] Load global settings (done) | time=695ms

1077[INFO] Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu

1078[INFO] User cache: /home/travis/.sonar/cache

1079[INFO] Load/download plugins

1080[INFO] Load plugins index

1081[INFO] Load plugins index (done) | time=161ms

1082[INFO] Load/download plugins (done) | time=20715ms

1083[INFO] Loaded core extensions: developer-scanner

1084[WARNING] The version of Java (1.8.0_191) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.

1085[INFO] Process project properties

1086[INFO] Execute project builders

1087[INFO] Execute project builders (done) | time=13ms

1088[INFO] Project key: JosephThachilGeorge_ATTSD_Project

1089[INFO] Base dir: /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project

1090[INFO] Working dir: /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/sonar

1091[INFO] Load project settings for component key: 'JosephThachilGeorge_ATTSD_Project'

1092[INFO] Load project settings for component key: 'JosephThachilGeorge_ATTSD_Project' (done) | time=282ms

1093[INFO] Found an active CI vendor: 'TravisCI'

1094[INFO] Load project branches

1095[INFO] Load project branches (done) | time=127ms

1096[INFO] Check ALM binding of project 'JosephThachilGeorge_ATTSD_Project'

1097[INFO] Detected project binding: BOUND

1098[INFO] Check ALM binding of project 'JosephThachilGeorge_ATTSD_Project' (done) | time=124ms

1099[INFO] Load project pull requests

1100[INFO] Load project pull requests (done) | time=111ms

1101[INFO] Load branch configuration

1102[INFO] Load branch configuration (done) | time=3ms

1103[INFO] Load quality profiles

1104[INFO] Load quality profiles (done) | time=197ms

1105[INFO] Load active rules

1106[INFO] Load active rules (done) | time=3568ms

1107[INFO] Organization key: josephthachilgeorge

1108[INFO] Indexing files...

1109[INFO] Project configuration:

1110[INFO] Excluded sources for coverage: **/model/*.*, **/SpringProjectMainApplication.*, **/config/**

1111[INFO] Load project repositories

1112[INFO] Load project repositories (done) | time=127ms

1113[INFO] 38 files indexed

1114[INFO] 0 files ignored because of scm ignore settings

1115[INFO] Quality profile for css: Sonar way

1116[INFO] Quality profile for java: Sonar way

1117[INFO] Quality profile for web: Sonar way

1118[INFO] Quality profile for xml: Sonar way

1119[INFO] ------------- Run sensors on module spring-project

1120[INFO] Load metrics repository

1121[INFO] Load metrics repository (done) | time=115ms

1122[INFO] Sensor JavaSquidSensor [java]

1123[INFO] Configured Java source version (sonar.java.source): 8

1124[INFO] JavaClasspath initialization

1125[INFO] JavaClasspath initialization (done) | time=16ms

1126[INFO] JavaTestClasspath initialization

1127[INFO] JavaTestClasspath initialization (done) | time=4ms

1128[INFO] Java Main Files AST scan

1129[INFO] 13 source files to be analyzed

1130[INFO] 13/13 source files have been analyzed

1131[INFO] Java Main Files AST scan (done) | time=3742ms

1132[INFO] Java Test Files AST scan

1133[INFO] 15 source files to be analyzed

1134[INFO] Java Test Files AST scan (done) | time=1993ms

1135[INFO] Java Generated Files AST scan

1136[INFO] 0 source files to be analyzed

1137[INFO] 15/15 source files have been analyzed

1138[INFO] 0/0 source files have been analyzed

1139[INFO] Java Generated Files AST scan (done) | time=7ms

1140[INFO] Sensor JavaSquidSensor [java] (done) | time=6008ms

1141[INFO] Sensor SonarCSS Metrics [cssfamily]

1142[INFO] Sensor SonarCSS Metrics [cssfamily] (done) | time=24ms

1143[INFO] Sensor SonarCSS Rules [cssfamily]

1144[INFO] 7 source files to be analyzed

1145[INFO] 7/7 source files have been analyzed

1146[INFO] Sensor SonarCSS Rules [cssfamily] (done) | time=1041ms

1147[INFO] Sensor SurefireSensor [java]

1148[INFO] parsing [/home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/surefire-reports]

1149[INFO] Sensor SurefireSensor [java] (done) | time=53ms

1150[INFO] Sensor JavaXmlSensor [java]

1151[INFO] 1 source files to be analyzed

1152[INFO] Sensor JavaXmlSensor [java] (done) | time=253ms

1153[INFO] 1/1 source files have been analyzed

1154[INFO] Sensor HTML [web]

1155[INFO] Sensor HTML [web] (done) | time=83ms

1156[INFO] Sensor XML Sensor [xml]

1157[INFO] 1 source files to be analyzed

1158[INFO] 1/1 source files have been analyzed

1159[INFO] Sensor XML Sensor [xml] (done) | time=212ms

1160[INFO] Sensor JaCoCo XML Report Importer [jacoco]

1161[WARNING] No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths='/home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/site/jacoco.xml'. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml

1162[INFO] No report imported, no coverage information will be imported by JaCoCo XML Report Importer

1163[INFO] Sensor JaCoCo XML Report Importer [jacoco] (done) | time=21ms

1164[INFO] Sensor ThymeLeaf template sensor [securityjavafrontend]

1165[INFO] Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=324ms

1166[INFO] Sensor JavaSecuritySensor [security]

1167[INFO] Reading type hierarchy from: /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/sonar/ucfg2/java

1168[INFO] Read 68 type definitions

1169[INFO] Reading UCFGs from: /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/sonar/ucfg2/java

1170[INFO] 14:02:46.455 Building Type propagation graph

1171[INFO] 14:02:46.471 Running Tarjan on 226 nodes

1172[INFO] 14:02:46.476 Tarjan found 226 components

1173[INFO] 14:02:46.481 Variable type analysis: done

1174[INFO] 14:02:46.486 Building Type propagation graph

1175[INFO] 14:02:46.494 Running Tarjan on 226 nodes

1176[INFO] 14:02:46.496 Tarjan found 226 components

1177[INFO] 14:02:46.498 Variable type analysis: done

1178[INFO] Analyzing 71 ucfgs to detect vulnerabilities.

1179[INFO] All rules entrypoints : 0 Retained UCFGs : 0

1180[INFO] rule: S5131, entrypoints: 0

1181[INFO] rule: S5131 done

1182[INFO] rule: S3649, entrypoints: 0

1183[INFO] rule: S3649 done

1184[INFO] rule: S2076, entrypoints: 0

1185[INFO] rule: S2076 done

1186[INFO] rule: S2091, entrypoints: 0

1187[INFO] rule: S2091 done

1188[INFO] rule: S2078, entrypoints: 0

1189[INFO] rule: S2078 done

1190[INFO] rule: S2631, entrypoints: 0

1191[INFO] rule: S2631 done

1192[INFO] rule: S5135, entrypoints: 0

1193[INFO] rule: S5135 done

1194[INFO] rule: S2083, entrypoints: 0

1195[INFO] rule: S2083 done

1196[INFO] rule: S5167, entrypoints: 0

1197[INFO] rule: S5167 done

1198[INFO] rule: S5144, entrypoints: 0

1199[INFO] rule: S5144 done

1200[INFO] rule: S5145, entrypoints: 0

1201[INFO] rule: S5145 done

1202[INFO] rule: S5146, entrypoints: 0

1203[INFO] rule: S5146 done

1204[INFO] rule: S5334, entrypoints: 0

1205[INFO] rule: S5334 done

1206[INFO] Sensor JavaSecuritySensor [security] (done) | time=461ms

1207[INFO] Sensor CSharpSecuritySensor [security]

1208[INFO] Reading type hierarchy from: /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/ucfg_cs2

1209[INFO] Read 0 type definitions

1210[INFO] Reading UCFGs from: /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/ucfg_cs2

1211[INFO] No UCFGs have been included for analysis.

1212[INFO] Sensor CSharpSecuritySensor [security] (done) | time=5ms

1213[INFO] Sensor PhpSecuritySensor [security]

1214[INFO] Reading type hierarchy from: /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/sonar/ucfg2/php

1215[INFO] Read 0 type definitions

1216[INFO] Reading UCFGs from: /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/sonar/ucfg2/php

1217[INFO] No UCFGs have been included for analysis.

1218[INFO] Sensor PhpSecuritySensor [security] (done) | time=8ms

1219[INFO] Sensor PythonSecuritySensor [security]

1220[INFO] Reading type hierarchy from: /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/sonar/ucfg2/python

1221[INFO] Read 0 type definitions

1222[INFO] Reading UCFGs from: /home/travis/build/JosephThachilGeorge/ATTSD_Project/spring-project/target/sonar/ucfg2/python

1223[INFO] No UCFGs have been included for analysis.

1224[INFO] Sensor PythonSecuritySensor [security] (done) | time=1ms

1225[INFO] ------------- Run sensors on project

1226[INFO] Sensor Zero Coverage Sensor

1227[INFO] Sensor Zero Coverage Sensor (done) | time=12ms

1228[INFO] Sensor Java CPD Block Indexer

1229[INFO] Sensor Java CPD Block Indexer (done) | time=33ms

1230[INFO] SCM Publisher SCM provider for this project is: git

1231[INFO] SCM Publisher 1 source file to be analyzed

1232[INFO] SCM Publisher 1/1 source file have been analyzed (done) | time=114ms

1233[INFO] CPD Executor 3 files had no CPD blocks

1234[INFO] CPD Executor Calculating CPD for 15 files

1235[INFO] CPD Executor CPD calculation finished (done) | time=22ms

1236[INFO] Analysis report generated in 115ms, dir size=323 KB

1237[INFO] Analysis report compressed in 69ms, zip size=118 KB

1238[INFO] Analysis report uploaded in 588ms

1239[INFO] ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=JosephThachilGeorge_ATTSD_Project

1240[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report

1241[INFO] More about the report processing at https://sonarcloud.io/api/ce/task?id=AXNNopW4EAlPZLkUY50p

1242[INFO] Analysis total time: 19.522 s

1243[INFO] ------------------------------------------------------------------------

1244[INFO] BUILD SUCCESS

1245[INFO] ------------------------------------------------------------------------

1246[INFO] Total time: 01:13 min

1247[INFO] Finished at: 2020-07-14T14:02:47Z

1248[INFO] ------------------------------------------------------------------------

1249The command "mvn -f spring-project/pom.xml clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar -Dsonar.projectKey=JosephThachilGeorge_ATTSD_Project" exited with 0.

cache.2

1250store build cache

1259

1260

1261Done. Your build exited with 0.

Hi @TomVanBraband

Do you need full log ?

Notice this line in the output of the scanner:

It seems the report file was not generated where you expected it. And I can see why: the org.jacoco:jacoco-maven-plugin:prepare-agent goal starts JaCoCo agent to collect coverage data, but the step to actually write that to the report file is missing. Add org.jacoco:jacoco-maven-plugin:report after the install goal. This should produce the file, and the warning about “No coverage report…” should disappear.

Let us know how this goes!

Also, I recommend this guide for importing JaCoCo reports.

Hi @janos,

Excellent suggestion you gave ! i tried and it worked

Below script i wrote in .travis. yml

script:

  • mvn -f spring-project/pom.xml clean verify -Pjacoco coveralls:report
  • mvn -f spring-project/pom.xml clean org.jacoco:jacoco-maven-plugin:prepare-agent install org.jacoco:jacoco-maven-plugin:report
  • mvn -f spring-project/pom.xml sonar:sonar -Dsonar.projectKey=JosephThachilGeorge_ATTSD_Project
  • mvn -f spring-project/pom.xml verify -Pfailsafe

My out put was :

However the same Warning is there in the build

and below build you could notice that , even though build is OK. It is not showing in color. Normally build show in Blue color or green color

Let me know do i need to do any further steps ?

Note that mvn clean deletes all previous build products. So the files that are generated by verify -Pjacoco coveralls:report of the first command, are all deleted by the clean in the second command.

Although your build and analysis seem to be working, it’s important to understand warnings when possible. Here, the warning says it could not find jacoco.xml at the specified location. On the INFO line that follows you can see that the analyzer tried to look for reports at the default locations, and it found and imported something.

Without digging any deep at all, it look to me that the jacoco.* settings were not effective, and JaCoCo created the reports at the default locations. And if you drop all the jacoco.* and sonar.coverage.* properties, everything should work find and without warnings, because JaCoCo will create the reports at default locations, and the SonarCloud scanner will find them there.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.