Basic environmental information:
- Enterprise Edition Version 8.9.10 (build 61524)
- SonarScanner CLI 6.2.1.4610
- Java 17.0.12 Eclipse Adoptium (64-bit)
- Linux 5.10.219-208.866.amzn2.x86_64 amd64
When I use the following command .sonar-scanner/bin/sonar-scanner -Dsonar.branch.name=feature/test-ci -Dsonar.projectKey=web-activity
to scan the front-end code project, I get an error.
java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: public/images/email-template/????????????????????????????????????,????????????????????????????????????
In public/images/email-template/ there is a file name in Chinese,is this error caused by coding problems?
I tried the following three methods based on the usage documentation and other responses from the community, but I still get the same error.
- use
-Dsonar.sorceEncoding=UTF-8
- Add the LANG parameter,
LANG=en_US.UTF-8;.sonar-scanner/bin/sonar-scanner -Dsonar.branch.name=feature/test-ci -Dsonar.sourceEncoding=UTF-8 -Dsonar.projectKey=web-activity
LANG=C.UTF-8;LC_ALL=C.UTF-8;.sonar-scanner/bin/sonar-scanner -Dsonar.branch.name=feature/test-ci -Dsonar.sourceEncoding=UTF-8 -Dsonar.projectKey=web-activity
The error log is as follows
2024-12-03 14:38:26 ------------------------begin sonar-------------------------------
2024-12-03 14:38:26 [Pipeline] echo
2024-12-03 14:38:26 ------------------------begin full sonar-------------------------------
2024-12-03 14:38:26 [Pipeline] echo
2024-12-03 14:38:26 sonar 全量扫描执行命令: sonar-scanner -Dsonar.branch.name=feature/test-ci
2024-12-03 14:38:26 [Pipeline] sh
2024-12-03 14:38:26 > git rev-parse --verify HEAD # timeout=10
2024-12-03 14:38:26 Resetting working tree
2024-12-03 14:38:26 > git reset --hard # timeout=10
2024-12-03 14:38:26 > git clean -fdx # timeout=10
2024-12-03 14:38:28 + [ ! -d .sonar-scanner ]
2024-12-03 14:38:28 + mkdir -p .sonar-scanner
2024-12-03 14:38:28 + wget https://xxx.s3.ap-northeast-1.amazonaws.com/sonar-scanner-cli-6.2.1.4610-linux-x64.tar.gz -O .sonar-scanner/
2024-12-03 14:38:28 Saving to: '.sonar-scanner/sonar-scanner.tar.gz'
2024-12-03 14:38:30 + chmod +x .sonar-scanner/bin/sonar-scanner
2024-12-03 14:38:30 [Pipeline] sh
2024-12-03 14:38:31 + sh .sonar-scanner/bin/sonar-scanner --version
2024-12-03 14:38:31 14:38:30.700 INFO Scanner configuration file: /home/jenkins/agent/workspace/web-activity@2/.sonar-scanner/conf/sonar-scanner.properties
2024-12-03 14:38:31 14:38:30.703 INFO Project root configuration file: NONE
2024-12-03 14:38:31 14:38:30.715 INFO SonarScanner CLI 6.2.1.4610
2024-12-03 14:38:31 14:38:30.716 INFO Java 17.0.12 Eclipse Adoptium (64-bit)
2024-12-03 14:38:31 14:38:30.717 INFO Linux 5.10.219-208.866.amzn2.x86_64 amd64
2024-12-03 14:38:31 [Pipeline] echo
2024-12-03 14:38:31 sonar new command: .sonar-scanner/bin/sonar-scanner -Dsonar.branch.name=feature/test-ci -Dsonar.projectKey=web-activity
2024-12-03 14:38:31 [Pipeline] withSonarQubeEnv
2024-12-03 14:38:31 Injecting SonarQube environment variables using the configuration: sonar-de
2024-12-03 14:38:32 [Pipeline] {
2024-12-03 14:38:32 [Pipeline] sh
2024-12-03 14:38:32 14:38:31.789 INFO Scanner configuration file: /home/jenkins/agent/workspace/web-activity@2/.sonar-scanner/conf/sonar-scanner.properties
2024-12-03 14:38:32 14:38:31.792 INFO Project root configuration file: NONE
2024-12-03 14:38:32 14:38:31.805 INFO SonarScanner CLI 6.2.1.4610
2024-12-03 14:38:32 14:38:31.806 INFO Java 17.0.12 Eclipse Adoptium (64-bit)
2024-12-03 14:38:32 14:38:31.807 INFO Linux 5.10.219-208.866.amzn2.x86_64 amd64
2024-12-03 14:38:32 14:38:31.938 INFO User cache: /root/.sonar/cache
2024-12-03 14:38:33 14:38:32.676 INFO Communicating with SonarQube Server 8.9.10.61524
2024-12-03 14:38:33 14:38:32.858 INFO Load global settings
2024-12-03 14:38:33 14:38:32.906 INFO Load global settings (done) | time=48ms
2024-12-03 14:38:33 14:38:32.908 INFO Server id: 86E1FA4D-AXjUW3t_GNH8x5zOp3VC
2024-12-03 14:38:33 14:38:32.910 INFO User cache: /root/.sonar/cache
2024-12-03 14:38:33 14:38:32.911 INFO Load/download plugins
2024-12-03 14:38:33 14:38:32.912 INFO Load plugins index
2024-12-03 14:38:33 14:38:32.944 INFO Load plugins index (done) | time=32ms
2024-12-03 14:38:35 14:38:35.378 INFO Load/download plugins (done) | time=2467ms
2024-12-03 14:38:36 14:38:35.944 INFO Loaded core extensions: developer-scanner
2024-12-03 14:38:36 14:38:36.159 INFO JavaScript/TypeScript frontend is enabled
2024-12-03 14:38:36 14:38:36.276 INFO Process project properties
2024-12-03 14:38:36 14:38:36.276 INFO Process project properties (done) | time=0ms
2024-12-03 14:38:36 14:38:36.276 INFO Execute project builders
2024-12-03 14:38:36 14:38:36.277 INFO Execute project builders (done) | time=1ms
2024-12-03 14:38:36 14:38:36.280 INFO Project key: web-activity
2024-12-03 14:38:36 14:38:36.280 INFO Base dir: /home/jenkins/agent/workspace/web-activity@2
2024-12-03 14:38:36 14:38:36.280 INFO Working dir: /home/jenkins/agent/workspace/web-activity@2/.scannerwork
2024-12-03 14:38:36 14:38:36.380 INFO Load project settings for component key: 'web-activity'
2024-12-03 14:38:36 14:38:36.402 INFO Load project branches
2024-12-03 14:38:36 14:38:36.413 INFO Load project branches (done) | time=11ms
2024-12-03 14:38:36 14:38:36.414 INFO Load project pull requests
2024-12-03 14:38:36 14:38:36.423 INFO Load project pull requests (done) | time=9ms
2024-12-03 14:38:36 14:38:36.423 INFO Load branch configuration
2024-12-03 14:38:36 14:38:36.424 INFO Found manual configuration of branch/PR analysis. Skipping automatic configuration.
2024-12-03 14:38:36 14:38:36.425 INFO Load branch configuration (done) | time=2ms
2024-12-03 14:38:36 14:38:36.448 INFO Auto-configuring with CI 'Jenkins'
2024-12-03 14:38:36 14:38:36.449 INFO Load quality profiles
2024-12-03 14:38:36 14:38:36.506 INFO Load quality profiles (done) | time=57ms
2024-12-03 14:38:36 14:38:36.508 INFO Auto-configuring with CI 'Jenkins'
2024-12-03 14:38:36 14:38:36.510 INFO Load active rules
2024-12-03 14:38:38 14:38:38.132 INFO Load active rules (done) | time=1623ms
2024-12-03 14:38:38 14:38:38.148 INFO Branch name: feature/test-ci
2024-12-03 14:38:38 14:38:38.168 WARN Property 'sonar.groovy.file.suffixes' is not declared as multi-values/property set but was read using 'getStringArray' method. The SonarQube plugin declaring this property should be updated.
2024-12-03 14:38:38 14:38:38.181 INFO Indexing files...
2024-12-03 14:38:38 14:38:38.182 INFO Project configuration:
2024-12-03 14:38:38 14:38:38.521 INFO EXECUTION FAILURE
2024-12-03 14:38:38 14:38:38.523 INFO Total time: 6.757s
2024-12-03 14:38:38 14:38:38.523 ERROR Error during SonarScanner CLI execution
2024-12-03 14:38:38 java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: public/images/email-template/????????????????????????????????????,????????????????????????????????????
2024-12-03 14:38:38 at java.base/sun.nio.fs.UnixPath.encode(Unknown Source)
2024-12-03 14:38:38 at java.base/sun.nio.fs.UnixPath.<init>(Unknown Source)
2024-12-03 14:38:38 at java.base/sun.nio.fs.UnixFileSystem.getPath(Unknown Source)
2024-12-03 14:38:38 at java.base/java.nio.file.Path.resolve(Unknown Source)
2024-12-03 14:38:38 at org.sonar.scm.git.IncludedFilesRepository.indexFiles(IncludedFilesRepository.java:65)
2024-12-03 14:38:38 at org.sonar.scm.git.IncludedFilesRepository.<init>(IncludedFilesRepository.java:40)
2024-12-03 14:38:38 at org.sonar.scm.git.GitIgnoreCommand.init(GitIgnoreCommand.java:37)
2024-12-03 14:38:38 at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.index(ProjectFileIndexer.java:104)
2024-12-03 14:38:38 at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:352)
2024-12-03 14:38:38 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
2024-12-03 14:38:38 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
2024-12-03 14:38:38 at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:150)
2024-12-03 14:38:38 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
2024-12-03 14:38:38 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
2024-12-03 14:38:38 at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
2024-12-03 14:38:38 at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
2024-12-03 14:38:38 at org.sonarsource.scanner.lib.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:41)
2024-12-03 14:38:38 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2024-12-03 14:38:38 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2024-12-03 14:38:38 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2024-12-03 14:38:38 at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2024-12-03 14:38:38 at org.sonarsource.scanner.lib.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:62)
2024-12-03 14:38:38 at jdk.proxy3/jdk.proxy3.$Proxy2.execute(Unknown Source)
2024-12-03 14:38:38 at org.sonarsource.scanner.lib.InProcessScannerEngineFacade.doAnalyze(InProcessScannerEngineFacade.java:39)
2024-12-03 14:38:38 at org.sonarsource.scanner.lib.ScannerEngineFacade.analyze(ScannerEngineFacade.java:61)
2024-12-03 14:38:38 at org.sonarsource.scanner.cli.Main.analyze(Main.java:77)
2024-12-03 14:38:38 at org.sonarsource.scanner.cli.Main.main(Main.java:63)
2024-12-03 14:38:38 14:38:38.526 ERROR
2024-12-03 14:38:38 14:38:38.526 ERROR Re-run SonarScanner CLI using the -X switch to enable full debug logging.
2024-12-03 14:38:38 [Pipeline] }
2024-12-03 14:38:38 WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeed?
2024-12-03 14:38:40 [Pipeline] // withSonarQubeEnv
2024-12-03 14:38:40 [Pipeline] echo
2024-12-03 14:38:40 执行sonar扫描错误: hudson.AbortException: script returned exit code 1
How to fix this?