Integrating Sonar with Docker

Published: Apr 27, 2022 by Isaac Johnson

We already looked at creating dockerized tests a few weeks ago.

However, having to look at logs to see if hopefully tests ran and were passed isn’t enterprise scale. Moreover, we may wish to have some kind of management of coverage, tests, etc in an external tool such as sonarqube.

We will setup Sonarqube in our cluster, configure it then setup scans of our Dockerized NodeJS app we used before. We will then extend the scans to include coverage and lastly look at ways we can gate on coverage.

Installing Sonarqube

We will use the Helm chart to load Sonarqube. If you want better DR, consider using a PaaS PostgreSQL database and passing the settings to the chart.

$ helm repo add sonarqube https://SonarSource.github.io/helm-chart-sonarqube
"sonarqube" has been added to your repositories

$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "sonarqube" chart repository
...Successfully got an update from the "uptime-kuma" chart repository
...Successfully got an update from the "azure-samples" chart repository
...Successfully got an update from the "kuma" chart repository
...Successfully got an update from the "dapr" chart repository
...Successfully got an update from the "kubecost" chart repository
...Successfully got an update from the "sumologic" chart repository
...Successfully got an update from the "datadog" chart repository
...Successfully got an update from the "harbor" chart repository
...Successfully got an update from the "nginx-stable" chart repository
...Successfully got an update from the "incubator" chart repository
...Successfully got an update from the "rancher-latest" chart repository
...Successfully got an update from the "myharbor" chart repository
...Successfully got an update from the "newrelic" chart repository
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈

$ helm upgrade --install sonarqube sonarqube/sonarqube
Release "sonarqube" does not exist. Installing it now.
NAME: sonarqube
LAST DEPLOYED: Wed Apr 20 06:59:19 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
  export POD_NAME=$(kubectl get pods --namespace default -l "app=sonarqube,release=sonarqube" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl port-forward $POD_NAME 8080:9000 -n default

To setup Ingress, I’ll create a Route53 record and Ingress object

$ cat r53-sonarqube.json
{
  "Comment": "CREATE sonarqube fb.s A record ",
  "Changes": [
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "sonarqube.freshbrewed.science",
        "Type": "A",
        "TTL": 300,
        "ResourceRecords": [
          {
            "Value": "73.242.50.46"
          }
        ]
      }
    }
  ]
}

Apply it

$ aws route53 change-resource-record-sets --hosted-zone-id Z39E8QFU0F9PZP --change-batch file://r53-sonarqube.json
{
    "ChangeInfo": {
        "Id": "/change/C01128752CBKS8XC7KOMR",
        "Status": "PENDING",
        "SubmittedAt": "2022-04-20T11:40:01.752Z",
        "Comment": "CREATE sonarqube fb.s A record "
    }
}

Then we can create the Ingress

$ cat sonarqubeIngress.yml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/tls-acme: "true"
    kubernetes.io/ingress.class: nginx
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
  name: sonarqube
  namespace: default
spec:
  tls:
  - hosts:
    - sonarqube.freshbrewed.science
    secretName: sonarqube-tls
  rules:
  - host: sonarqube.freshbrewed.science
    http:
      paths:
      - backend:
          service:
            name: sonarqube-sonarqube
            port:
              number: 9000
        path: /
        pathType: ImplementationSpecific


$ kubectl apply -f sonarqubeIngress.yml
ingress.networking.k8s.io/sonarqube created

I have an odd little issue that has cropped up lately that my LE (Acme) validation is getting held up by Nginx redirects of HTTPS.

Ingress:

sonarqube                               <none>   sonarqube.freshbrewed.science   192.168.1.12,192.168.1.205,192.168.1.214,192.168.1.57,192.168.1.77                80, 443   3m44s
cm-acme-http-solver-7z2x5               <none>   sonarqube.freshbrewed.science                                                                                     80        3m39s

My dirty trick is to just delete the ingress for a moment, then recreate after the http solver is done

$ kubectl delete ingress sonarqube
ingress.networking.k8s.io "sonarqube" deleted

$ kubectl get cert | tail -n1
sonarqube-tls                        False   sonarqube-tls                         4m3s

$ kubectl get cert | tail -n1
sonarqube-tls                        True    sonarqube-tls                         4m35s

$ kubectl apply -f sonarqubeIngress.yml
ingress.networking.k8s.io/sonarqube created

When you connect, you’ll want to change your admin password first (default is admin for both username and password).

/content/images/2022/04/dockertests3-01.png

Setup

In Settings, we’ll want to set our host URL

/content/images/2022/04/dockertests3-02.png

and then create some SMTP settings. I tend to use SES for this purpose.

Login to AWS console and go to SES settings

/content/images/2022/04/dockertests3-03.png

From there, we can create new SMTP credentials

/content/images/2022/04/dockertests3-04.png

In the wizard, you can download the creds as JSON but also view them

/content/images/2022/04/dockertests3-05.png

You can review the prior blog on feedback forms to see how to test.

Once we’ve set the SMTP settings, we can send a test email to ensure they work (for SES, use starttls instead of ssl, fyi)

/content/images/2022/04/dockertests3-06.png

The other setting I tend to always enable is to change my project visibility to private. This is mostly because results can include source code and by default you want to not share that (unless you are specifically wanting public access).

/content/images/2022/04/dockertests3-07.png

Create a project

From the Projects Management area we can “Create Project”. Git it a Name and Key. For simplicity, I am often of the habit of keeping them the same. However, if you have projects with non Alphanumeric characters or spaces, then you can let them differ. The key will be used on Issues and to send results up.

/content/images/2022/04/dockertests3-08.png

We now have a live project: https://sonarqube.freshbrewed.science/dashboard?id=dkrwtsts

/content/images/2022/04/dockertests3-09.png

Ny first test will be to upload manually. Click the “Manually” tile at the bottom and then Generaet a token

18407a327a0148f4a8e33bbc3fff23a5

Next, we can click the “Other” type of build and “Linux” to get a basic sonar scan oneliner

/content/images/2022/04/dockertests3-10.png

sonar-scanner \
  -Dsonar.projectKey=dkrwtsts \
  -Dsonar.sources=. \
  -Dsonar.host.url=https://sonarqube.freshbrewed.science \
  -Dsonar.login=18407a327a0148f4a8e33bbc3fff23a5

Creating a project and token

We next want to create a project we will use to track coverage and details about our containerized service.

Running a scan manually

Install Sonarscanner. I’ll use Brew on Linux


$ brew install sonar-scanner
Running `brew update --preinstall`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
acl                      criterion                ecflow-ui                httpyac                  libcython                mongodb-atlas-cli        ugit
ansible-language-server  dagger                   flyctl                   ifacemaker               libmarpa                 nvchecker                wasm-tools
autocannon               ddcutil                  gi-docgen                imposm3                  localtunnel              openjdk@17               werf
cloudflare-quiche        difftastic               gops                     jdtls                    mariadb@10.6             powerman-dockerize
compiledb                easeprobe                highs                    kmod                     melody                   shadowsocks-rust
==> Updated Formulae
Updated 1503 formulae.
==> Deleted Formulae
autopano-sift-c              boost-python                 griffon                      komposition                  mozilla-addon-sdk            szip

==> Downloading https://ghcr.io/v2/homebrew/core/alsa-lib/manifests/1.2.6.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/alsa-lib/blobs/sha256:c673efe91d915b952414f5bc37381c9f75979f0ecd196236a2997413beca1bab
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:c673efe91d915b952414f5bc37381c9f75979f0ecd196236a2997413beca1bab?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2022-03-29
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:e777028f6008e695fe33b07ddc0c13f149b4bbe2289bbd65173daadc98fcfc7d
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:e777028f6008e695fe33b07ddc0c13f149b4bbe2289bbd65173daadc98fcfc7d?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/manifests/1.1.1n
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/blobs/sha256:e93f6823d627f7f7390fa9126ffdc0b508ade9f5724ab6b91c8c32237931a05d
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:e93f6823d627f7f7390fa9126ffdc0b508ade9f5724ab6b91c8c32237931a05d?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/m4/manifests/1.4.19
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/m4/blobs/sha256:f6d1087a51e0ff2e582b3043a25a51b67971b2246cf65167ef3abf1230160f04
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:f6d1087a51e0ff2e582b3043a25a51b67971b2246cf65167ef3abf1230160f04?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/bison/manifests/3.8.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/bison/blobs/sha256:d708c29c7e44f28a4fa77d353ff7adfbe673b31cef6f24c3c384a03ba01b3608
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:d708c29c7e44f28a4fa77d353ff7adfbe673b31cef6f24c3c384a03ba01b3608?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ncurses/manifests/6.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ncurses/blobs/sha256:09c1d079d3b5cf1c855afa9da1fc7251234b73971d4cbe0bf7b9fca1cbea353c
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:09c1d079d3b5cf1c855afa9da1fc7251234b73971d4cbe0bf7b9fca1cbea353c?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/readline/manifests/8.1.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/readline/blobs/sha256:2b46aff4f720e0f15601aecb2efd4ae7c2a3454b2fad91b196728ed4ee4f12c3
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:2b46aff4f720e0f15601aecb2efd4ae7c2a3454b2fad91b196728ed4ee4f12c3?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/manifests/1.2.11
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/blobs/sha256:db54bf590275839d3f4cdf31d9527aa3a4c19a8984b5605cedc3f7c22a65eea4
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:db54bf590275839d3f4cdf31d9527aa3a4c19a8984b5605cedc3f7c22a65eea4?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxml2/manifests/2.9.13
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxml2/blobs/sha256:01393bbdc60b7263d0c66d19bb56361d703c69c7ab56940561746715958b2d5e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:01393bbdc60b7263d0c66d19bb56361d703c69c7ab56940561746715958b2d5e?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gettext/manifests/0.21
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gettext/blobs/sha256:33f840e667c6ee0f674adb279e644ca4a1b3cd1606894c85d9bbce1b5acc0273
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:33f840e667c6ee0f674adb279e644ca4a1b3cd1606894c85d9bbce1b5acc0273?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/krb5/manifests/1.19.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/krb5/blobs/sha256:ddc056655dfc8c6b880729096c25968b52cb39de533c61053c0c74a69961bce6
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:ddc056655dfc8c6b880729096c25968b52cb39de533c61053c0c74a69961bce6?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gmp/manifests/6.2.1_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gmp/blobs/sha256:786ae29f0c0b06ea86e42bd9c6ac2c49bd5757da037dead7053e8bd612c4cf8c
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:786ae29f0c0b06ea86e42bd9c6ac2c49bd5757da037dead7053e8bd612c4cf8c?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/bdw-gc/manifests/8.0.6
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/bdw-gc/blobs/sha256:2de2bd6626902c0c6007c718d9bebdc9f653dcd58058f9f1a8cc0346fee8c8c7
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:2de2bd6626902c0c6007c718d9bebdc9f653dcd58058f9f1a8cc0346fee8c8c7?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libffi/manifests/3.4.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libffi/blobs/sha256:48e34a380ab065bda9191298bd3eefc895f1c2315d508cb83614eac01cf38301
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:48e34a380ab065bda9191298bd3eefc895f1c2315d508cb83614eac01cf38301?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libtool/manifests/2.4.7
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libtool/blobs/sha256:1cde2899a36adf5b04d25a9b8b4d6bec8a3099bc59ae68c63e479a4da8ca70b3
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:1cde2899a36adf5b04d25a9b8b4d6bec8a3099bc59ae68c63e479a4da8ca70b3?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libunistring/manifests/1.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libunistring/blobs/sha256:b1d76e62d1bafe89c7535ca21aad48fe99370b5353d0c4efeafe564db367401d
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:b1d76e62d1bafe89c7535ca21aad48fe99370b5353d0c4efeafe564db367401d?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/manifests/0.29.2_3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/blobs/sha256:3d9b8bf9b7b4bd08086be1104e3e18afb1c437dfaca03e6e7df8f2710b9c1c1a
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:3d9b8bf9b7b4bd08086be1104e3e18afb1c437dfaca03e6e7df8f2710b9c1c1a?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gperf/manifests/3.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gperf/blobs/sha256:a91b89f648c21ae225074e0a9f4e54154b4f2744cc0a37e8421e84ee7ac61a95
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:a91b89f648c21ae225074e0a9f4e54154b4f2744cc0a37e8421e84ee7ac61a95?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/guile/manifests/3.0.8
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/guile/blobs/sha256:0a6685530111e6091bd640f119603b6a2f4cb70bfb8cd70532577898a9dbd91b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:0a6685530111e6091bd640f119603b6a2f4cb70bfb8cd70532577898a9dbd91b?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libidn2/manifests/2.3.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libidn2/blobs/sha256:57a2bf8955bcc8c2661aec2b26acfb90ec50402d78afebb000a1f6b0c27421e4
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:57a2bf8955bcc8c2661aec2b26acfb90ec50402d78afebb000a1f6b0c27421e4?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libtasn1/manifests/4.18.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libtasn1/blobs/sha256:9964622a7285ce7dbcdc713804d18fc9de0ce1db5037198de69b91fdb3a7f062
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:9964622a7285ce7dbcdc713804d18fc9de0ce1db5037198de69b91fdb3a7f062?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nettle/manifests/3.7.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nettle/blobs/sha256:a7c56819e2bc18baf900853311685108aab2cda8fc4963ca095ba893235ef1cb
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:a7c56819e2bc18baf900853311685108aab2cda8fc4963ca095ba893235ef1cb?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/p11-kit/manifests/0.24.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/p11-kit/blobs/sha256:41dd8094535e5cb03c1c4e94290cee3047e79c07183cdccbb0f4f3cbe89d29db
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:41dd8094535e5cb03c1c4e94290cee3047e79c07183cdccbb0f4f3cbe89d29db?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libevent/manifests/2.1.12
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libevent/blobs/sha256:08f595173b3e517a94919784e0a2378cdb17c94276d7382203eb7b54322798a7
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:08f595173b3e517a94919784e0a2378cdb17c94276d7382203eb7b54322798a7?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libnghttp2/manifests/1.47.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libnghttp2/blobs/sha256:85fcb5b98c7d3d607c02742146146c92363f5bfaf95b0cb8924b207cb1fc9082
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:85fcb5b98c7d3d607c02742146146c92363f5bfaf95b0cb8924b207cb1fc9082?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/expat/manifests/2.4.7
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/expat/blobs/sha256:6d90f22095cca714b764af2e2aca33b4e96d06fbf237775d64aa50b81525a1c8
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:6d90f22095cca714b764af2e2aca33b4e96d06fbf237775d64aa50b81525a1c8?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/unbound/manifests/1.15.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/unbound/blobs/sha256:9f6128b97ce6f63f9197aa6010a6380afe31a8df9732e1c5d91a3036dc5c8f6d
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:9f6128b97ce6f63f9197aa6010a6380afe31a8df9732e1c5d91a3036dc5c8f6d?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gnutls/manifests/3.7.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/gnutls/blobs/sha256:e01881a84a775b5cc5f5c76bde81f15da2dafc1f0dffe38e5fbe004ea178d446
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:e01881a84a775b5cc5f5c76bde81f15da2dafc1f0dffe38e5fbe004ea178d446?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/cups/manifests/2.4.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/cups/blobs/sha256:d3fc052a8a913bafc9481780ebc7b3bf4d9ce685a9bb5c62ec07ece33709f057
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:d3fc052a8a913bafc9481780ebc7b3bf4d9ce685a9bb5c62ec07ece33709f057?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libpng/manifests/1.6.37
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libpng/blobs/sha256:aeb238f8b62e3e8923a032caf88152e287a4435ab4afd663fa98b4a57495d116
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:aeb238f8b62e3e8923a032caf88152e287a4435ab4afd663fa98b4a57495d116?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/bzip2/manifests/1.0.8-1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/bzip2/blobs/sha256:c9e18abf0be3de0f15101a7411aa05a65807b0f9c8f68d634b91e36b42570087
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:c9e18abf0be3de0f15101a7411aa05a65807b0f9c8f68d634b91e36b42570087?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/freetype/manifests/2.12.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/freetype/blobs/sha256:b9bf649c16033dc4fcea694384136f8ee13fe2f924b4a443b02fd7bab0ff368b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:b9bf649c16033dc4fcea694384136f8ee13fe2f924b4a443b02fd7bab0ff368b?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/util-linux/manifests/2.38
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/util-linux/blobs/sha256:f52e145ee56a685c717c6adc7db269b84f0ee7dcb01ff3d9d1f30f424e733ca5
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:f52e145ee56a685c717c6adc7db269b84f0ee7dcb01ff3d9d1f30f424e733ca5?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/fontconfig/manifests/2.14.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/fontconfig/blobs/sha256:1c1706b94f8b9408ce14a9880d67e9dbd22724b85f7ba9eb625c9d91fd43323f
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:1c1706b94f8b9408ce14a9880d67e9dbd22724b85f7ba9eb625c9d91fd43323f?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libpthread-stubs/manifests/0.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libpthread-stubs/blobs/sha256:06a9f3556eefaa9d243d18b484a38f89bcc999b84d3e9722ddf3645479bce44b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:06a9f3556eefaa9d243d18b484a38f89bcc999b84d3e9722ddf3645479bce44b?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/xorgproto/manifests/2021.5
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/xorgproto/blobs/sha256:97763c1171ba9dc0772b5fa107c8dad9b19c3e73963d84887fb2d8c02a1ab59e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:97763c1171ba9dc0772b5fa107c8dad9b19c3e73963d84887fb2d8c02a1ab59e?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxau/manifests/1.0.9
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxau/blobs/sha256:a7a733e5d4e05d82227129aadb680501e18ce206de6deaeca422d63b71d96307
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:a7a733e5d4e05d82227129aadb680501e18ce206de6deaeca422d63b71d96307?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxdmcp/manifests/1.1.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxdmcp/blobs/sha256:15c87cc0fddf3e002fc2d45104348d2499412261c0e9d6cad0ad5caa39455b4e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:15c87cc0fddf3e002fc2d45104348d2499412261c0e9d6cad0ad5caa39455b4e?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxcb/manifests/1.14_2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxcb/blobs/sha256:105c626775006b99f03f67dd80a0ec5ef84e9163353cd33a8b39193fdf231936
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:105c626775006b99f03f67dd80a0ec5ef84e9163353cd33a8b39193fdf231936?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libx11/manifests/1.7.5
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libx11/blobs/sha256:0ecf5a4ebc6f6e2153dd4883b3c24565f6db2d48667a2d3a71ee19ccd8d55dcb
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:0ecf5a4ebc6f6e2153dd4883b3c24565f6db2d48667a2d3a71ee19ccd8d55dcb?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxext/manifests/1.3.4
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxext/blobs/sha256:dc7d5b80cf1ac00d0ffff27be679d38c0b7c8e8ee8ceb1747bb1f8ac9e5773d0
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:dc7d5b80cf1ac00d0ffff27be679d38c0b7c8e8ee8ceb1747bb1f8ac9e5773d0?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxrender/manifests/0.9.10
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxrender/blobs/sha256:10b4f9c57a6af40dda0ca45ddecb325f9de9bee28959ed11fc0fa52d2accf562
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:10b4f9c57a6af40dda0ca45ddecb325f9de9bee28959ed11fc0fa52d2accf562?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxrandr/manifests/1.5.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxrandr/blobs/sha256:5eb9fe7c6e55b0f95bcb5448e956dbb761e3ec330f945c4cb0d48dee0089ece9
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:5eb9fe7c6e55b0f95bcb5448e956dbb761e3ec330f945c4cb0d48dee0089ece9?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libice/manifests/1.0.10
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libice/blobs/sha256:6a4f7025e876d05b0fef0d624f81336648dba225eb94754d42222bca47fa1452
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:6a4f7025e876d05b0fef0d624f81336648dba225eb94754d42222bca47fa1452?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libsm/manifests/1.2.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libsm/blobs/sha256:fd4bc0900857d6412c240c00aee8b50881cf102696e7e5756083e52e39b6f9e8
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:fd4bc0900857d6412c240c00aee8b50881cf102696e7e5756083e52e39b6f9e8?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxt/manifests/1.2.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxt/blobs/sha256:637ae200e0333076678621e5c5b330ca8ce5047534d5528f35bd7bfb59b3b630
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:637ae200e0333076678621e5c5b330ca8ce5047534d5528f35bd7bfb59b3b630?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxfixes/manifests/6.0.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxfixes/blobs/sha256:b10945be16e84b8e7cd08c600d64408e1332574f1fa8e33a44aadb3bf5e06d68
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:b10945be16e84b8e7cd08c600d64408e1332574f1fa8e33a44aadb3bf5e06d68?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxi/manifests/1.8
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxi/blobs/sha256:1026c8936f13ff85a1c93091cf37e488510361bdfb69d0c0ec15234a7d281ed5
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:1026c8936f13ff85a1c93091cf37e488510361bdfb69d0c0ec15234a7d281ed5?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxtst/manifests/1.2.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libxtst/blobs/sha256:81dadd1477613a046eca000b17f6c12850ca15769cb8556fff01b4c6d873379c
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:81dadd1477613a046eca000b17f6c12850ca15769cb8556fff01b4c6d873379c?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/unzip/manifests/6.0_7
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/unzip/blobs/sha256:f99196fb266de6a937959261b35f9b5e818455b7ca55d75d2818e7455781994b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:f99196fb266de6a937959261b35f9b5e818455b7ca55d75d2818e7455781994b?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zip/manifests/3.0-2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zip/blobs/sha256:ce503e630831ea12bb87e28c2668a185cb12a94680f4f42b791b6e4a19af2e87
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:ce503e630831ea12bb87e28c2668a185cb12a94680f4f42b791b6e4a19af2e87?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/11/manifests/11.0.14.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/11/blobs/sha256:b120010b4fee7bc6591ebf685ec01b53e6037dc3bf9de1caa3a6842bace48ae6
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:b120010b4fee7bc6591ebf685ec01b53e6037dc3bf9de1caa3a6842bace48ae6?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/sonar-scanner/manifests/4.7.0.2747
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/sonar-scanner/blobs/sha256:a1de3bfacf212710b3308cddc9ba286b2a80b7553fbc26340add77caa8335906
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:a1de3bfacf212710b3308cddc9ba286b2a80b7553fbc26340add77caa8335906?se=2022-04-20T15%3A55%3A00Z
######################################################################## 100.0%
==> Installing dependencies for sonar-scanner: alsa-lib, ca-certificates, openssl@1.1, m4, bison, ncurses, readline, zlib, libxml2, gettext, krb5, gmp, bdw-gc, libffi, libtool, libunistring, pkg-config, gperf, guile, libidn2, libtasn1, nettle, p11-kit, libevent, libnghttp2, expat, unbound, gnutls, cups, libpng, bzip2, freetype, util-linux, fontconfig, libpthread-stubs, xorgproto, libxau, libxdmcp, libxcb, libx11, libxext, libxrender, libxrandr, libice, libsm, libxt, libxfixes, libxi, libxtst, unzip, zip and openjdk@11
==> Installing sonar-scanner dependency: alsa-lib
==> Pouring alsa-lib--1.2.6.1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/alsa-lib/1.2.6.1: 143 files, 2.2MB
==> Installing sonar-scanner dependency: ca-certificates
==> Pouring ca-certificates--2022-03-29.all.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/ca-certificates/2022-03-29: 3 files, 227.1KB
==> Installing sonar-scanner dependency: openssl@1.1
==> Pouring openssl@1.1--1.1.1n.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/openssl@1.1/1.1.1n: 8,403 files, 24.3MB
==> Installing sonar-scanner dependency: m4
==> Pouring m4--1.4.19.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/m4/1.4.19: 39 files, 1.1MB
==> Installing sonar-scanner dependency: bison
==> Pouring bison--3.8.2.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/bison/3.8.2: 208 files, 5.0MB
==> Installing sonar-scanner dependency: ncurses
==> Pouring ncurses--6.3.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/ncurses/6.3: 3,958 files, 9.9MB
==> Installing sonar-scanner dependency: readline
==> Pouring readline--8.1.2.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/readline/8.1.2: 48 files, 2.0MB
==> Installing sonar-scanner dependency: zlib
==> Pouring zlib--1.2.11.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/zlib/1.2.11: 12 files, 453KB
==> Installing sonar-scanner dependency: libxml2
==> Pouring libxml2--2.9.13.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libxml2/2.9.13: 282 files, 11.9MB
==> Installing sonar-scanner dependency: gettext
==> Pouring gettext--0.21.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/gettext/0.21: 1,952 files, 21.5MB
==> Installing sonar-scanner dependency: krb5
==> Pouring krb5--1.19.3.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/krb5/1.19.3: 165 files, 5.2MB
==> Installing sonar-scanner dependency: gmp
==> Pouring gmp--6.2.1_1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/gmp/6.2.1_1: 23 files, 3.9MB
==> Installing sonar-scanner dependency: bdw-gc
==> Pouring bdw-gc--8.0.6.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/bdw-gc/8.0.6: 72 files, 1.8MB
==> Installing sonar-scanner dependency: libffi
==> Pouring libffi--3.4.2.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libffi/3.4.2: 18 files, 665.8KB
==> Installing sonar-scanner dependency: libtool
==> Pouring libtool--2.4.7.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libtool/2.4.7: 74 files, 3.8MB
==> Installing sonar-scanner dependency: libunistring
==> Pouring libunistring--1.0.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libunistring/1.0: 57 files, 5.5MB
==> Installing sonar-scanner dependency: pkg-config
==> Pouring pkg-config--0.29.2_3.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/pkg-config/0.29.2_3: 11 files, 744.4KB
==> Installing sonar-scanner dependency: gperf
==> Pouring gperf--3.1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/gperf/3.1: 11 files, 554.9KB
==> Installing sonar-scanner dependency: guile
==> Pouring guile--3.0.8.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/guile/3.0.8: 846 files, 69.6MB
==> Installing sonar-scanner dependency: libidn2
==> Pouring libidn2--2.3.2.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libidn2/2.3.2: 78 files, 1MB
==> Installing sonar-scanner dependency: libtasn1
==> Pouring libtasn1--4.18.0.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libtasn1/4.18.0: 62 files, 650.9KB
==> Installing sonar-scanner dependency: nettle
==> Pouring nettle--3.7.3.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/nettle/3.7.3: 88 files, 2.8MB
==> Installing sonar-scanner dependency: p11-kit
==> Pouring p11-kit--0.24.1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/p11-kit/0.24.1: 68 files, 4.9MB
==> Installing sonar-scanner dependency: libevent
==> Pouring libevent--2.1.12.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libevent/2.1.12: 62 files, 2.5MB
==> Installing sonar-scanner dependency: libnghttp2
==> Pouring libnghttp2--1.47.0.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libnghttp2/1.47.0: 14 files, 783.3KB
==> Installing sonar-scanner dependency: expat
==> Pouring expat--2.4.7.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/expat/2.4.7: 21 files, 840.3KB
==> Installing sonar-scanner dependency: unbound
==> Pouring unbound--1.15.0.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/unbound/1.15.0: 59 files, 11.1MB
==> Installing sonar-scanner dependency: gnutls
==> Pouring gnutls--3.7.4.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/gnutls/3.7.4: 1,288 files, 11.6MB
==> Installing sonar-scanner dependency: cups
==> Pouring cups--2.4.1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/cups/2.4.1: 121 files, 9.6MB
==> Installing sonar-scanner dependency: libpng
==> Pouring libpng--1.6.37.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libpng/1.6.37: 28 files, 1.4MB
==> Installing sonar-scanner dependency: bzip2
==> Pouring bzip2--1.0.8.x86_64_linux.bottle.1.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/bzip2/1.0.8: 30 files, 549.7KB
==> Installing sonar-scanner dependency: freetype
==> Pouring freetype--2.12.0.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/freetype/2.12.0: 68 files, 2.8MB
==> Installing sonar-scanner dependency: util-linux
==> Pouring util-linux--2.38.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/util-linux/2.38: 398 files, 20.2MB
==> Installing sonar-scanner dependency: fontconfig
==> Pouring fontconfig--2.14.0.x86_64_linux.bottle.tar.gz
==> Regenerating font cache, this may take a while
==> /home/linuxbrew/.linuxbrew/Cellar/fontconfig/2.14.0/bin/fc-cache -frv
🍺  /home/linuxbrew/.linuxbrew/Cellar/fontconfig/2.14.0: 87 files, 2.4MB
==> Installing sonar-scanner dependency: libpthread-stubs
==> Pouring libpthread-stubs--0.4.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libpthread-stubs/0.4: 5 files, 22.4KB
==> Installing sonar-scanner dependency: xorgproto
==> Pouring xorgproto--2021.5.all.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/xorgproto/2021.5: 264 files, 4.0MB
==> Installing sonar-scanner dependency: libxau
==> Pouring libxau--1.0.9.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libxau/1.0.9: 21 files, 131.9KB
==> Installing sonar-scanner dependency: libxdmcp
==> Pouring libxdmcp--1.1.3.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libxdmcp/1.1.3: 12 files, 136KB
==> Installing sonar-scanner dependency: libxcb
==> Pouring libxcb--1.14_2.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libxcb/1.14_2: 2,452 files, 6.7MB
==> Installing sonar-scanner dependency: libx11
==> Pouring libx11--1.7.5.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libx11/1.7.5: 1,062 files, 8MB
==> Installing sonar-scanner dependency: libxext
==> Pouring libxext--1.3.4.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libxext/1.3.4: 88 files, 488.7KB
==> Installing sonar-scanner dependency: libxrender
==> Pouring libxrender--0.9.10.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libxrender/0.9.10: 13 files, 209.9KB
==> Installing sonar-scanner dependency: libxrandr
==> Pouring libxrandr--1.5.2.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libxrandr/1.5.2: 27 files, 247.7KB
==> Installing sonar-scanner dependency: libice
==> Pouring libice--1.0.10.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libice/1.0.10: 17 files, 404.7KB
==> Installing sonar-scanner dependency: libsm
==> Pouring libsm--1.2.3.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libsm/1.2.3: 14 files, 196.7KB
==> Installing sonar-scanner dependency: libxt
==> Pouring libxt--1.2.1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libxt/1.2.1: 311 files, 2.0MB
==> Installing sonar-scanner dependency: libxfixes
==> Pouring libxfixes--6.0.0.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libxfixes/6.0.0: 13 files, 141.8KB
==> Installing sonar-scanner dependency: libxi
==> Pouring libxi--1.8.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libxi/1.8: 86 files, 773.2KB
==> Installing sonar-scanner dependency: libxtst
==> Pouring libxtst--1.2.3.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libxtst/1.2.3: 23 files, 161.5KB
==> Installing sonar-scanner dependency: unzip
==> Pouring unzip--6.0_7.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/unzip/6.0_7: 16 files, 576.5KB
==> Installing sonar-scanner dependency: zip
==> Pouring zip--3.0.x86_64_linux.bottle.2.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/zip/3.0: 14 files, 853.5KB
==> Installing sonar-scanner dependency: openjdk@11
==> Pouring openjdk@11--11.0.14.1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/openjdk@11/11.0.14.1: 670 files, 309MB
==> Installing sonar-scanner
==> Pouring sonar-scanner--4.7.0.2747.all.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/sonar-scanner/4.7.0.2747: 8 files, 679.1KB
==> Running `brew cleanup sonar-scanner`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

Verify

builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ which sonar-scanner
/home/linuxbrew/.linuxbrew/bin/sonar-scanner

We can generate test results locally:

builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ npm run testnyc

> nodewithtests@1.0.0 testnyc /home/builder/Workspaces/dockerWithTests2
> nyc --reporter=lcov --reporter=text-lcov mocha ./**/*.js



  Array
    #indexOf()
      ✔ should return -1 when the value is missing


  1 passing (3ms)

Now upload to sonar directly:

$ sonar-scanner -Dsonar.projectKey=dkrwtsts -Dsonar.sources=. -Dsonar.exclusions=**/node_modules/**,tests/** -Dsonar.host.ur
l=https://sonarqube.freshbrewed.science -Dsonar.login=18407a327a0148f4a8e33bbc3fff23a5 -Dsonar.tests=./tests -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
INFO: Scanner configuration file: /home/linuxbrew/.linuxbrew/Cellar/sonar-scanner/4.7.0.2747/libexec/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.7.0.2747
INFO: Java 11.0.14.1 Homebrew (64-bit)
INFO: Linux 5.10.60.1-microsoft-standard-WSL2 amd64
INFO: User cache: /home/builder/.sonar/cache
INFO: Scanner configuration file: /home/linuxbrew/.linuxbrew/Cellar/sonar-scanner/4.7.0.2747/libexec/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: Analyzing on SonarQube server 9.4.0
INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=99ms
INFO: Server id: EA8D9556-AYBG2PRTCtsqpeeU9sMB
INFO: User cache: /home/builder/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=45ms
INFO: Load/download plugins (done) | time=95ms
INFO: Process project properties
INFO: Process project properties (done) | time=7ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=0ms
INFO: Project key: dkrwtsts
INFO: Base dir: /home/builder/Workspaces/dockerWithTests2
INFO: Working dir: /home/builder/Workspaces/dockerWithTests2/.scannerwork
INFO: Load project settings for component key: 'dkrwtsts'
INFO: Load project settings for component key: 'dkrwtsts' (done) | time=34ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=86ms
INFO: Load active rules
INFO: Load active rules (done) | time=3260ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=22ms
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: **/node_modules/**, tests/**
INFO: 31 files indexed
INFO: 4864 files ignored because of inclusion/exclusion patterns
INFO: 9 files ignored because of scm ignore settings
INFO: Quality profile for js: Sonar way
INFO: Quality profile for json: Sonar way
INFO: Quality profile for web: Sonar way
INFO: Quality profile for yaml: Sonar way
INFO: ------------- Run sensors on module dkrwtsts
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=37ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=85ms
INFO: Sensor JavaScript analysis [javascript]
ERROR: Only Node.js v12 or later is supported, got 10.
org.sonarsource.nodejs.NodeCommandException: Only Node.js v12 or later is supported, got 10.
        at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:171)
        at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:142)
        at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.initNodeCommand(EslintBridgeServerImpl.java:183)
        at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServer(EslintBridgeServerImpl.java:128)
        at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServerLazily(EslintBridgeServerImpl.java:212)
        at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:66)
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:81)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
        at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:392)
        at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:388)
        at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:357)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
        at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:134)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        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:189)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)

INFO: Sensor JavaScript analysis [javascript] (done) | time=889ms
INFO: Sensor TypeScript analysis [javascript]
INFO: No input files found for analysis
INFO: Sensor TypeScript analysis [javascript] (done) | time=1ms
INFO: Sensor JavaScript/TypeScript Coverage [javascript]
INFO: Analysing [/home/builder/Workspaces/dockerWithTests2/coverage/lcov.info]
INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=3ms
INFO: Sensor CSS Rules [javascript]
INFO: Sensor CSS Rules [javascript] (done) | time=1ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
INFO: Sensor C# Analysis Log [csharp]
INFO: Sensor C# Analysis Log [csharp] (done) | time=9ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=64ms
INFO: Sensor Text Sensor [text]
INFO: 18 source files to be analyzed
INFO: 18/18 source files have been analyzed
INFO: Sensor Text Sensor [text] (done) | time=17ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms
INFO: Sensor VB.NET Analysis Log [vbnet]
INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=12ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=0ms
INFO: SCM Publisher SCM provider for this project is: git
INFO: SCM Publisher 3 source files to be analyzed
INFO: SCM Publisher 2/3 source files have been analyzed (done) | time=90ms
WARN: Missing blame information for the following files:
WARN:   * mochawesome-report/mochawesome.html
WARN: This may lead to missing/broken features in SonarQube
INFO: CPD Executor 1 file had no CPD blocks
INFO: CPD Executor Calculating CPD for 0 files
INFO: CPD Executor CPD calculation finished (done) | time=0ms
INFO: Analysis report generated in 47ms, dir size=118.5 kB
INFO: Analysis report compressed in 13ms, zip size=16.7 kB
INFO: Analysis report uploaded in 68ms
INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarqube.freshbrewed.science/dashboard?id=dkrwtsts
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://sonarqube.freshbrewed.science/api/ce/task?id=AYBHsxhICtsqpeeU9xkV
INFO: Analysis total time: 6.913 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 7.986s
INFO: Final Memory: 16M/88M
INFO: ------------------------------------------------------------------------

We now see results:

/content/images/2022/04/dockertests3-11.png

and while there were no bugs

/content/images/2022/04/dockertests3-12.png

there were some warnings

/content/images/2022/04/dockertests3-13.png

We can try building with Node 12.

builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ nvm list
->     v10.22.1
       v14.18.1
        v17.6.0
default -> 10.22.1 (-> v10.22.1)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v17.6.0) (default)
stable -> 17.6 (-> v17.6.0) (default)
lts/* -> lts/gallium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.11 (-> N/A)
lts/fermium -> v14.19.1 (-> N/A)
lts/gallium -> v16.14.2 (-> N/A)
builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ nvm install 12.22.11
Downloading and installing node v12.22.11...
Downloading https://nodejs.org/dist/v12.22.11/node-v12.22.11-linux-x64.tar.xz...
########################################################################################################################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v12.22.11 (npm v6.14.16)
builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ nvm use 12.22.11
Now using node v12.22.11 (npm v6.14.16)

builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ npm install
npm WARN nodewithtests@1.0.0 No description
npm WARN nodewithtests@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 362 packages in 1.419s

37 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ npm run testnyc

> nodewithtests@1.0.0 testnyc /home/builder/Workspaces/dockerWithTests2
> nyc --reporter=lcov --reporter=text-lcov mocha ./**/*.js



  Array
    #indexOf()
      ✔ should return -1 when the value is missing


  1 passing (3ms)

I’ll run the same upload command again

builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ sonar-scanner -Dsonar.projectKey=dkrwtsts -Dsonar.sources=. -Dsonar.exclusions=**/node_modules/**,tests/** -Dsonar.host.url=https://sonarqube.freshbrewed.science -Dsonar.login=18407a327a0148f4a8e33bbc3fff23a5 -Dsonar.tests=./tests -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
INFO: Scanner configuration file: /home/linuxbrew/.linuxbrew/Cellar/sonar-scanner/4.7.0.2747/libexec/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.7.0.2747
INFO: Java 11.0.14.1 Homebrew (64-bit)
INFO: Linux 5.10.60.1-microsoft-standard-WSL2 amd64
INFO: User cache: /home/builder/.sonar/cache
INFO: Scanner configuration file: /home/linuxbrew/.linuxbrew/Cellar/sonar-scanner/4.7.0.2747/libexec/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: Analyzing on SonarQube server 9.4.0
INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=92ms
INFO: Server id: EA8D9556-AYBG2PRTCtsqpeeU9sMB
INFO: User cache: /home/builder/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=50ms
INFO: Load/download plugins (done) | time=99ms
INFO: Process project properties
INFO: Process project properties (done) | time=7ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=1ms
INFO: Project key: dkrwtsts
INFO: Base dir: /home/builder/Workspaces/dockerWithTests2
INFO: Working dir: /home/builder/Workspaces/dockerWithTests2/.scannerwork
INFO: Load project settings for component key: 'dkrwtsts'
INFO: Load project settings for component key: 'dkrwtsts' (done) | time=32ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=74ms
INFO: Load active rules
INFO: Load active rules (done) | time=3529ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=32ms
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: **/node_modules/**, tests/**
INFO: 31 files indexed
INFO: 4864 files ignored because of inclusion/exclusion patterns
INFO: 9 files ignored because of scm ignore settings
INFO: Quality profile for js: Sonar way
INFO: Quality profile for json: Sonar way
INFO: Quality profile for web: Sonar way
INFO: Quality profile for yaml: Sonar way
INFO: ------------- Run sensors on module dkrwtsts
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=37ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=93ms
INFO: Sensor JavaScript analysis [javascript]
WARN: Using Node.js version 12 to execute analysis is deprecated and will stop being supported no earlier than August 1st, 2022. Please upgrade to a newer LTS version of Node.js [14, 16]
INFO: 2 source files to be analyzed
INFO: 2/2 source files have been analyzed
INFO: Sensor JavaScript analysis [javascript] (done) | time=2489ms
INFO: Sensor TypeScript analysis [javascript]
INFO: No input files found for analysis
INFO: Sensor TypeScript analysis [javascript] (done) | time=1ms
INFO: Sensor JavaScript/TypeScript Coverage [javascript]
INFO: Analysing [/home/builder/Workspaces/dockerWithTests2/coverage/lcov.info]
INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=2ms
INFO: Sensor CSS Rules [javascript]
INFO: 1 source file to be analyzed
INFO: 1/1 source file has been analyzed
INFO: Sensor CSS Rules [javascript] (done) | time=77ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
INFO: Sensor C# Analysis Log [csharp]
INFO: Sensor C# Analysis Log [csharp] (done) | time=9ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=34ms
INFO: Sensor Text Sensor [text]
INFO: 18 source files to be analyzed
INFO: 18/18 source files have been analyzed
INFO: Sensor Text Sensor [text] (done) | time=13ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms
INFO: Sensor VB.NET Analysis Log [vbnet]
INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=9ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=7ms
INFO: SCM Publisher SCM provider for this project is: git
INFO: SCM Publisher 1 source file to be analyzed
INFO: SCM Publisher 0/1 source files have been analyzed (done) | time=35ms
WARN: Missing blame information for the following files:
WARN:   * mochawesome-report/mochawesome.html
WARN: This may lead to missing/broken features in SonarQube
INFO: CPD Executor 2 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 0 files
INFO: CPD Executor CPD calculation finished (done) | time=0ms
INFO: Analysis report generated in 46ms, dir size=119.0 kB
INFO: Analysis report compressed in 19ms, zip size=17.8 kB
INFO: Analysis report uploaded in 39ms
INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarqube.freshbrewed.science/dashboard?id=dkrwtsts
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://sonarqube.freshbrewed.science/api/ce/task?id=AYBHuDG0CtsqpeeU9xkW
INFO: Analysis total time: 13.659 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 14.719s
INFO: Final Memory: 17M/94M
INFO: ------------------------------------------------------------------------

we can now see blame results

/content/images/2022/04/dockertests3-14.png

This shows my tests all pass, but i have zero code coverage.

/content/images/2022/04/dockertests3-15.png

Dockerizing Sonarscan

Trying to bundle into Docker

builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ cat sonar-scanner.properties
sonar.projectKey=dkrwtsts
sonar.sources=.
sonar.exclusions=**/node_modules/**,tests/**
sonar.host.url=https://sonarqube.freshbrewed.science
sonar.login=18407a327a0148f4a8e33bbc3fff23a5
sonar.tests=./tests
sonar.javascript.lcov.reportPaths=coverage/lcov.info
builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ cat Dockerfile
FROM node:17.6.0 as base

WORKDIR /code

COPY package.json package.json
COPY package-lock.json package-lock.json

FROM base as test
RUN curl -s -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip -o sonarscanner.zip \
  && unzip -qq sonarscanner.zip \
  && rm -rf sonarscanner.zip \
  && mv sonar-scanner-4.7.0.2747-linux sonar-scanner
COPY sonar-scanner.properties sonar-scanner/conf/sonar-scanner.properties
ENV SONAR_RUNNER_HOME=sonar-scanner
ENV PATH $PATH:sonar-scanner/bin

RUN npm ci
COPY . .
RUN npm run testnyc

CMD sonar-scanner -Dsonar.settings=sonar-scanner/conf/sonar-scanner.properties

FROM base as prod
ENV NODE_ENV=production
RUN npm ci --production
COPY . .
CMD [ "node", "server.js" ]

We can see it run now

$ docker build -t testinglocal --target test .

/content/images/2022/04/dockertests3-16.png

builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ docker build -t testinglocal --target test .
[+] Building 62.2s (16/16) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                        0.0s
 => => transferring dockerfile: 899B                                                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/node:17.6.0                                                                                                             17.6s
 => [auth] library/node:pull token for registry-1.docker.io                                                                                                                 0.0s
 => [internal] load build context                                                                                                                                           0.9s
 => => transferring context: 171.76MB                                                                                                                                       0.9s
 => [base 1/4] FROM docker.io/library/node:17.6.0@sha256:08e37ce0636ad9796900a180f2539f3110648e4f2c1b541bc0d4d3039e6b3251                                                   0.0s
 => CACHED [base 2/4] WORKDIR /code                                                                                                                                         0.0s
 => CACHED [base 3/4] COPY package.json package.json                                                                                                                        0.0s
 => CACHED [base 4/4] COPY package-lock.json package-lock.json                                                                                                              0.0s
 => CACHED [test 1/6] RUN curl -s -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip -o sonarscanner.zip   && unzip  0.0s
 => CACHED [test 2/6] COPY sonar-scanner.properties sonar-scanner/conf/sonar-scanner.properties                                                                             0.0s
 => [test 3/6] RUN npm ci                                                                                                                                                   8.1s
 => [test 4/6] COPY . .                                                                                                                                                     0.8s
 => [test 5/6] RUN npm run testnyc                                                                                                                                          1.0s
 => [test 6/6] RUN sonar-scanner -Dsonar.settings=sonar-scanner/conf/sonar-scanner.properties                                                                              32.7s
 => exporting to image                                                                                                                                                      1.0s
 => => exporting layers                                                                                                                                                     1.0s
 => => writing image sha256:b454fef365fcf997097b6682e815bedb8660511bf9906dcb6e0bebb5730fcf01                                                                                0.0s
 => => naming to docker.io/library/testinglocal

And I can see it uploaded results

/content/images/2022/04/dockertests3-17.png

Adding coverage

We may have some challenges writing proper unit tests around Ronin (it can run unit tests, but not test itself, at least as far as I was able to work out in a few days)

What I did instead was assumed our app would likely add some usable functionality and that would be the thing worth testing.

I installed a few libraries. In the end I didn’t use jest.

npm install jest --save-dev
npm i @babel/cli @babel/register babel-plugin-istanbul @babel/preset-env cross-env mocha chai nyc --save-dev

I created an index.js we could use to serve a webapp: index.js

const http = require('http')
const qs = require('querystring')
const calculator = require('./calculator')

const server = http.createServer(function(request, response) {
  console.dir(request.param)

  if (request.method == 'POST') {
    console.log('POST')
    var body = ''
    request.on('data', function(data) {
      body += data
    })

    request.on('end', function() {
      const post = qs.parse(body)
      const numbers = post.numbers
      const result = calculator.add(numbers)
      response.writeHead(200, {'Content-Type': 'text/html'})
      response.end('Result: ' + result)
    })
  } else {
    var html = `
            &lt;html&gt;
                &lt;body&gt;
                    &lt;form method="post" action="http://localhost:3000"&gt;Numbers:
                        &lt;input type="text" name="numbers" /&gt;
                        &lt;input type="submit" value="Add" /&gt;
                    &lt;/form&gt;
                &lt;/body&gt;
            &lt;/html&gt;`
    response.writeHead(200, {'Content-Type': 'text/html'})
    response.end(html)
  }
})

const port = 3000
const host = '127.0.0.1'
server.listen(port, host)
console.log(`Listening at http://${host}:${port}`)

I then created a calculator app: calculator.js

function add(numbers) {
	    return numbers
	        .split(',')
	        .map(x => parseInt(x))
	        .reduce((a, b) => a + b)
}

exports.add = add;

Then I wrote a test to use it: tests/calc.js

import CoverageBabel from '../calculator'

require('chai').should()

describe('CoverageBabel', function () {
  it('string with a single number should result in the number itself', function () {
    CoverageBabel.add('1').should.equal(1)
  })
})

I needed to update the “nyc” block and “files” block to my package.json. Which made the package.json look like this:

{
  "name": "nodewithtests",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test2": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha tests/calc.js",
    "test": "mocha ./**/*.js",
    "start": "nodemon --inspect=0.0.0.0:9229 server.js",
    "testawesome": "mocha --reporter mochawesome ./**/*.js",
    "testnyc": "nyc --reporter=lcov --reporter=text-lcov mocha ./**/*.js"
  },
  "keywords": [
    "nodejs"
  ],
  "author": "Isaac Johnson",
  "license": "MIT",
  "devDependencies": {
    "@babel/cli": "^7.17.6",
    "@babel/preset-env": "^7.16.11",
    "@babel/register": "^7.17.7",
    "babel-plugin-istanbul": "^6.1.1",
    "chai": "^4.3.6",
    "cross-env": "^7.0.3",
    "expect.js": "^0.3.1",
    "jest": "^28.0.2",
    "mocha": "^9.2.2",
    "nyc": "^15.1.0"
  },
  "dependencies": {
    "mochawesome": "^7.1.3",
    "ronin-mocks": "^0.1.6",
    "ronin-server": "^0.1.3"
  },
  "nyc": {
    "require": [
      "@babel/register"
    ],
    "reporter": [
      "lcov",
      "text"
    ],
    "sourceMap": false,
    "instrument": true
  },
  "files": [
    "calculator.js"
  ]
}

You can see the new command added to package.json above “test2”

    "test2": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha tests/calc.js",

And I changed line 22 to use “test2” instead of testnyc in my testing steps in the Dockerfile

FROM node:17.6.0 as base

WORKDIR /code

COPY package.json package.json
COPY package-lock.json package-lock.json

FROM base as test
RUN curl -s -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip -o sonarscanner.zip \
  && unzip -qq sonarscanner.zip \
  && rm -rf sonarscanner.zip \
  && mv sonar-scanner-4.7.0.2747-linux sonar-scanner
COPY sonar-scanner.properties sonar-scanner/conf/sonar-scanner.properties
ENV SONAR_RUNNER_HOME=sonar-scanner
ENV PATH $PATH:sonar-scanner/bin
# RUN sed -i 's/use_embedded_jre=true/use_embedded_jre=false/g' sonar-scanner/bin/sonar-scanner

RUN npm ci
COPY . .
COPY .git .git
RUN npm run test2

RUN sonar-scanner -Dsonar.settings=sonar-scanner/conf/sonar-scanner.properties

FROM base as prod
ENV NODE_ENV=production
RUN npm ci --production
COPY . .
CMD [ "node", "server.js" ]

Testing locally

we can now see if we run test2 locally we can get coverage results:

builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ npm run test2

> nodewithtests@1.0.0 test2 /home/builder/Workspaces/dockerWithTests2
> cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha tests/calc.js



  CoverageBabel
    ✔ string with a single number should result in the number itself


  1 passing (3ms)

---------------|---------|----------|---------|---------|-------------------
File           | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|-------------------
All files      |      75 |      100 |   66.66 |      75 |
 calculator.js |      75 |      100 |   66.66 |      75 | 5
---------------|---------|----------|---------|---------|-------------------

this generated the lcov results

builder@DESKTOP-QADGF36:~/Workspaces/dockerWithTests2$ cat coverage/lcov.info
TN:
SF:calculator.js
FN:1,add
FN:4,(anonymous_1)
FN:5,(anonymous_2)
FNF:3
FNH:2
FNDA:1,add
FNDA:1,(anonymous_1)
FNDA:0,(anonymous_2)
DA:2,1
DA:4,1
DA:5,0
DA:8,1
LF:4
LH:3
BRF:0
BRH:0
end_of_record

There is also an HTML file we can view locally:

/content/images/2022/04/dockertests3-18.png

Now if we docker build we should expect to see results publish to Sonarqube

$ docker build -t testinglocal --target test .
[+] Building 72.5s (16/16) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                        0.0s
 => => transferring dockerfile: 38B                                                                                                                                         0.0s
 => [internal] load .dockerignore                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/node:17.6.0                                                                                                             15.7s
 => [base 1/4] FROM docker.io/library/node:17.6.0@sha256:08e37ce0636ad9796900a180f2539f3110648e4f2c1b541bc0d4d3039e6b3251                                                   0.0s
 => [internal] load build context                                                                                                                                           0.3s
 => => transferring context: 695.65kB                                                                                                                                       0.3s
 => CACHED [base 2/4] WORKDIR /code                                                                                                                                         0.0s
 => [base 3/4] COPY package.json package.json                                                                                                                               0.0s
 => [base 4/4] COPY package-lock.json package-lock.json                                                                                                                     0.0s
 => [test 1/7] RUN curl -s -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip -o sonarscanner.zip   && unzip -qq so  2.8s
 => [test 2/7] COPY sonar-scanner.properties sonar-scanner/conf/sonar-scanner.properties                                                                                    0.0s
 => [test 3/7] RUN npm ci                                                                                                                                                  14.6s
 => [test 4/7] COPY . .                                                                                                                                                     2.7s
 => [test 5/7] COPY .git .git                                                                                                                                               0.1s
 => [test 6/7] RUN npm run test2                                                                                                                                            2.1s
 => [test 7/7] RUN sonar-scanner -Dsonar.settings=sonar-scanner/conf/sonar-scanner.properties                                                                              32.9s
 => exporting to image                                                                                                                                                      1.3s
 => => exporting layers                                                                                                                                                     1.3s
 => => writing image sha256:be232f9d9f00e4d59015faee3ccde8982e2b2c852c11b2f30a11bd30544cc24e                                                                                0.0s
 => => naming to docker.io/library/testinglocal

/content/images/2022/04/dockertests3-19.png

We can see it “failed” because our coverage is under the required 80% threshold.

Clicking the project shows details:

/content/images/2022/04/dockertests3-20.png

Moreover, if we dig into the details by clicking the large “10.71%” near the bottom, we see it’s the lack of coverage on our server (server.js and index.js) that really brings the coverage percentage down

/content/images/2022/04/dockertests3-21.png

Now we can get clever and test by asking Sonar, after the run, what the results are:

$ curl -u 18407a327a0148f4a8e33bbc3fff23a5: https://sonarqube.freshbrewed.science/api/project_analyses/search?project=dkrwtsts | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   932  100   932    0     0   7338      0 --:--:-- --:--:-- --:--:--  7338
{
  "paging": {
    "pageIndex": 1,
    "pageSize": 100,
    "total": 3
  },
  "analyses": [
    {
      "key": "AYBq0ZhKM3dkp6CaQA1u",
      "date": "2022-04-27T11:38:55+0000",
      "events": [
        {
          "key": "AYBq0Z5IM3dkp6CaQA7B",
          "category": "QUALITY_GATE",
          "name": "Failed",
          "description": "Coverage on New Code < 80"
        },
        {
          "key": "AYBq0Z5LM3dkp6CaQA7C",
          "category": "VERSION",
          "name": "not provided"
        }
      ],
      "projectVersion": "not provided",
      "manualNewCodePeriodBaseline": false,
      "revision": "7493cfd6e93408629103c60d6b62e0e3b361a900",
      "detectedCI": "undetected"
    },
    {
      "key": "AYBJcI9oM3dkp6CaQAwn",
      "date": "2022-04-21T00:05:39+0000",
      "events": [],
      "projectVersion": "not provided",
      "manualNewCodePeriodBaseline": false,
      "revision": "d79ce4e1ccc143a30ad5826ae60121130c73bced",
      "detectedCI": "undetected"
    },
    {
      "key": "AYBJa0G4M3dkp6CaQAmS",
      "date": "2022-04-20T23:59:52+0000",
      "events": [],
      "projectVersion": "not provided",
      "manualNewCodePeriodBaseline": false,
      "revision": "d79ce4e1ccc143a30ad5826ae60121130c73bced",
      "detectedCI": "undetected"
    }
  ]
}

Which we could easily parse with JQ:

$ curl --silent -u 18407a327a0148f4a8e33bbc3fff23a5: https://sonarqube.freshbrewed.science/api/project_analyses/search?project=dkrwtsts | jq -r '.analyses[].events[] | select(.category=="QUALITY_GATE") | .name'
Failed

This means we could integrate it in our Dockerfile builds:

$ cat Dockerfile
FROM node:17.6.0 as base

WORKDIR /code

COPY package.json package.json
COPY package-lock.json package-lock.json

FROM base as test
RUN curl -s -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip -o sonarscanner.zip \
  && unzip -qq sonarscanner.zip \
  && rm -rf sonarscanner.zip \
  && mv sonar-scanner-4.7.0.2747-linux sonar-scanner
COPY sonar-scanner.properties sonar-scanner/conf/sonar-scanner.properties
ENV SONAR_RUNNER_HOME=sonar-scanner
ENV PATH $PATH:sonar-scanner/bin
# RUN sed -i 's/use_embedded_jre=true/use_embedded_jre=false/g' sonar-scanner/bin/sonar-scanner

RUN npm ci
COPY . .
COPY .git .git
RUN npm run test2

RUN sonar-scanner -Dsonar.settings=sonar-scanner/conf/sonar-scanner.properties

RUN apt update && apt install -y jq
RUN curl --silent -u 18407a327a0148f4a8e33bbc3fff23a5: https://sonarqube.freshbrewed.science/api/project_analyses/search?project=dkrwtsts | jq -r '.analyses[].events[] | select(.category=="QUALITY_GATE") | .name' | head -n1 > results
RUN grep -q "Failed" output; [ $? -eq 0 ] && exit 1 || true


FROM base as prod
ENV NODE_ENV=production
RUN npm ci --production
COPY . .
CMD [ "node", "server.js" ]

Essentially we run the scan, publish to Sonarqube that will determine the results and kill the build before an image is made if we are in a failed state.

We could also write the check in the inverse:

RUN curl --silent -u 18407a327a0148f4a8e33bbc3fff23a5: https://sonarqube.freshbrewed.science/api/project_analyses/search?project=dkrwtsts | jq -r '.analyses[].events[] | select(.category=="QUALITY_GATE") | .name' | head -n1 > results
RUN grep -q "Passed" output; exit $?

Limitations and next steps

The truth here is we are working around some of the limitations of the community Sonarqube edition. The more proper way, and the way I have implemented sonar gates is during PR checks. This is a feature of the dev and enterprise editions of Sonar

/content/images/2022/04/dockertests3-22.png

The other condition here is that we are asking for the last scan published against main, not necessarily this scan.

We could do some math and parse the local lcov results, however that would negate the remotely managed gate in our Sonarqube instance (that is, I move the required “level” into a hardcoded value in git).

If we are building main after PRs this might not be an issue (as we would expect less main based builds).

To force a pass, I created a lower quality gate

/content/images/2022/04/dockertests3-23.png

then under Project settings/Quality Gate

/content/images/2022/04/dockertests3-24.png

I changed to the newly defined lowerquality gate

/content/images/2022/04/dockertests3-25.png

And lastly, forced a push locally

$ sonar-scanner -Dsonar.projectKey=dkrwtsts -Dsonar.sources=. -Dsonar.exclusions=**/node_modules/**,tests/** -Dsonar.host.url=https://sonarqube.freshbrewed.science -Dsonar.login=18407a327a0148f4a8e33bbc3fff23a5 -Dsonar.tests=./tests -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
INFO: Scanner configuration file: /home/linuxbrew/.linuxbrew/Cellar/sonar-scanner/4.7.0.2747/libexec/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.7.0.2747
INFO: Java 11.0.14.1 Homebrew (64-bit)
INFO: Linux 5.10.60.1-microsoft-standard-WSL2 amd64
INFO: User cache: /home/builder/.sonar/cache
INFO: Scanner configuration file: /home/linuxbrew/.linuxbrew/Cellar/sonar-scanner/4.7.0.2747/libexec/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: Analyzing on SonarQube server 9.4.0
INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=101ms
INFO: Server id: EA8D9556-AYBG2PRTCtsqpeeU9sMB
INFO: User cache: /home/builder/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=51ms
INFO: Load/download plugins (done) | time=141ms
INFO: Process project properties
INFO: Process project properties (done) | time=8ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=2ms
INFO: Project key: dkrwtsts
INFO: Base dir: /home/builder/Workspaces/dockerWithTests2
INFO: Working dir: /home/builder/Workspaces/dockerWithTests2/.scannerwork
INFO: Load project settings for component key: 'dkrwtsts'
INFO: Load project settings for component key: 'dkrwtsts' (done) | time=27ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=77ms
INFO: Load active rules
INFO: Load active rules (done) | time=1335ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=24ms
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: **/node_modules/**, tests/**
INFO: 293 files indexed
INFO: 7818 files ignored because of inclusion/exclusion patterns
INFO: 23 files ignored because of scm ignore settings
INFO: Quality profile for js: Sonar way
INFO: Quality profile for json: Sonar way
INFO: Quality profile for yaml: Sonar way
INFO: ------------- Run sensors on module dkrwtsts
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=29ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=4ms
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=118ms
INFO: Sensor JavaScript analysis [javascript]
WARN: Using Node.js version 12 to execute analysis is deprecated and will stop being supported no earlier than August 1st, 2022. Please upgrade to a newer LTS version of Node.js [14, 16]
INFO: 5 source files to be analyzed
INFO: 5/5 source files have been analyzed
INFO: Sensor JavaScript analysis [javascript] (done) | time=3726ms
INFO: Sensor TypeScript analysis [javascript]
INFO: No input files found for analysis
INFO: Sensor TypeScript analysis [javascript] (done) | time=2ms
INFO: Sensor JavaScript/TypeScript Coverage [javascript]
INFO: Analysing [/home/builder/Workspaces/dockerWithTests2/coverage/lcov.info]
INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=15ms
INFO: Sensor CSS Rules [javascript]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor CSS Rules [javascript] (done) | time=0ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
INFO: Sensor C# Analysis Log [csharp]
INFO: Sensor C# Analysis Log [csharp] (done) | time=12ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=2ms
INFO: Sensor Text Sensor [text]
INFO: 19 source files to be analyzed
INFO: 19/19 source files have been analyzed
INFO: Sensor Text Sensor [text] (done) | time=18ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms
INFO: Sensor VB.NET Analysis Log [vbnet]
INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=10ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=1ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=5ms
INFO: SCM Publisher SCM provider for this project is: git
INFO: SCM Publisher 3 source files to be analyzed
INFO: SCM Publisher 0/3 source files have been analyzed (done) | time=39ms
WARN: Missing blame information for the following files:
WARN:   * calculator.js
WARN:   * index.js
WARN:   * tests/calc.js
WARN: This may lead to missing/broken features in SonarQube
INFO: CPD Executor 2 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 1 file
INFO: CPD Executor CPD calculation finished (done) | time=6ms
INFO: Analysis report generated in 46ms, dir size=118.0 kB
INFO: Analysis report compressed in 31ms, zip size=20.3 kB
INFO: Analysis report uploaded in 36ms
INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarqube.freshbrewed.science/dashboard?id=dkrwtsts
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://sonarqube.freshbrewed.science/api/ce/task?id=AYBrH2vrCtsqpeeU9xkq
INFO: Analysis total time: 12.871 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 14.194s
INFO: Final Memory: 17M/88M
INFO: ------------------------------------------------------------------------

which sets it passed

/content/images/2022/04/dockertests3-26.png

Summary

We setup up the free Sonarqube community edition in our cluster and used it to publish unit test results. We then integrated the scan into the Docker build itself and published inline. Wanted to see coverage we created a new small calculator app and setup mocha with cross-env to created lcov results to upload to Sonarqube. Lastly, we added a step to check for Failed scans during the build and stop Docker builds if coverage did not meet the active gate.

We covered some limitations above and know that if we wanted to really productize this in an organization, it would make more sense to buy the commercial product with PR support.

That said, we’ve now externalized our Unit Test and Coverage results into a persistent system. This can be useful for PjM or Leads to ensure the quality of coverage that tests are passing without needed to parse build logs or access CICD systems like Azure DevOps or Jenkins.

docker containers github hookdeck acr azure

Have something to add? Feedback? Try our new forums

Isaac Johnson

Isaac Johnson

Cloud Solutions Architect

Isaac is a CSA and DevOps engineer who focuses on cloud migrations and devops processes. He also is a dad to three wonderful daughters (hence the references to Princess King sprinkled throughout the blog).

Theme built by C.S. Rhymes