GoogleCloudPlatform / GoogleCloudPlatform/cloud-builders-community
sonarqube scan Angular project - NODE is missing
- Dominant language
- Go
- Stars
- 1.3k
- Forks
- 848
- PR merge metrics
- No merged PRs in 30d
Description
## Affected builder image
gcr.io/$PROJECT_ID/sonar-scanner:latest
Here is my yaml file
```
steps:
- id: 'SonarQube analysis'
name: 'gcr.io/$PROJECT_ID/sonar-scanner:latest'
args:
- '-Dsonar.host.url=https://xxxxxxxxx'
- '-Dsonar.login=xxxxxxxxxx'
- '-Dsonar.projectKey=xxxxxxxxxx'
- '-Dsonar.sources=src'
timeout: "1600s"
```
## Expected Behavior
Analysis to be executed without errors
## Actual Behavior
NODE component is missing. Analysis is performed correctly, the error does not block the entire build and the SonarQube dashboard properly shows results. But without NODE I think that part of the analysis is not executed.
```
starting build "63b6fc99-xxxxxxxxx-7070a028b9f8"
FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From https://source.developers.google.com/p/xxxxxxxxx/r/bitbucket_xxxxxxxxxxx
* branch c95dabxxxxxxxxxxcb8c0ae9734 -> FETCH_HEAD
HEAD is now at c95dabc Merge branch 'develop'
BUILD
Pulling image: gcr.io/xxxxxxxxx/sonar-scanner:latest
latest: Pulling from xxxxxxxxx/sonar-scanner
e7c96db7181b: Already exists
293826260402: Pulling fs layer
971696430c0d: Pulling fs layer
971696430c0d: Verifying Checksum
971696430c0d: Download complete
293826260402: Verifying Checksum
293826260402: Download complete
293826260402: Pull complete
971696430c0d: Pull complete
Digest: sha256:3f7479f17a6ca6deb2d026e800f62c5a3785f67d73f57ec4d942f4ca243610f7
Status: Downloaded newer image for gcr.io/xxxxxxxxx/sonar-scanner:latest
START: Running sonar-scanner-cli on Tue May 14 17:36:03 UTC 2019
INFO: Scanner configuration file: /opt/sonar-scanner-3.2.0.1227-linux/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.2.0.1227
INFO: Java 1.8.0_212 IcedTea (64-bit)
INFO: Linux 4.15.0-1030-gcp amd64
INFO: User cache: /root/.sonar/cache
INFO: SonarQube server 7.0.0
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=830ms
INFO: Server id: AWKVRlYl_FMPFLU_Ecyi
INFO: User cache: /root/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=257ms
INFO: Load/download plugins
INFO: Load/download plugins (done) | time=4304ms
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=226ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=171ms
INFO: Load active rules
INFO: Load active rules (done) | time=1565ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=191ms
INFO: Project key: sonarqube-project-key
INFO: ------------- Scan sonarqube-project-key
INFO: Load server rules
INFO: Load server rules (done) | time=320ms
INFO: Base dir: /workspace
INFO: Working dir: /workspace/.scannerwork
INFO: Source paths: src
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: 91 files indexed
INFO: Quality profile for js: Sonar way
INFO: Quality profile for ts: Sonar way
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=10ms
INFO: Sensor SonarTS [typescript]
ERROR: Failed to get Node.js version
java.io.IOException: Cannot run program "node": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at org.sonar.plugin.typescript.ExternalTypescriptSensor.isCompatibleNodeVersion(ExternalTypescriptSensor.java:155)
at org.sonar.plugin.typescript.ExternalTypescriptSensor.analyze(ExternalTypescriptSensor.java:115)
at org.sonar.plugin.typescript.ExternalTypescriptSensor.execute(ExternalTypescriptSensor.java:109)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:180)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:288)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:283)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:261)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 38 common frames omitted
ERROR: No TypeScript files will be analyzed
INFO: Sensor SonarTS [typescript] (done) | time=265ms
INFO: Sensor SonarTS Coverage [typescript]
INFO: Sensor SonarTS Coverage [typescript] (done) | time=2ms
INFO: Sensor SonarJS [javascript]
INFO: 6 source files to be analyzed
INFO: 3/6 files analyzed, current file: /workspace/src/assets/lib/bootstrap-4.3.1/js/bootstrap.js
INFO: 6/6 source files have been analyzed
INFO: Sensor SonarJS [javascript] (done) | time=12719ms
INFO: Sensor SonarJS Coverage [javascript]
INFO: Sensor SonarJS Coverage [javascript] (done) | time=1ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=165ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=1ms
INFO: SCM provider for this project is: git
INFO: 27 files to be analyzed
WARN: Shallow clone detected, no blame information will be provided. You can convert to non-shallow with 'git fetch --unshallow'.
INFO: 0/27 files analyzed
WARN: Missing blame information for the following files:
WARN: * src/app/app-routing.module.ts
WARN: * src/app/app-routing/app-routing.module.ts
WARN: * src/app/app.component.spec.ts
WARN: * src/app/app.component.ts
WARN: * src/app/app.constants.ts
WARN: * src/app/app.module.ts
WARN: * src/app/header/header.component.spec.ts
WARN: * src/app/header/header.component.ts
WARN: * src/app/home/home.component.spec.ts
WARN: * src/app/home/home.component.ts
WARN: * src/app/login/login.component.spec.ts
WARN: * src/app/login/login.component.ts
WARN: * src/app/services/pre-registration.service.ts
WARN: * src/app/student/registration/registration.component.spec.ts
WARN: * src/app/student/registration/registration.component.ts
WARN: * src/app/teacher/pre-registration/pre-registration.component.spec.ts
WARN: * src/app/teacher/pre-registration/pre-registration.component.ts
WARN: * src/assets/lib/bootstrap-4.3.1/js/bootstrap.bundle.js
WARN: * src/assets/lib/bootstrap-4.3.1/js/bootstrap.bundle.min.js
WARN: * src/assets/lib/bootstrap-4.3.1/js/bootstrap.js
WARN: * src/assets/lib/bootstrap-4.3.1/js/bootstrap.min.js
WARN: * src/environments/environment.prod.ts
WARN: * src/environments/environment.ts
WARN: * src/karma.conf.js
WARN: * src/main.ts
WARN: * src/polyfills.ts
WARN: * src/test.ts
WARN: This may lead to missing/broken features in SonarQube
INFO: 1 file had no CPD blocks
INFO: Calculating CPD for 3 files
INFO: CPD calculation finished
INFO: Analysis report generated in 484ms, dir size=985 KB
INFO: Analysis reports compressed in 123ms, zip size=318 KB
INFO: Analysis report uploaded in 1332ms
INFO: ANALYSIS SUCCESSFUL, you can browse https://xxxxxxxxxx/dashboard/index/sonarqube-project-key
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://xxxxxxxxxx/api/ce/task?id=xxxxxxxxx
INFO: Task total time: 22.198 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 34.114s
INFO: Final Memory: 12M/215M
INFO: ------------------------------------------------------------------------
END: Running sonar-scanner-cli on Tue May 14 17:36:38 UTC 2019
PUSH
DONE
```
I'm not usre here, this is something that need to be configured at server-side or inside the sonar image?
Contributor guide
Research direction
Start with the affected gcr.io/$PROJECT_ID/sonar-scanner:latest image and the provided Cloud Build YAML. Check whether the image includes the node executable required by the SonarTS sensor, then determine whether the fix belongs in the image or server configuration. Done means the Angular scan completes without the missing Node.js error and TypeScript files are analyzed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, docker, google-cloud, node.js, typescript
- Domain
- build-system, ci-cd, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100