GitLab CI: Could not find ‘java’ executable in JAVA_HOME or PATH

Must-share information (formatted with Markdown):

  • which versions are you using:
    ** SonarQube 10.3
    ** Scanner sonarsource/sonar-scanner-cli:latest
    *** But I’ve tried sonarsource/sonar-scanner-cli:11.0 same thing
  • how is SonarQube deployed: Docker
  • what are you trying to achieve. run the scanner as before
  • what have you tried so far to achieve this: I’ve tried downversions of the sonar-scanner-cli to 11.0 - no dice.

Downgrading sonar-scanner-cli to 10.0 finally worked.
Why is there no JAVA_HOME in sonar-scanner-cli 11.0?

Job:

sonar_dev:
  stage: sonar
  needs: [ 'test_dev' ]
  allow_failure: true
  environment:
    name: development
  rules:
    - if: $CI_COMMIT_BRANCH == "DEVELOPMENT"
      changes:
        - src/**/*
        - test/**/*
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [ '/bin/sh', '-c' ]
  variables:
    SONAR_USER_HOME: '${CI_PROJECT_DIR}/.sonar'
    GIT_DEPTH: 0
  cache:
    key: '${CI_JOB_NAME}'
    paths:
      - .sonar/cache
  script:
    - sonar-scanner

New result:

$ sonar-scanner
Could not find ‘java’ executable in JAVA_HOME or PATH.

Hi,

Your pipeline says latest, but you’re citing 11.0, when 11.1.1 is the newest version.

Can you try that and see if this is still replicable?

 
Thx,
Ann

I tried 11.0 after latest failed.

I think it is pretty clear from my description that latest was the one to fail, and that I then tried 11.0, and then 10.0 and that 10.0 worked while latest and 11.0 did not.

Hi @Predrag_Stojadinovic ,

We were able to reproduce the issue with prior versions of the sonar-scanner-cli indeed. And we could also demonstrate that the latest version of sonar-scanner-cli no longer has this issue.

The latest version we use is sonarsource/sonar-scanner-cli:11.1.1.1661_6.2.1 which has Digest: sha256:0b90dedf01ef875d69a5a151f73d72b8288a319b39cdfd2ee32a729027a00785

Could you check if this is the version you are using?

Thanks!
@AlxO

1 Like

I’ve just tried with sonarsource/sonar-scanner-cli:11.1 and it failed again with Could not find 'java' executable in JAVA_HOME or PATH. :frowning:

sonarsource/sonar-scanner-cli:11.1 has the same Digest as sonarsource/sonar-scanner-cli:11.1.1.1661_6.2.1 and as sonarsource/sonar-scanner-cli:latest

This is puzzling…

Here are the tests I did:

docker image pull sonarsource/sonar-scanner-cli:11.1.1.1661_6.2.1
11.1.1.1661_6.2.1: Pulling from sonarsource/sonar-scanner-cli
9a0f8ca95549: Already exists 
f6c81cf32813: Already exists 
ef33d0945dc7: Already exists 
30102dc55d4b: Already exists 
4a7c91ac5b9c: Already exists 
4f4fb700ef54: Already exists 
Digest: sha256:0b90dedf01ef875d69a5a151f73d72b8288a319b39cdfd2ee32a729027a00785
Status: Downloaded newer image for sonarsource/sonar-scanner-cli:11.1.1.1661_6.2.1
docker.io/sonarsource/sonar-scanner-cli:11.1.1.1661_6.2.1
docker container run -it sonarsource/sonar-scanner-cli:11.1.1.1661_6.2.1 /bin/sh
sh-5.2$ java --version
openjdk 17.0.12 2024-07-16 LTS
OpenJDK Runtime Environment Corretto-17.0.12.7.1 (build 17.0.12+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.12.7.1 (build 17.0.12+7-LTS, mixed mode, sharing)
sh-5.2$ 

Can you run the same tests?

I just tried sonarsource/sonar-scanner-cli:11.1.1.1661_6.2.1 and:

Preparing the “docker” executor
Using Docker executor with image sonarsource/sonar-scanner-cli:11.1.1.1661_6.2.1 …
$ sonar-scanner
Could not find ‘java’ executable in JAVA_HOME or PATH.