Skip to main content

Implementing SonarQube: A Simple Proof of Concept using Docker

Let's walk through a basic setup of SonarQube using Docker, analyzing a simple Java backend and static front-end page.

  1. Start SonarQube Server:

bash

docker run -d --name sonarqube -p 9000:9000 sonarqube:latest

  1. Create a sample project:
    • index.html (Front-end)
    • App.java (Backend)
  2. Install SonarScanner:
    Download and extract SonarScanner from the official website.
  3. Create a sonar-project.properties file:

Text

sonar.projectKey=my_project sonar.sources=.

  1. Run the analysis:

bash

path/to/sonar-scanner

  1. View the results in the SonarQube dashboard at http://localhost:9000.

This simple setup demonstrates how easily teams can start benefiting from static code analysis.

 
Let's look at a sample code with a simple java app, along with simple Jenkins pipeline and GitHub Actions workflow for a proof of concept (POC) demonstrating SonarQube integration. 

 

Index File


 Java App File


 Jenkins File


 GitHub Actions Workflow

Comments

Popular posts from this blog

Best Practices to clean up GitHub Actions Workspace

    GitHub Actions is a powerful and popular automation tool that allows developers to automate their software workflows. It provides an environment for running scripts, testing code, and deploying applications. One of the key features of GitHub Actions is its ability to create a workspace where code can be checked out and built. However, as with any tool that generates files, GitHub Actions can create clutter in the workspace. This clutter can cause issues with build failures, errors, and storage limitations. Therefore, it is essential to properly clean up the GitHub Actions workspace after every job. In this blog, we will discuss how to clean up the workspace and the best practices to follow. What is the GitHub Actions Workspace? The GitHub Actions workspace is a directory in the runner machine that GitHub creates for each job in a workflow. It is the working directory where code is checked out, built, and processed during the workflow. The workspace directory can be access...

Step-by-Step Configuration Guide: Using AWS CloudTrail for Auditing and Compliance

  AWS CloudTrail is an indispensable service for auditing and maintaining compliance in your AWS environment. Follow this step-by-step guide to set up and configure AWS CloudTrail to effectively monitor and track API activities within your account. Step 1: Sign in to AWS Management Console Log in to your AWS account using your credentials to access the AWS Management Console. Step 2: Navigate to AWS CloudTrail Once you are logged in, search for "CloudTrail" in the AWS Management Console search bar, and click on the "CloudTrail" service. Step 3: Create a CloudTrail Trail In the AWS CloudTrail dashboard, click on the "Trails" tab and then "Create trail." Step 4: Configure Trail Settings Give your trail a descriptive name and specify the bucket where you want the CloudTrail logs to be stored. You can either choose an existing S3 bucket or create a new one. Enable "Log file validation" to ensure the integrity of your logs. Step 5: Enable Cl...

Step-by-Step Guide: Setting Up Visual Studio Code DevContainers

1. Install Visual Studio Code:    Download and install the latest version of Visual Studio Code from the official website (https://code.visualstudio.com). Follow the installation instructions specific to your operating system. 2. Install Docker:    Ensure that Docker is installed on your machine. Visit the Docker website (https://www.docker.com) and download the appropriate version for your operating system. Follow the installation instructions to set up Docker. 3. Install the Remote Development Extension:    Launch Visual Studio Code and navigate to the Extensions view by clicking on the square icon on the left sidebar. Search for "Remote - Containers" extension developed by Microsoft. Install the extension and restart Visual Studio Code if prompted. 4. Create a Project Folder:    Open a new terminal in Visual Studio Code by selecting "View" from the top menu and choosing "Terminal". Navigate to the directory where you want to create your project...