{"id":28365924,"url":"https://github.com/cnescatlab/sonar-scanner-catlab","last_synced_at":"2025-10-11T15:44:23.360Z","repository":{"id":47058276,"uuid":"283153394","full_name":"cnescatlab/sonar-scanner-catlab","owner":"cnescatlab","description":"Docker environment containing open source code analysis tools configured by CNES and dedicated to Continuous Integration.","archived":false,"fork":false,"pushed_at":"2024-10-03T08:35:49.000Z","size":167,"stargazers_count":6,"open_issues_count":6,"forks_count":4,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-08-10T14:24:00.836Z","etag":null,"topics":["ci","cnes","docker","software-factory","sonarqube"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/lequal/sonar-scanner","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cnescatlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-28T08:42:52.000Z","updated_at":"2025-08-08T12:56:50.000Z","dependencies_parsed_at":"2024-05-02T10:43:47.016Z","dependency_job_id":"56ab3c54-e7fb-41a0-947e-a627634ae27f","html_url":"https://github.com/cnescatlab/sonar-scanner-catlab","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/cnescatlab/sonar-scanner-catlab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnescatlab%2Fsonar-scanner-catlab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnescatlab%2Fsonar-scanner-catlab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnescatlab%2Fsonar-scanner-catlab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnescatlab%2Fsonar-scanner-catlab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnescatlab","download_url":"https://codeload.github.com/cnescatlab/sonar-scanner-catlab/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnescatlab%2Fsonar-scanner-catlab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007627,"owners_count":26084336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","cnes","docker","software-factory","sonarqube"],"created_at":"2025-05-28T23:06:24.382Z","updated_at":"2025-10-11T15:44:23.342Z","avatar_url":"https://github.com/cnescatlab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CNES sonar-scanner-catlab image\n\n![CI badge](https://github.com/cnescatlab/sonar-scanner/workflows/CI/badge.svg) ![CD badge](https://github.com/cnescatlab/sonar-scanner/workflows/CD/badge.svg)\n\n\u003e Docker environment containing open source code analysis tools configured by CNES and dedicated to Continuous Integration.\n\nThis image is a pre-configured sonar-scanner image derived from [Docker-CAT](https://github.com/cnescatlab/docker-cat). It contains the same tools for code analysis and it is available on Docker Hub at [lequal/sonar-scanner](https://hub.docker.com/r/lequal/sonar-scanner-catlab/).\n\nSonarQube itself is an opensource project on GitHub: [SonarSource/sonarqube](https://github.com/SonarSource/sonarqube).\n\nFor versions and changelog: [GitHub Releases](https://github.com/cnescatlab/sonar-scanner-catlab/releases).\n\n:information_source: If you only need a containerized `sonar-scanner`, you better use the official image from SonarSource available on Docker Hub: [sonarsource/sonar-scanner-cli](https://hub.docker.com/r/sonarsource/sonar-scanner-cli). The official image is smaller because it does not embed any other tool.\n\n## Features\n\nCompared to the official [sonarsource/sonar-scanner-cli](https://hub.docker.com/r/sonarsource/sonar-scanner-cli) image, this image provides additional features.\n\nAdditional features are:\n\n- Embedded tools\n  - see the [list](#analysis-tools-included)\n- Configuration files\n  - [pylintrc](#how-to-use-embedded-cnes-pylintrc)\n\n_This image is made to be used in conjunction with a pre-configured SonarQube server image that embeds all necessary plugins and configuration: [cnescatlab/sonarqube](https://github.com/cnescatlab/sonarqube-catlab). It is, however, not mandatory to use it._\n\n## User guide\n\n1. Write a `sonar-project.properties` at the root of your project\n   - For information on what to write in it, see the [official SonarQube documentation](https://docs.sonarqube.org/sonarqube/9.9/)\n2. Execute the sonar-scanner on the project by running this image from the root of the project\n\n   ```sh\n   $ docker run \\\n           --rm \\\n           -u \"$(id -u):$(id -g)\" \\\n           -e SONAR_HOST_URL=\"url of your SonarQube instance\" \\\n           -v \"$(pwd):/usr/src\" \\\n           lequal/sonar-scanner\n   ```\n\n   This docker command is equivalent to `sonar-scanner -Dsonar.host.url=\"url of your SonarQube instance\"`.\n   - If the SonarQube server is running in a container on the same computer, you will need to connect both containers (server and client) to the same bridge so that they can communicate. To do so:\n\n     ```sh\n     $ docker network create -d bridge sonarbridge\n     $ docker network connect sonarbridge \"name of your sonarqube container\"\n     # add the following option to the command line when running the lequal/sonar-scanner\n     --net sonarbridge\n     ```\n\nThis image suffers from the same limitations as the official SonarQube [sonarsource/sonar-scanner-cli](https://hub.docker.com/r/sonarsource/sonar-scanner-cli) image.\n\n- If you need to analyze .NET projects, you must use the SonarScanner for MSBuild.\n- If you want to save the sonar-scanner cache, you must create the directory to bind mount in the container before running it. For more information, see [SonarQube documentation](https://docs.sonarqube.org/sonarqube/9.9/).\n\n### How to use embedded tools\n\nNot only does this image provide a sonar-scanner, but also a set of open source code analysis tools. All available tools are listed [below](#analysis-tools-included). They can be used from the image by changing the arguments of the container when running one.\n\n```sh\n# Example with shellcheck\n$ docker run \\\n        --rm \\\n        -u \"$(id -u):$(id -g)\" \\\n        -v \"$(pwd):/usr/src\" \\\n        lequal/sonar-scanner \\\n        shellcheck --color always -s bash -f checkstyle my-script.bash\n# where my-script.bash is a file in the current working directory\n```\n\nFor information on how to use these tools, refer to their official documentation.\n\n#### How to use embedded CNES pylintrc\n\nThere are 3 _pylintrc_ embedded in the image under `/opt/python`:\n\n- `pylintrc_RNC2015_A_B`\n- `pylintrc_RNC2015_C`\n- `pylintrc_RNC2015_D`\n\nTo use one of these files when running `pylint` from within the container:\n\n```sh\n# pylint with a CNES pylintrc\n$ docker run \\\n        --rm \\\n        -u \"$(id -u):$(id -g)\" \\\n        -v \"$(pwd):/usr/src\" \\\n        lequal/sonar-scanner \\\n        pylint --rcfile=/opt/python/pylintrc_RNC2015_A_B my-script.py\n# where my-script.py is a python module in the current working directory\n```\n\nTo import pylint results in SonarQube see the [official documentation](https://docs.sonarqube.org/7.9/analysis/languages/python/#header-3). (Summed up: Run pylint with the following template: `pylint \u003cmodule_or_package\u003e --rcfile=\u003cpylintrc\u003e -r n --msg-template=\"{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}\" \u003e pylint-report.txt`. Activate at least one pylint rule in the Quality Profile the project uses for Python.)\n\n#### How to use other pylintrcs\n\nYou may want to use the embedded `pylint` with a pylintrc of yours . In this case, the easiest way to do so is to put a _pylintrc_ file along with the sources.\n\nTo then use it:\n\n```sh\n# pylint with a custom pylintrc\n$ docker run \\\n        --rm \\\n        -u \"$(id -u):$(id -g)\" \\\n        -v \"$(pwd):/usr/src\" \\\n        lequal/sonar-scanner \\\n        pylint --rcfile=/usr/src/custom_pylintrc my-script.py\n# where my-script.py is a python module in the current working directory\n# and custom_pylintrc is a pylintrc in the current working directory\n```\n\nOn the other hand, if you want to use a CNES _pylintrc_ for your project you can download it directly from github. They are stored on this repository under [pylintrc.d](https://github.com/cnescatlab/sonar-scanner/tree/master/pylintrc.d).\n\n### Examples usage in CI\n\nThis image was made for CI, hence here are some examples. Make sur to use the right URL for your SonarQube instance instead of `my-sonarqube.com`.\n\n_These examples still need to be tested._\n\n#### Jenkins\n\nHere are 2 examples of a declarative Jenkinsfile and a scripted Jenkinsfile that call this image in a stage to analyze a project.\n\n```groovy\n// Declarative pipeline\ndef sonarqubeURL = 'https://my-sonarqube.com'\n\npipeline {\n    agent any\n\n    stages {\n        stage('Sonar scan') {\n            steps {\n                sh  \"\"\"\n                    docker run --rm \\\n                        -u \"\\$(id -u):\\$(id -g)\" \\\n                        -e SONAR_HOST_URL=\"${sonarqubeURL}\" \\\n                        -v \"\\$(pwd):/usr/src\" \\\n                        lequal/sonar-scanner\n                    \"\"\"\n            }\n        }\n    }\n}\n```\n\n```groovy\n// Scripted pipeline\ndef sonarqubeURL = 'https://my-sonarqube.com'\n\nnode {\n    checkout scm\n\n    stage('Sonar scan') {\n        sh  \"\"\"\n            docker run --rm \\\n                  -u \"\\$(id -u):\\$(id -g)\" \\\n                  -e SONAR_HOST_URL=\"${sonarqubeURL}\" \\\n                  -v \"\\$(pwd):/usr/src\" \\\n                  lequal/sonar-scanner\n            \"\"\"\n    }\n}\n```\n\n#### GitHub Actions\n\nHere is a GitHub Actions job of a GitHub Actions workflow that call this image to analyze a project.\n\n```yml\njobs:\n  sonar-scanning:\n    name: Run CNES sonar-scanner\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v2\n      - name: Cache sonar-scanner data\n        uses: actions/cache@v2\n        with:\n          path: .sonarcache\n          key: sonar-scanner-cache\n      - run: |\n          mkdir -p .sonarcache\n          docker run --rm \\\n                    -u \"$(id -u):$(id -g)\" \\\n                    -e SONAR_HOST_URL=\"https://my-sonarqube.com\" \\\n                    -v \"$(pwd):/usr/src\" \\\n                    -v \".sonarcache:/opt/sonar-scanner/.sonar/cache\" \\\n                    lequal/sonar-scanner\n```\n\n#### Travis CI\n\nHere is a Travis CI script step, in a `.travis.yml`, to analyze a project with this image.\n\n```yml\ncache:\n  directories:\n    - /home/travis/.sonarcache\n\nscript:\n  - mkdir -p /home/travis/.sonarcache\n  - docker run --rm \\\n    -u \"$(id -u):$(id -g)\" \\\n    -e SONAR_HOST_URL=\"https://my-sonarqube.com\" \\\n    -v \"$(pwd):/usr/src\" \\\n    -v \"/home/travis/.sonarcache:/opt/sonar-scanner/.sonar/cache\" \\\n    lequal/sonar-scanner\n```\n\n#### GitLab-CI\n\nHere is GitLab-CI job, in a `.gitlab-ci.yml`, to analyze a project with this image.\n\n```yml\nsonar-scanning:\n  stage: test\n  cache:\n    key: sonar-scanner-job\n    paths:\n      - .sonarcache\n  script:\n    - mkdir -p .sonarcache\n    - docker run --rm \\\n      -u \"$(id -u):$(id -g)\" \\\n      -e SONAR_HOST_URL=\"https://my-sonarqube.com\" \\\n      -v \"$(pwd):/usr/src\" \\\n      -v \".sonarcache:/opt/sonar-scanner/.sonar/cache\" \\\n      lequal/sonar-scanner\n```\n\n## Analysis tools included\n\n| Tool                                                                           | Version    | Default report file |\n| ------------------------------------------------------------------------------ | ---------- | ------------------- |\n| [sonar-scanner](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/) | 6.0.0.4432 |                     |\n| [ShellCheck](https://github.com/koalaman/shellcheck)                           | 0.8.0      |                     |\n| [pylint](http://pylint.pycqa.org/en/latest/user_guide/index.html)              | 3.1.0      | pylint-report.txt   |\n| [CNES pylint extension](https://github.com/cnescatlab/cnes-pylint-extension)   | 7.0.0      |                     |\n| [CppCheck](https://github.com/danmar/cppcheck)                                 | 2.14.1     | cppcheck-report.xml |\n| [Hadolint](https://hadolint.github.io/hadolint/)                               | 2.12.0     |                     |\n\n## Developer's guide\n\n_Note about branch naming_: if a new feature needs modifications to be made both on the server image and this one, it is strongly advised to give the same name to the branches on both repositories because the CI workflow of this image will try to use the server image built from the same branch.\n\n### How to build the image\n\nIt is a normal docker image. Thus, it can be built with the following commands.\n\n```sh\n# from the root of the project\n$ docker build -t lequal/sonar-scanner .\n```\n\nTo then run a container with this image see the [user guide](#user-guide).\n\nTo run the tests and create your own ones see the [test documentation](https://github.com/cnescatlab/sonar-scanner/tree/develop/tests).\n\n## How to contribute\n\nIf you experienced a problem with the image please open an issue. Inside this issue please explain us how to reproduce this issue and paste the log.\n\nIf you want to do a PR, please put inside of it the reason of this pull request. If this pull request fixes an issue please insert the number of the issue or explain inside of the PR how to reproduce this issue.\n\nAll details are available in [CONTRIBUTING](https://github.com/cnescatlab/.github/blob/master/CONTRIBUTING.md).\n\nBugs and feature requests: [issues](https://github.com/cnescatlab/sonar-scanner/issues)\n\nTo contribute to the project, read [this](https://github.com/cnescatlab/.github/wiki/CATLab's-Workflows) about CATLab's workflows for Docker images.\n\n## License\n\nLicensed under the [GNU General Public License, Version 3.0](https://www.gnu.org/licenses/gpl.txt)\n\nThis project is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnescatlab%2Fsonar-scanner-catlab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnescatlab%2Fsonar-scanner-catlab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnescatlab%2Fsonar-scanner-catlab/lists"}