Giter Site home page Giter Site logo

sonar-demo's Introduction

SonarQube Demo

Start SonarQube server using Docker

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

Install Java

Check if you have java installed in your system

java -version

We need java verison 11 to run the sample code, you can use below command to install the java 11.

sudo apt-get install default-jdk

If you have multiple java versions installed, you can used below command to slect the java version 11 for this project.

sudo update-alternatives --config java

Install Maven

Visit https://maven.apache.org/download.cgi page to download the Maven or you can use below command to download it from the command line.

wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz

Extract tar file and then goto bin directory.

tar -xvzf apache-maven-3.8.6-bin.tar.gz

cd apache-maven-3.8.6/bin

Run pwd command to get the maven bin directory path

pwd

My output:

/home/ishtiyaq/Downloads/apache-maven-3.8.6/bin

Set the maven path in the system PATH variable.

export PATH="$PATH:/home/ishtiyaq/Downloads/apache-maven-3.8.6/bin"

Now, you will be able to access the mvn command from anywhere in your system.

Install git and clone the sample project from the given link

sudo apt install git

Now, goto your desktop and clone the sample project.

git clone https://github.com/ishtiyaq-td/sonar-demo.git

Go to the project directory,

cd sonar-demo

Create a project on SonarQube server

Login to your sonarqube server and crate a project.

SonarQube default username and password is admin

Configure sonar-project.properties and connect maven to SonarQube

# Required metadata
sonar.projectKey=sonar-demo
sonar.projectName=Simple Java project analyzed with the SonarQube Runner
sonar.projectVersion=1.0

# Comma-separated paths to directories with sources (required)
sonar.sources=src

# Language
sonar.language=java

# Encoding of the source files
sonar.sourceEncoding=UTF-8

Compile the code

mvn compile

Run the SonarQube scanner

mvn clean verify sonar:sonar \
  -Dsonar.projectKey=<your-project-key> \
  -Dsonar.host.url=<your-sonarqube-server-url> \
  -Dsonar.login=<your-sonarqube-access-key>

sonar-demo's People

Contributors

ishtiyaq-td avatar ishtiyaq avatar

Watchers

 avatar

Forkers

abhinav-tatras

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.