DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Trending

  • Optimizing Serverless Computing with AWS Lambda Layers and CloudFormation
  • Next Evolution in Integration: Architecting With Intent Using Model Context Protocol
  • ITBench, Part 1: Next-Gen Benchmarking for IT Automation Evaluation
  • Caching 101: Theory, Algorithms, Tools, and Best Practices

Creating Custom SonarQube Image With Mule Plugin

In this article, we will create the Custom SonarQube Image with MuleSoft plugin to scan and analyze Mule 3/Mule 4 Code.

By 
Ankit Lawaniya user avatar
Ankit Lawaniya
·
Oct. 07, 20 · Tutorial
Likes (7)
Comment
Save
Tweet
Share
11.4K Views

Join the DZone community and get the full member experience.

Join For Free

What Is SonarQube?

SonarQube is an open-source platform for continuous inspection of code quality. It is a universal tool to perform "Static Code Analysis".

SonarQube helps in below:

  • Identify the Overall Code Coverage
  • Identify the Coverage on the Latest Code
  • Identify the Code smells
  • Identify the Code Bugs
  • Identify the Security Vulnerabilities

In this article, we will create the Custom SonarQube Image with MuleSoft plugin to scan and analyze Mule 3/Mule 4 Code.

Step 1:  Download the MuleSoft plugin binary from the below location.

MuleSoft Sonar Plugin

Step 2: Execute below command and create a jar file as a plugin.

Shell
 




xxxxxxxxxx
1


 
1
mvn clean package sonar-packaging:sonar-plugin -Dlanguage=mule



Step 3: Download the below rules for Mule 3 and Mule 4.

1: https://github.com/mulesoft-catalyst/mule-sonarqube-plugin/blob/master/src/test/resources/rules-4.xml

2: https://github.com/mulesoft-catalyst/mule-sonarqube- plugin/blob/master/src/test/resources/rules-3.xml

Step 4: Create a Dockerfile for the SonarQube with MuleSoft plugin.

Dockerfile
 




xxxxxxxxxx
1


 
1
FROM sonarqube:7.9.4-community
2
COPY mule-validation-sonarqube-plugin-1.0.3-mule.jar /opt/sonarqube/extensions/plugins/
3
COPY rules-4.xml /opt/sonarqube/extensions/plugins/
4
COPY rules-3.xml /opt/sonarqube/extensions/plugins/
5

          



Step 5: Execute the below command to create the Custom image.

Shell
 




xxxxxxxxxx
1


 
1
docker build --tag=alawaniy/sonarqube-mule .



Step 6: Execute the below command to run the container.

Shell
 




xxxxxxxxxx
1


 
1
docker run -d --name sonarqube -p 9000:9000 alawaniy/sonarqube-mule



Step 7: (Optional) Shell into container to see if the MulePlugin has been copied to the extensions folder.

Shell
 




x


 
1
docker exec -it <<Container_id>> /bin/bash



Step 7: Open Browser and type URL http://localhost:9000 and login with default credentials.

User Name: admin 

Password : admin

log in to SonarQube

After Login , Go to Administration and you will see the Mule Tab under General Settings.

 admin

Step 8: Go to Administration -> XML and delete the .xml extension otherwise Code scanning will conflict .xml pattern with  sonar.lang.patterns.xml and sonar.lang.patterns.mule

xml

Step 9: Deploy your MuleSoft code with below mvn command and it will push the analysis to the SonarQube.

Shell
 




xxxxxxxxxx
1


 
1
sonar:sonar test -Dsonar.host.url=http://localhost:9000 -Dsonar.sources=src/



Step 10: Check the analysis.

check the analysis

Hope this helps.

Thanks. Keep learning.

Opinions expressed by DZone contributors are their own.

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!