Coder Social home page Coder Social logo

cnescatlab / sonarqube-catlab Goto Github PK

View Code? Open in Web Editor NEW
9.0 4.0 8.0 190 KB

Docker version of SonarQube with preconfigured plugins and settings dedicated to Continuous Integration.

Home Page: https://hub.docker.com/r/lequal/sonarqube

License: GNU General Public License v3.0

Dockerfile 14.67% Shell 39.24% Python 46.09%
sonarqube docker cnes software-factory ci

sonarqube-catlab's Introduction

CNES SonarQube image [server]

CI badge CD badge

Docker image for SonarQube with pre-configured plugins and settings by CNES dedicated to Continuous Integration.

This image is a pre-configured SonarQube server image derived from Docker-CAT. It contains the same plugins and the same rules for code analysis. It is based on the LTS version of SonarQube.

SonarQube itself is an open source project on GitHub: SonarSource/sonarqube.

For versions and changelog: GitHub Releases.

Features

This image is based on the official SonarQube LTS image, namely sonarqube:9.9.6-community, and offers additional features.

Additional features are:

  • Mandatory modification of the default admin password to run a container.
  • Healthcheck of the container.
  • More plugins (see the list)
  • CNES configuration
    • CNES Quality Profiles for Java, Python, C, C++ and VHDL
    • CNES Quality Gate (set as default)

This image is made to be used in conjunction with a pre-configured sonar-scanner image that embeds all necessary tools: cnescatlab/sonar-scanner. It is, however, not mandatory to use it.

Developer's guide

How to build the image

It is a normal docker image. Thus, it can be built with the following commands.

# from the root of the project
$ docker build -t lequal/sonarqube .

To then run a container with this image see the user guide.

To run the tests and create your own ones see the test documentation.

User guide

This image is available on Docker Hub: lequal/sonarqube.

Since inception, this image has been designed to be used in production. Thus, leaving the default admin password (namely "admin") will never be an option. To this extent, a new password for the admin account shall be given by setting the environment variable SONARQUBE_ADMIN_PASSWORD.

โš ๏ธ ๐Ÿšจ The container will fail to run if SONARQUBE_ADMIN_PASSWORD is empty or equal to "admin".

To run the image locally:

# Recommended options
$ docker run --name lequalsonarqube \
             --rm \
             -p 9000:9000 \
             -e SONARQUBE_ADMIN_PASSWORD="admin password of your choice" \
             lequal/sonarqube:latest

# To stop (and remove) the container
Ctrl-C
# or
$ docker container stop lequalsonarqube

Use an external database

By default, SonarQube uses an embedded database that can be used for tests but in production using an external database for data persistency is mandatory. The docker-compose.yml file shows an example of how to configure an external postgres database. It can be run with:

$ docker-compose up -d

# To set variables when running the containers
$ LEQUAL_SONARQUBE_VERSION=1.0.0 POSTGRES_PASSWD=secret-passwd SONARQUBE_ADMIN_PASSWORD="a password" docker-compose up -d

With an external database, the data used by SonarQube is stored outside of the container. It means that the container may be stopped, restarted, removed and recreated at will.

SonarQube plugins included

SonarQube plugin Version URL
Ansible Lint 2.5.1 https://github.com/sbaudoin/sonar-ansible/sonar-ansible-plugin
C++ (Community) 2.1.1 (build 488) https://github.com/SonarOpenCommunity/sonar-cxx/wiki
Checkstyle 10.17.0 https://github.com/checkstyle/sonar-checkstyle
Clover 4.1 https://github.com/sfeir-open-source/sonar-clover
Cobertura 2.0 https://github.com/galexandre/sonar-cobertura
Community Branch Plugin 1.14.0 https://github.com/mc1arke/sonarqube-community-branch-plugin
Findbugs 4.2.9 https://github.com/spotbugs/sonar-findbugs/
PMD 3.4.0 https://github.com/jborgers/sonar-pmd
ShellCheck Analyzer 2.5.0 https://github.com/sbaudoin/sonar-shellcheck
Sonar i-Code CNES plugin 3.1.1 https://github.com/cnescatlab/sonar-icode-cnes-plugin
SonarQube CNES Report 4.3.0 https://github.com/cnescatlab/sonar-cnes-report
SonarTS 2.1 (build 4362) http://redirect.sonarsource.com/plugins/typescript.html
VHDLRC 3.4 https://www.linty-services.com
YAML Analyzer 1.9.1 https://github.com/sbaudoin/sonar-yaml

To update this list run the following script:

while IFS='|' read -r plugin version url
do
    if [ "$url" = "null" ]; then url="n/a"; fi
    printf "| %.60s| %.25s| %.75s|\n" "$plugin                                                            " "$version                         " "$url                                                                           "
done < <(curl -u MY_TOKEN: -s http://localhost:9000/api/plugins/installed | jq -r '.plugins[] | "\(.name)|\(.version)|\(.homepageUrl)"')

# With `MY_TOKEN` your SonarQube personal token.

Additional information for the Community Branch Plugin

It is advised to set the property sonar.core.serverBaseURL in /admin/settings for the links posted in PR comments and mail to work.

How to contribute

If 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.

If 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.

All details are available in CONTRIBUTING.

Bugs and feature requests: issues

To contribute to the project, read this about CATLab's workflows for Docker images.

License

Licensed under the GNU General Public License, Version 3.0

This 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.

sonarqube-catlab's People

Contributors

begarco avatar diegorodriguez31 avatar gbonnefille avatar github-actions[bot] avatar lefl0w avatar louisjdmartin avatar thomascluzel avatar topin2001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sonarqube-catlab's Issues

Tests with RUN=no doesn't work from within a container

Describe the bug

The docker env is initialized before checking the "RUN" env variable. If the user tell RUN=no and is running from a container, this will produce a bug.

To reproduce

Run "RUN=no pytest" inside a docker container.

Expected behavior

This should work fine in a docker container.

Automerge PRs

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

PRs should be merged automatically when reviewed and checked.

Describe the solution you'd like

A clear and concise description of what you want to happen.

A GitHub Actions workflow.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

  • Doing it manually

CD tries to deliver even when not ready

Describe the bug

A clear and concise description of what the bug is.

The CD workflow should run the delivery steps only when a milestone is completed.

To reproduce

Steps to reproduce the behavior.

  1. Merge a PR linked to an issue linked to a milestone
  2. See that CD fails when getting executed because it can't find a completed milestone

Expected behavior

A clear and concise description of what you expected to happen.

It must not try to release if the milestone is not completed.

User environment

Please complete the following information.

  • OS: GitHub Runner
  • Project version: 2.0.0

C/C++ support

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

C/C++ languages should be supported like in Docker-CAT.

Describe the solution you'd like

A clear and concise description of what you want to happen.

The same plugins as in Docker-CAT (except CNES CXX)

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Python support

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Python language should be supported like in Docker-CAT.

Describe the solution you'd like

A clear and concise description of what you want to happen.

Same plugins as in Docker-CAT

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Add cnes report 3.3.0

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

CatLab images must benefit of the new cnesreport version.

Describe the solution you'd like

A clear and concise description of what you want to happen.

Version 3.3.0 of cnesreport must be installed in SonarQube image.

Support for Shell and Fortran

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Shell and Fortran languages should be supported, like in Docker-CAT.

Describe the solution you'd like

A clear and concise description of what you want to happen.

This image should have the same plugin as Docker-CAT for shell and fortran, namely Sonar i-Code CNES plugin.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

SonarQube CNES 3.1.0 doesn't contain CNES quality profile and quality gate

Describe the bug

Specific quality profiles and quality gate from CNES (RNC) are not available in SonarQube.

To reproduce

  1. Go to Quality profiles and check RNCs presence

Expected behavior

See quality Profile and Quality Gate

Screenshots & log

When launching container, error is

parse error: Invalid numeric literal at line 1, column 10

This is in https://github.com/cnescatlab/sonarqube/blob/6ba333a4e0870cb99a275bcc88154cc37a2ded45/scripts/functions.bash#L66 .

The server is not started, so the API doesn't work and the jq failed.
It's better to test the HTTP code return of curl. And if it's code 200, get the response to test the status.

Furthermore, It'll be better in CI during the check to verify quality profiles and quality gates with API.

Test fails but CI is green

Describe the bug

The test logs indicates an error but the docker-cat image is published

To reproduce

Steps to reproduce the behavior.

  1. Commit anything
  2. Check CI logs to see errors

Expected behavior

CI may crash on errors

Fix CD to prevent early push

Describe the bug

The CD is done when merge on default branch (dev) and not master

Expected behavior

The CD should run only when merge on master

Multi branch plugin

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

This image should use the multi branch community plugin mc1arke/sonarqube-community-branch-plugin.

Describe the solution you'd like

A clear and concise description of what you want to happen.

I would like the image to have the multi branch plugin.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Update quality gates to use Clean As You Code

Is your feature request related to a problem? Please describe.

We must update and synchronize quality gates from our internal sonarqube to use Clean As You Code

Describe the solution you'd like

A clear and concise description of what you want to happen.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Basic image

Basic image

Develop the minimal image to analyze code.

Add Dockerfile language support

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

This image cannot handle Docker projects.

Describe the solution you'd like

A clear and concise description of what you want to happen.

Last release of sonar-hadolint-plugin should be installed and available: https://github.com/cnescatlab/sonar-hadolint-plugin

Java support

Update the image so that all it can perform the same analyses as Docker-CAT.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.