Showing posts with label sonar. Show all posts
Showing posts with label sonar. Show all posts

Monday, 24 November 2025

How to Install SonarQube 25 on ubuntu 22/24

Install SonarQube 25.x (Community Edition) on Ubuntu 22.04 / 24.04

This is a complete fresh installation guide for SonarQube 25.x, using Java 17 and PostgreSQL. All commands include copy buttons for easy use.


Step 1 — Update System

sudo apt update && sudo apt upgrade -y
sudo apt install -y wget unzip curl git apt-transport-https

Step 2 — Install Java 17

sudo apt install -y openjdk-17-jdk
java -version

Step 3 — Install PostgreSQL

sudo apt install -y postgresql postgresql-contrib
sudo systemctl enable --now postgresql

Step 4 — Create SonarQube Database & User

sudo -u postgres psql <<EOF
CREATE ROLE sonaruser WITH LOGIN ENCRYPTED PASSWORD 'StrongPassword123!';
CREATE DATABASE sonarqube OWNER sonaruser ENCODING 'UTF8' LC_COLLATE='C.UTF-8' LC_CTYPE='C.UTF-8';
GRANT ALL PRIVILEGES ON DATABASE sonarqube TO sonaruser;
EOF

Verify database is empty:

sudo -u postgres psql -d sonarqube -c "\dt"

Step 5 — Configure Kernel Limits (Elasticsearch)

echo "vm.max_map_count=524288" | sudo tee -a /etc/sysctl.conf
echo "fs.file-max=65536" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Set user limits:

sudo tee -a /etc/security/limits.conf <<EOF
sonar   -   nofile   65536
sonar   -   nproc    4096
EOF

Step 6 — Create Dedicated SonarQube User

sudo groupadd sonar
sudo useradd -c "SonarQube User" -d /opt/sonarqube -g sonar -s /bin/bash sonar

Step 7 — Download SonarQube 25.x

Using your specific build: sonarqube-25.11.0.114957.zip

cd /opt
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-25.11.0.114957.zip
sudo unzip sonarqube-25.11.0.114957.zip
sudo mv sonarqube-25.11.0.114957 sonarqube
sudo chown -R sonar:sonar /opt/sonarqube

Step 8 — Configure SonarQube (sonar.properties)

sudo nano /opt/sonarqube/conf/sonar.properties

Set the following inside the file:

sonar.jdbc.username=sonaruser
sonar.jdbc.password=StrongPassword123!
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube
sonar.web.host=0.0.0.0

Step 9 — Create Systemd Service

sudo tee /etc/systemd/system/sonarqube.service > /dev/null <<EOF
[Unit]
Description=SonarQube 25.x Service
After=network.target postgresql.service

[Service]
Type=forking
User=sonar
Group=sonar
ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
Restart=always
LimitNOFILE=65536
LimitNPROC=4096
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload

Step 10 — Start SonarQube

sudo systemctl start sonarqube
sudo systemctl enable sonarqube

Check service status:

systemctl status sonarqube

Check logs (new location for 25.x):

tail -f /opt/sonarqube/var/logs/web.log

Step 11 — Open Firewall

sudo ufw allow 9000/tcp
sudo ufw status

Step 12 — Access the UI

http://YOUR_SERVER_PUBLIC_IP:9000

Default Login:

  • Username: admin
  • Password: admin

Installation Complete

SonarQube 25.x is now fully installed and running on your server.

Sunday, 23 November 2025

How to install Sonarqube on Ubuntu 22

Install SonarQube 9.9 LTS on Ubuntu 22.04

This is a clean installation guide for SonarQube 9.9.0.65466 using Java 17 and PostgreSQL.


Step 0 — Update Ubuntu

sudo apt update && sudo apt upgrade -y
sudo apt install -y wget unzip vim

Step 1 — Install Java 17

sudo apt install -y openjdk-17-jdk
java -version

Step 2 — Install PostgreSQL

sudo apt install -y postgresql postgresql-contrib
sudo systemctl enable --now postgresql

Step 3 — Create Database & User

sudo -u postgres psql <<EOF
CREATE ROLE sonaruser WITH LOGIN ENCRYPTED PASSWORD 'StrongPassword123!';
CREATE DATABASE sonarqube OWNER sonaruser ENCODING 'UTF8' LC_COLLATE='C.UTF-8' LC_CTYPE='C.UTF-8';
GRANT ALL PRIVILEGES ON DATABASE sonarqube TO sonaruser;
EOF

Verify database is empty:

sudo -u postgres psql -d sonarqube -c "\dt"

Step 4 — Kernel Settings for Elasticsearch

echo "vm.max_map_count=524288" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Step 5 — Download SonarQube 9.9.0.65466

cd /tmp
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.9.0.65466.zip
sudo unzip sonarqube-9.9.0.65466.zip -d /opt
sudo mv /opt/sonarqube-9.9.0.65466 /opt/sonarqube

Step 6 — Create SonarQube User

sudo groupadd sonar
sudo useradd -c "SonarQube User" -d /opt/sonarqube -g sonar -s /bin/bash sonar
sudo chown -R sonar:sonar /opt/sonarqube

Step 7 — Configure SonarQube

Edit config:

sudo nano /opt/sonarqube/conf/sonar.properties

Set these values:

sonar.jdbc.username=sonaruser
sonar.jdbc.password=StrongPassword123!
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube
sonar.web.host=0.0.0.0

Step 8 — Create Systemd Service

sudo tee /etc/systemd/system/sonarqube.service > /dev/null << 'EOF'
[Unit]
Description=SonarQube service
After=network.target postgresql.service

[Service]
Type=forking
User=sonar
Group=sonar
ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
Restart=always
LimitNOFILE=65536
LimitNPROC=4096

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload

Step 9 — Start SonarQube

sudo systemctl start sonarqube
sudo systemctl enable sonarqube

Check status:

systemctl status sonarqube

Check logs:

tail -f /opt/sonarqube/logs/web.log

Step 10 — Open Firewall

sudo ufw allow 9000/tcp
sudo ufw status

Step 11 — Access SonarQube

http://YOUR_SERVER_PUBLIC_IP:9000

Default Login:

  • Username: admin
  • Password: admin

Installation Complete

Your SonarQube 9.9 LTS server is fully operational.

Thursday, 10 September 2020

How to Enable Scanning Delphi Scan in SonarQube

Delphi is a general-purpose programming language and a software product that uses the Delphi dialect of the Object Pascal programming language and provides an integrated development environment (IDE) for rapid application development of desktop, mobileweb, and console software,[2] currently developed and maintained by Embarcadero Technologies.

Delphi's compilers generate native code for Microsoft WindowsmacOSiOSAndroid and Linux (x64).[3] [4] [5]

Delphi includes a code editor, a visual designer, an integrated debugger, a source code control component, and support for third-party plugins. The code editor features Code Insight (code completion), Error Insight (real-time error-checking), and refactoring. The visual forms designer has the option of using either the Visual Component Library (VCL) for pure Windows development or the FireMonkey (FMX) framework for cross-platform development. Database support is a key feature and is provided by FireDAC (Database Access Components). Delphi is known for its fast compilation speed, native code, and developer productivity.

Delphi was originally developed by Borland as a rapid application development tool for Windows as the successor of Turbo Pascal. Delphi added full object-oriented programming to the existing language, and the language has grown to support generics, anonymous methods, closures, and native Component Object Model (COM) support.

Delphi and its C++ counterpart, C++Builder, are interoperable and jointly sold under the name RAD Studio. There are Professional, Enterprise, and Architect editions, with the higher editions having more features at a higher price. There is also a free-of-charge Community edition, with most of the features of Professional, but restricted to users and companies with low revenue.[6]

Features

Delphi supports rapid application development (RAD). Prominent features are a visual designer and two application frameworks, Visual Component Library (VCL) for Windows and FireMonkey (FMX) for cross-platform development.

Delphi uses the Pascal-based programming language Object Pascal created by Anders Hejlsberg for Borland (now IDERA) as the successor to Turbo Pascal. It supports native cross-compilation to many platforms including Windows, Linux, iOS, and Android.

To better support development for Microsoft Windows and interoperate with code developed with other software development tools, Delphi supports independent interfaces of Component Object Model (COM) with reference counting class implementations, and support for many third-party components. Interface implementations can be delegated to fields or properties of classes. Message handlers are implemented by tagging a method of a class with the integer constant of the message to handle.

Database connectivity is extensively supported through VCL database-aware and database access components.

Later versions have included upgraded and enhanced runtime library routines, some provided by the community group FastCode.

Characteristics

Delphi uses a strongly typed high-level programming language, intended to be easy to use and originally based on the earlier Object Pascal language. Pascal was originally developed as a general-purpose language "suitable for expressing the fundamental constructs known at the time in a concise and logical way", and "its implementation was to be efficient and competitive with existing FORTRAN compilers"[7] but without low-level programming facilities or access to hardware. Turbo Pascal and its descendants, including Delphi, support access to hardware and low-level programming, with the facility to incorporate code written in assembly language and other languages. Delphi's object-orientation features only class- and interface-based polymorphism.[8] Metaclasses are first class objects. Objects are references to the objects (as in Java), which Delphi implicitly de-references, so there is usually no need to manually allocate memory for pointers to objects or use similar techniques that some other languages need. There are dedicated reference-counted string types, and also null-terminated strings.

Strings can be concatenated by using the '+' operator, rather than using functions. For dedicated string types, Delphi handles memory management without programmer intervention. Since Borland Developer Studio 2006, there are functions to locate memory leaks.

Delphi includes an integrated IDE. The Delphi products all ship with a run-time library (RTL) and a Visual Component Library (VCL), including most of its source code. Third-party components (sometimes with full source code) and tools to enhance the IDE or for other Delphi related development tasks are available, some free of charge. The IDE includes a GUI for localization and translation of created programs that may be deployed to a translator; there are also third-party tools with more features for this purpose. The VCL framework maintains a high level of source compatibility between versions, which simplifies updating existing source code to a newer Delphi version. Third-party libraries typically need updates from the vendor but, if source code is supplied, recompilation with the newer version may be sufficient. The VCL was an early adopter of dependency injection or inversion of control; it uses a reusable component model, extensible by the developer. With class helpers, new functionality can be introduced to core RTL and VCL classes without changing the original source code of the RTL or VCL.

The compiler is optimizing and is a single-pass compiler. It can optionally compile to a single executable which does not require DLLs. Delphi can also generate standard DLLs, ActiveX DLLs, COM automation servers and Windows services.

The Delphi IDEs since Delphi 2005 increasingly support refactoring features such as method extraction and the possibility to create UML models from the source code or to modify the source through changes made in the model.

Delphi has communities on the web, where also its employees actively participate.

Backward compatibility

Delphi is one of the languages where backward compatibility is close to 100%. Although each new release of Delphi attempts to keep as much backward compatibility as possible to allow existing code reuse, new features, new libraries, and improvements sometimes make newer releases less than 100% backward compatible.

Since 2016, there have been new releases of Delphi every six months, with new platforms being added approximately every second release.[9]

Frameworks

Delphi offers two frameworks for visual application development, VCL and FireMonkey (FMX):

  • Visual Component Library (VCL) is the framework for developing pure Windows applications. VCL is a long-standing framework, included in the first release of Delphi and actively developed ever since then.
  • FireMonkey (later abbreviated FMX), was released in 2011, as part of Delphi XE2, together with an additional set of built-in compilers for non-Windows platforms. FireMonkey is a cross-platform framework for Windows, macOS, iOS, Android and Linux (x64). The GUI parts of FireMonkey are largely based on Direct3D and OpenGL. FireMonkey is not compatible with VCL; they are two separate frameworks. FireMonkey applications do, however, allow easy sharing of non-visual code units with VCL applications, enabling a lot of code to be ported or shared easily between the platforms.

Interoperability

Delphi and its C++ counterpart, C++Builder, are interoperable. They share many core components, notably the IDE, the VCL and FMX frameworks, and much of the runtime library. In addition, they can be used jointly in a project. For example, C++Builder 6 and later can combine source code from Delphi and C++ in one project, while packages compiled with C++Builder can be used from within Delphi. In 2007, the products were released jointly as RAD Studio, a shared host for Delphi and C++Builder, which can be purchased with either or both.Starting with Rio, there is also interoperability with Python.

Source:Delphi (software) explained

If you would like to enable scanning for Delphi files in SonarQube, there are both commercial and open source plug-ins available. you can find compatible plugins https://docs.sonarsource.com/sonarqube-server/2025.1/setup-and-upgrade/plugins/plugin-version-matrix
 Lets see how to enable open source plug-in for SonarQube. Useful information is below:


Pre-requisites:
SonarQube is already set up and running.

Steps: (Execute this step on SonarQube instance)

1. navigate to ${Sonar_Home}/extensions/plugins folder where you installed SonarQube:
cd /opt/sonarqube/extensions/plugins
2. Download the plsql opensource plug-in from the above websites by executing below command:
sudo curl -L -o sonar-delphi-plugin-1.18.3.jar https://raw.githubusercontent.com/princexav/files/refs/heads/main/plugin/sonar-delphi-plugin-1.18.3.jar 
3. Stop the Sonarqube scanner.
sudo systemctl stop sonarqube
4. Start the Sonarqube scanner.
 sudo systemctl start sonarqube
5. Make sure Sonarqube is up and running

IF THE ABOVE FAILS 
 sudo systemctl start sonarqube

sudo systemctl status sonarqube


once started, you should see below message
sonar.service - SonarQube service
   Loaded: loaded (/etc/systemd/system/sonar.service; enabled; vendor preset: e
   Active: active (running) since Thu 2020-09-10 19:48:54 UTC; 21s ago
  Process: 5644 ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop (code=ex
  Process: 5786 ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start (code=
 Main PID: 5843 (wrapper)
    Tasks: 138 (limit: 4686)
   CGroup: /system.slice/sonar.service
           ├─5843 /opt/sonarqube/bin/linux-x86-64/./wrapper /opt/sonarqube/bin/
           ├─5850 java -Dsonar.wrapped=true -Djava.awt.headless=true -Xms8m -Xm
           ├─5879 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Djava.awt.hea
           ├─5931 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Djava.awt.hea
           └─5985 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Djava.awt.hea

Sep 10 19:48:53 ip-172-31-37-172 systemd[1]: Starting SonarQube service...
Sep 10 19:48:54 ip-172-31-37-172 sonar.sh[5786]: Starting SonarQube...
Sep 10 19:48:54 ip-172-31-37-172 sonar.sh[5786]: Started SonarQube.
Sep 10 19:48:54 ip-172-31-37-172 systemd[1]: Started SonarQube service.
6. If you don't see server is not starting, you might want to check the logs by executing:
cat /opt/sonarqube/logs/web.log 
7. Now login to SonarQube, Navigate to Rules section, you should see PL/SQL rules added.

Tuesday, 1 September 2020

How to install SonarQube on Ubuntu Linux?

 

How to install SonarQube on Ubuntu Linux

SonarQube is one of the popular static code analysis tool. SonarQube is java based tool along with back end - back end can be MySQL, Oracle or PostgreSQL. We will use Postgres for set up on Ubuntu.
Please find steps for installing SonarQube on Ubuntu EC2. Make sure port 9000 is opened in security group(firewall rule).



Let us start with java install (skip java install if you already have it installed)

1. Java steps 

sudo apt-get update
sudo apt-get install default-jdk -y

Verify Java Version

java -version

openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.16.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

2. Postgres Installation

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'



sudo wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -



sudo apt-get -y install postgresql postgresql-contrib







sudo systemctl start postgresql
sudo systemctl enable postgresql

Login as postgres user now
sudo su - postgres

Now create a user below
createuser sonar

Switch to sql shell by entering
psql



Execute the below three lines (one by one)

ALTER USER sonar WITH ENCRYPTED password 'password';
CREATE DATABASE sonar OWNER sonar;
\q




type exit to come out of postgres user.





3. Now install SonarQube Web App
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-6.4.zip

sudo apt-get -y install unzip
sudo unzip sonarqube-6.4.zip -d /opt





sudo mv /opt/sonarqube-6.4 /opt/sonarqube -v




Modify sonar.properties file
sudo vi /opt/sonarqube/conf/sonar.properties
uncomment the below lines by removing # and add values highlighted yellow
sonar.jdbc.username=sonar
sonar.jdbc.password=password







Next, uncomment the below line, removing #
sonar.jdbc.url=jdbc:postgresql://localhost/sonar





Press escape, and enter :wq! to come out of the above screen.

Create Sonar as a service
Execute the below command:
sudo vi /etc/systemd/system/sonar.service










add the below code in green color:
[Unit]
Description=SonarQube service
After=syslog.target network.target

[Service]
Type=forking

ExecStart=/opt/sonarqube/bin/l
inux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/li
nux-x86-64/sonar.sh stop

User=root
Group=root
Restart=always

[Install]
WantedBy=multi-user.target


sudo systemctl enable sonar
sudo systemctl start sonar
sudo systemctl status sonar
type q now to come out of this mode.
Now execute the below command to see if Sonarqube is up and running. This may take a few minutes.

tail -f /opt/sonarqube/logs/sonar.log

Make sure you get the below message that says sonarqube is up..
Now access sonarQube UI by going to browser and enter public dns name with port 9000

.
Watch video installation for Sonarqube on ubuntu 16.04 instance



Bash Script to Install Artifactory in Ubuntu 22

JFrog Artifactory OSS 7.21.5 — Install (Bash Script) This script installs Artifactory OSS (no Docker, no Pro, works on Ubuntu 22 EC2). ...