Search code examples
javasonarqube

sonar-scanner-cli-4.2 does not find jre/bin/java


I am trying to run the sonnarqube scanner on a docker container on jenkins. I use following image:

FROM node:16-alpine

I install java from here:

RUN apk --no-cache add openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community

I install sonnarqube scanner from here:

RUN wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873.zip

When running the scanner, I get following error:

22:33:55 sonar-scanner-4.2.0.1873-linux/bin/sonar-scanner: exec: line 64: /e2e/sonar-scanner-4.2.0.1873-linux/jre/bin/java: not found

I've checked java path:

22:33:49 Step 39/44 : RUN which java
22:33:49  ---> Running in 47df6c73c0b7
22:33:50 /usr/bin/java

and append it to my PATH env variable (sonnarqube executable too):

22:50:57 /usr/bin/java/bin:/sonar-scanner-4.2.0.1873/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

In the docs, they say that they provide a JRE for linux distribution.

But if I inspect the sonnarqube folder, I just see:

22:50:39 drwxr-xr-x    5 root     root          4096 Nov 25 21:50 .
22:50:39 drwxr-xr-x    1 root     root          4096 Nov 25 21:50 ..
22:50:39 drwxr-xr-x    2 root     root          4096 Nov 25 21:50 bin
22:50:39 drwxr-xr-x    2 root     root          4096 Nov 25 21:50 conf
22:50:39 drwxr-xr-x    2 root     root          4096 Nov 25 21:50 lib

There's no sonar-scanner-4.2.0.1873/jre/java/bin

Should the jre be in the sonar-scanner-4.2.0.1873 folder? is my PATH env var wrong? I can't figure out why java is not found.


Solution

  • if you need exactly alpine, then:

    export GLIBC_VERSION=2.34-r0
    apk --no-cache add binutils curl
    curl -sL https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub
    curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk
    curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk
    curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-i18n-${GLIBC_VERSION}.apk
    apk add --no-cache glibc-${GLIBC_VERSION}.apk glibc-bin-${GLIBC_VERSION}.apk glibc-i18n-${GLIBC_VERSION}.apk # you must be needed to add || true for alpine newer than 3.15
    

    in my tests GLIBC_VERSION 2.34-r0 only working. I tried newer, but doesn't work

    Update 2025-02-27

    It seems there are prepared images with current Alpine versions on https://hub.docker.com/r/frolvlad/alpine-glibc

    Dockerfile is here