SAP / jenkins-library

Jenkins shared library for Continuous Delivery pipelines.
https://www.project-piper.io
Apache License 2.0
778 stars 586 forks source link

sonarExecuteScan failing with exit code 127 #3724

Closed siluski closed 2 years ago

siluski commented 2 years ago

Good morning all,

I have configured sonarExecuteScan in a CAP project with project piper. Currently it calls the sonarExecuteScan step, but it fails with an exit code of 127 : command not found, and I'm not sure why. Below are the logs of when this is run, any assistance would be greatly appreciated.

[2022-04-11T14:35:37.836Z] --- Begin library step of: sonarExecuteScan --- [Pipeline] echo [2022-04-11T14:35:37.901Z] Unstash content: piper-bin [Pipeline] unstash [Pipeline] echo [2022-04-11T14:35:38.685Z] Unstash content: pipelineConfigAndTests [Pipeline] unstash [Pipeline] libraryResource [Pipeline] writeFile [Pipeline] withEnv [Pipeline] { [Pipeline] sh [2022-04-11T14:35:39.213Z] + ./piper getConfig --contextConfig --stepMetadata .pipeline/tmp/metadata/sonarExecuteScan.yaml --defaultConfig .pipeline/.pipeline/cicdCustomDefaults.yml --ignoreCustomDefaults [2022-04-11T14:35:39.230Z] time="2022-04-11T14:35:38Z" level=info msg="{ [] 0x975880}" library=SAP/jenkins-library [2022-04-11T14:35:39.246Z] time="2022-04-11T14:35:38Z" level=info msg="Printing stepName " library=SAP/jenkins-library [2022-04-11T14:35:39.259Z] time="2022-04-11T14:35:38Z" level=info msg="Ignoring custom defaults from pipeline config" library=SAP/jenkins-library [Pipeline] readJSON [Pipeline] echo [2022-04-11T14:35:39.393Z] Context Config: [dockerImage:sonarqube, dockerName:sonar, dockerPullImage:false] [Pipeline] withEnv [Pipeline] { [Pipeline] sh [2022-04-11T14:35:39.828Z] + ./piper writePipelineEnv [2022-04-11T14:35:39.846Z] time="2022-04-11T14:35:39Z" level=info msg="{ [] 0x975880}" library=SAP/jenkins-library [Pipeline] } [Pipeline] // withEnv [Pipeline] sh [2022-04-11T14:35:40.219Z] + ./piper getConfig --stepMetadata .pipeline/tmp/metadata/sonarExecuteScan.yaml --defaultConfig .pipeline/.pipeline/cicdCustomDefaults.yml --ignoreCustomDefaults [2022-04-11T14:35:40.234Z] time="2022-04-11T14:35:40Z" level=info msg="{ [] 0x975880}" library=SAP/jenkins-library [2022-04-11T14:35:40.246Z] time="2022-04-11T14:35:40Z" level=info msg="Printing stepName " library=SAP/jenkins-library [2022-04-11T14:35:40.256Z] time="2022-04-11T14:35:40Z" level=info msg="Ignoring custom defaults from pipeline config" library=SAP/jenkins-library [Pipeline] readJSON [Pipeline] echo [2022-04-11T14:35:40.364Z] Step Config: [branchName:master, githubApiUrl:https://api.github.com, owner:siluski, projectKey:risk-management-project, pullRequestProvider:GitHub, repository:RiskManagement, serverUrl:http://localhost:9000, sonarScannerDownloadUrl:https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip, versioningModel:major] [Pipeline] echo [2022-04-11T14:35:40.520Z] [INFO] executing pipeline step 'sonarExecuteScan' with docker image 'sonarqube' [Pipeline] echo [2022-04-11T14:35:40.793Z] --- Begin library step of: dockerExecute --- [Pipeline] echo [2022-04-11T14:35:41.028Z] [dockerExecute] Sending telemetry data is disabled. [Pipeline] echo [2022-04-11T14:35:41.319Z] --- Begin library step of: dockerExecuteOnKubernetes --- [Pipeline] echo [2022-04-11T14:35:41.641Z] [dockerExecuteOnKubernetes] Sending telemetry data is disabled. [Pipeline] stash [2022-04-11T14:36:39.275Z] Stashed 24857 file(s) [Pipeline] podTemplate [Pipeline] { [Pipeline] node [2022-04-11T14:36:48.545Z] Created Pod: kubernetes steward-run-9nwgn-main-ncp76/dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt [2022-04-11T14:36:48.592Z] [Normal][steward-run-9nwgn-main-ncp76/dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt][Scheduled] Successfully assigned steward-run-9nwgn-main-ncp76/dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt to ip-10-250-1-236.eu-central-1.compute.internal [2022-04-11T14:36:50.511Z] [Normal][steward-run-9nwgn-main-ncp76/dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt][Pulled] Container image "jenkins/jnlp-slave@sha256:30732bbe8afbe63652b2903d308ba405b16290d81a08688b75a51a6e0f1b4087" already present on machine [2022-04-11T14:36:50.553Z] [Normal][steward-run-9nwgn-main-ncp76/dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt][Created] Created container jnlp [2022-04-11T14:36:50.660Z] [Normal][steward-run-9nwgn-main-ncp76/dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt][Started] Started container jnlp [2022-04-11T14:36:50.674Z] [Normal][steward-run-9nwgn-main-ncp76/dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt][Pulling] Pulling image "sonarqube" [2022-04-11T14:36:54.423Z] Still waiting to schedule task [2022-04-11T14:36:54.440Z] Waiting for next available executor on ‘dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt’ [2022-04-11T14:37:04.211Z] [Normal][steward-run-9nwgn-main-ncp76/dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt][Pulled] Successfully pulled image "sonarqube" in 13.547210268s [2022-04-11T14:37:06.908Z] [Normal][steward-run-9nwgn-main-ncp76/dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt][Created] Created container container-exec [2022-04-11T14:37:06.988Z] [Normal][steward-run-9nwgn-main-ncp76/dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt][Started] Started container container-exec [2022-04-11T14:37:07.269Z] Agent dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt is provisioned from template dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr [2022-04-11T14:37:07.300Z] Running on dynamic-agent-45f900d7-bc48-4e8e-aa44-443254e91532-2p4jr-f3sjt in /home/jenkins/agent/workspace/risk-management-job [Pipeline] { [Pipeline] echo [2022-04-11T14:37:07.396Z] ContainerConfig: [name:container-exec] [Pipeline] container [Pipeline] { [Pipeline] echo [2022-04-11T14:37:07.533Z] Unstash content: workspace-45f900d7-bc48-4e8e-aa44-443254e91532 [Pipeline] unstash [Pipeline] echo [2022-04-11T14:37:20.958Z] invalidate stash workspace-45f900d7-bc48-4e8e-aa44-443254e91532 [Pipeline] stash [2022-04-11T14:37:21.059Z] Warning: overwriting stash ‘workspace-45f900d7-bc48-4e8e-aa44-443254e91532’ [2022-04-11T14:37:21.608Z] Stashed 0 file(s) [Pipeline] echo [2022-04-11T14:37:21.703Z] [INFO][dockerExecute] Executing inside a Kubernetes Pod [Pipeline] fileExists [Pipeline] echo [2022-04-11T14:37:21.840Z] Unstash content: git [Pipeline] unstash [Pipeline] withEnv [Pipeline] { [Pipeline] sh [2022-04-11T14:37:22.668Z] + ./piper writePipelineEnv [2022-04-11T14:37:22.684Z] time="2022-04-11T14:37:22Z" level=info msg="{ [] 0x975880}" library=SAP/jenkins-library [Pipeline] } [Pipeline] // withEnv [Pipeline] withEnv [Pipeline] { [Pipeline] withCredentials [Pipeline] { [Pipeline] sh [2022-04-11T14:37:23.596Z] + ./piper sonarExecuteScan --defaultConfig .pipeline/.pipeline/cicdCustomDefaults.yml --ignoreCustomDefaults [2022-04-11T14:37:23.616Z] time="2022-04-11T14:37:23Z" level=info msg="{ [] 0x975880}" library=SAP/jenkins-library [2022-04-11T14:37:23.628Z] info sonarExecuteScan - Using stageName 'Build' from env variable [2022-04-11T14:37:23.649Z] info sonarExecuteScan - Project config: '.pipeline/config.yml' [2022-04-11T14:37:23.663Z] info sonarExecuteScan - Project defaults: '.pipeline/.pipeline/cicdCustomDefaults.yml' [2022-04-11T14:37:23.695Z] info sonarExecuteScan - Ignoring custom defaults from pipeline config [2022-04-11T14:37:23.716Z] info sonarExecuteScan - Retrieving hook configuration [2022-04-11T14:37:23.729Z] warn sonarExecuteScan - sonar token not set [2022-04-11T14:37:23.741Z] info sonarExecuteScan - [DEBUG] GET https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip [2022-04-11T14:37:26.269Z] info sonarExecuteScan - running command: /home/jenkins/agent/workspace/risk-management-job/.sonar-scanner/bin/sonar-scanner -Dsonar.projectKey=risk-management-project -Dsonar.branch.name=master [2022-04-11T14:37:26.282Z] info sonarExecuteScan - /home/jenkins/agent/workspace/risk-management-job/.sonar-scanner/bin/sonar-scanner: exec: line 66: /home/jenkins/agent/workspace/risk-management-job/.sonar-scanner/jre/bin/java: not found [2022-04-11T14:37:26.291Z] info sonarExecuteScan - fatal error: errorDetails{"category":"undefined","correlationId":"n/a","error":"running command '/home/jenkins/agent/workspace/risk-management-job/.sonar-scanner/bin/sonar-scanner' failed: cmd.Run() failed: exit status 127","library":"SAP/jenkins-library","message":"Execution failed","result":"failure","stepName":"sonarExecuteScan","time":"2022-04-11T14:37:26.093683087Z"} [2022-04-11T14:37:26.338Z] fatal sonarExecuteScan - Execution failed - running command '/home/jenkins/agent/workspace/risk-management-job/.sonar-scanner/bin/sonar-scanner' failed: cmd.Run() failed: exit status 127 [2022-04-11T14:37:26.351Z] info sonarExecuteScan - persisting reports to GCS is disabled, because gcsBucketId is empty [2022-04-11T14:37:26.384Z] info sonarExecuteScan - Step telemetry data:{"StepStartTime":"2022-04-11 14:37:23.42909973 +0000 UTC","PipelineURLHash":"50f013532a9770a2c2cfdc38b7581dd01df69b70","BuildURLHash":"50f013532a9770a2c2cfdc38b7581dd01df69b70","StageName":"Build","StepName":"sonarExecuteScan","ErrorCode":"1","StepDuration":"2665","ErrorCategory":"undefined","CorrelationID":"n/a","PiperCommitHash":"5f4cd838cfd4fc7825c0587d6b432808dc97b3f0","ErrorDetail":{"category":"undefined","correlationId":"n/a","error":"running command '/home/jenkins/agent/workspace/risk-management-job/.sonar-scanner/bin/sonar-scanner' failed: cmd.Run() failed: exit status 127","library":"SAP/jenkins-library","message":"Execution failed","result":"failure","stepName":"sonarExecuteScan","time":"2022-04-11T14:37:26.093683087Z"}}

raman-susla-epam commented 2 years ago

Hi @siluski, It sounds like a duplicate: https://github.com/SAP/jenkins-library/issues/3227 Do you still need any help with it?

ashlymat commented 2 years ago

Hi @siluski Closing this issue for now.Please reopen if necessary