Showing posts with label sonarqube. Show all posts
Showing posts with label sonarqube. Show all posts

Friday, 18 September 2020

End to End Automation of Java web App Using jenkins, bitbucket,sonaqube,Maven,Tomcat,Artifactory,Slack

 Tools Used:

  • Bitbucket— Source Code Management
  • Maven — Build Tool
  • Jenkins — Continuous Integration (CI/CD)
  • Artifactory — Artifact Repository Manager
  • SonarQube — Code Quality and Code Analysis
  • Tomcat — Application Server(Web container)



What is the Requirement? - Setup MyDevopsApp Java Project using Maven in Bitbucket and Automate end to end Builds, Code quality checks, Deployments and Collaboration using Jenkins and other Devops tools we have used so far. Could you please work on below lab exercise on a brand new EC2 instance(small instance) and show the output when we meet on next week end?


Lab Exercise Steps:
1. Also, create a repo called MyAutomationRepo in bitbucket. (lab exercise # 5)
2. Create a Java project called MyDevopsApp (instead of MyWebApp which we did before (lab exercise #5) using Maven.
3. Set the above project in Bitbucket(lab exercise #5)
4. Set up a free style job called MyDevopsFreeStyleJob (use webhooks,lab exercise #6, lab exercise # 8) in Jenkins and automate builds, deployments to Tomcat server (lab exercise #6). Also integrate with SonarQube to see the code quality report(lab exercise #10). Finally Jenkins should deploy to Tomcat immediately if there is a code change(lab exercise #7, lab exercise 8). Also jenkins should upload WAR into Artifactory as well. (lab exercise # 17, lab exercise 18). And send notifications to Slack(lab exercise # 19)
5 Finally show the below output in Tomcat by modifying index.jsp (lab exercise #6) in your java project. 
       Congrats I am now a Devops Engineer I Can Migrate App to cloud using Bitbucket,Jenkins,Maven and Tomcat!!!
6. SonarQube dashboard should be viewed in Sonarqube.
7. Artifactory should show uploaded artifacts as well.
8. Slack should show the message coming from Jenkins for every build success/failure.

Tips:

You all know the maven command to create a Java project using Maven and where you to change the word MyWebApp to MyDevopsApp.
mvn archetype:generate -DgroupId=com.mkyong -DartifactId=MyWebApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

Thursday, 10 September 2020

How to Enable Scanning PLSQL Scan in SonarQube

 PL/SQL stands for “Procedural Language extensions to the Structured Query Language”. SQL is a popular language for both querying and updating data in the relational database management systems (RDBMS). PL/SQL adds many procedural constructs to SQL language to overcome some limitations of SQL. Besides, PL/SQL provides a more comprehensive programming language solution for building mission-critical applications on Oracle Databases.

PL/SQL is a highly structured and readable language. Its constructs express the intent of the code clearly. Also, PL/SQL is a straightforward language to learn.

PL/SQL is a standard and portable language for Oracle Database development. If you develop a program that executes on an Oracle Database, you can quickly move it to another compatible Oracle Database without any changes.

PL/SQL is an embedded language. PL/SQL only can execute in an Oracle Database. It was not designed to use as a standalone language like Java, C#, and C++. In other words, you cannot develop a PL/SQL program that runs on a system that does not have an Oracle Database.

PL/SQL is a high-performance and highly integrated database language. Besides PL/SQL, you can use other programming languages such as Java, C#, and C++. However, it is easier to write efficient code in PL/SQL than other programming languages when it comes to interacting with the Oracle Database. In particular, you can use PL/SQL specific constructs like the FORALL statement that helps improve database performance.

PL/SQL architecture

The following picture illustrates the PL/SQL architecture:

If you would like to enable scanning for PL/SQL files in SonarQube, there are both commercial and open source plug-ins available. Lets see how to enable open source plug-in for SonarQube. Useful information is below:

https://github.com/felipebz/sonar-plsql

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 wget https://github.com/felipebz/sonar-plsql/releases/download/2.0.0/sonar-plsql-open-plugin-2.0.0.jar
3. Stop the Sonarqube scanner.
sudo systemctl stop sonar
4. Start the Sonarqube scanner.
 sudo systemctl start sonar
5. Make sure Sonarqube is up and running

sudo systemctl status sonar


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.