DevOps/Cloud By GK
  • DevOps/Cloud Introduction
  • 🚩AWS
    • Create AWS Account
    • Launch EC2 Instance
  • 🚩Linux
    • User Managment
      • Adding the User to Sudo group
      • visudo
    • Directory / File Management
      • Vi
      • Changing Permissions (chmod)
      • Filtering IO/File
    • Memory Management
    • Process Management
    • Network Management
    • Service Management
    • Environmental Variables
      • $PATH
    • Utilities
    • SHELL PROGRAMMING
      • Hello World
      • Variables
      • Command Line arguments
      • Conditional Statements
      • Array
      • Loops
      • Functions
      • AWK
      • sed
      • Example Useful Scripts
      • Basic -> Advanced
  • 🚩git
    • Introduction
    • Creating GitHub Account
    • Installation
      • Git Bash In Windows
      • Git In VS Code
      • Git In Eclipse
      • Git CLI in Linux
  • Creating Git Remote Repository
  • Git Commands L -> R
  • Git Commands L <- R
  • Git Branch Commands
  • Using SSH (Password Less)
  • 🚩maven
    • Introduction
    • Installation
    • POM.xml
    • Goals
  • 🚩SonarQube
    • Introduction
    • Sonar Cloud
    • Creating Project In SonarCloud
    • Installing Sonar-Scanner
    • Triggering Scan
  • 🚩Nexus
    • Introduction
    • Installation of Nexus
    • Creating Repository
    • Uploading Artifacts to Repository
  • 🚩Jenkins
    • Introduction
    • Installation of Jenkins
    • First Job In Jenkins
    • Git + Jenkins
      • WebHook
    • Maven + Jenkins
    • Sonar-Scanner + Jenkins
    • Nexus + Jenkins
Powered by GitBook
On this page
  1. Jenkins

Sonar-Scanner + Jenkins

To integrate Sonar Scanner with Jenkins and perform a code scan, follow these steps:

  1. Install the SonarQube Scanner plugin:

    • Access the Jenkins web interface.

    • Click on "Manage Jenkins" in the left-hand side menu.

    • Select "Manage Plugins" from the dropdown.

    • Navigate to the "Available" tab.

    • Search for "SonarQube Scanner" in the filter box.

    • Check the box next to "SonarQube Scanner" plugin.

    • Click on the "Install without restart" button.

  2. Configure SonarQube server in Jenkins:

    • Go back to the Jenkins dashboard.

    • Click on "Manage Jenkins" in the left-hand side menu.

    • Select "Configure System" from the dropdown.

    • Scroll down to the "SonarQube servers" section.

    • Click on the "Add SonarQube" button.

    • Provide a name for the SonarQube server.

    • Enter the SonarQube server URL (e.g., http://localhost:9000).

    • Click on the "Save" button.

  3. Configure SonarQube analysis in your Jenkins job:

    • Open the configuration page for your Jenkins job.

    • Under the "Build Environment" section, check the "Prepare SonarQube Scanner environment" option.

    • From the "Analysis properties" field, click on the "Add" button.

    • Enter the SonarQube properties as key-value pairs, for example:

      sonar.projectKey=my-project
      sonar.sources=src
      sonar.tests=test
      sonar.language=java

      Adjust the properties according to your project's configuration.

    • Save the job configuration.

  4. Build the job:

    • On the Jenkins dashboard, click on the job name to navigate to its details page.

    • Click on "Build Now" to trigger the build.

Jenkins will now perform the SonarQube code scan using the SonarQube Scanner plugin. The scan results will be sent to the SonarQube server configured in Jenkins, where you can view and analyze them.

After the build is completed, you can access the SonarQube dashboard to see the code quality metrics, issues, and other analysis results for your project. You can further configure SonarQube to set quality gates, define rules, and track the code quality over time.

By integrating Sonar Scanner with Jenkins, you can automate the code analysis process and ensure continuous code quality monitoring in your development pipeline.

PreviousMaven + JenkinsNextNexus + Jenkins

Last updated 2 years ago

🚩