# Jenkins part (2)

**Day 2 began** with writing unit test cases for my Spring Boot application using **JUnit**, a popular unit testing framework for Java that helps verify the correctness of individual code units like methods and classes.

I also got my code reviewed using **SonarQube**, a static code analysis tool that helps identify bugs, code smells, and potential vulnerabilities.

There are plenty of resources available online for integrating **SonarQube with Jenkins**, so it’s best to choose one that aligns with your specific setup and environment.  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753067679010/f6824341-09df-4e9e-a96d-4e18b151de16.png align="center")

  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753064133555/a206c601-7927-4b5f-9cd7-ab3645dccab4.png align="center")

  
  
  
What is static code analysis?  
  
**Static Code Analysis** is the process of **analyzing source code without executing it** to find potential errors, code smells, vulnerabilities, or violations of coding standards.  
  
**Done before runtime** (at compile or development time).

* **Tools scan the code** for issues like:
    
    * Unused variables
        
    * Null pointer risks
        
    * Security flaws (e.g., SQL injection risks)
        
    * Non-adherence to coding standards (e.g., naming conventions)
        

  
  
Updated Jenkins file

```plaintext
pipeline {
    agent any

    environment {
        SONAR_PROJECT_KEY = 'test'
        SONAR_PROJECT_NAME = 'test'
    }

    stages {
        stage('Clone Repository') {
            steps {
                echo 'Cloning GitHub repo...'
                git branch: 'main', url: 'https://github.com/Kashimo0054/TODO-APP-with-a-frontend.git'
            }
        }

        stage('Test with Maven') {
            steps {
                echo 'Running tests...'
                bat 'mvn test'
            }
        }

        stage('SonarQube Analysis') {
            steps {
                echo 'Analyzing with SonarQube...'
                withSonarQubeEnv('test-sonar') {
                    bat "mvn sonar:sonar -Dsonar.projectKey=${SONAR_PROJECT_KEY} -Dsonar.projectName=${SONAR_PROJECT_NAME}"
                }
            }
        }

        stage('Build with Maven') {
            steps {
                echo 'Building the project...'
                bat 'mvn clean install -DskipTests=true'
            }
        }
    }

    post {
        success {
            echo '✅ Build completed successfully.'
        }
        failure {
            echo '❌ Build failed.'
        }
    }
}
```

---

**What’s next?**

Running the application locally comes with several challenges. Even if I plan to implement a full enterprise setup with environments like **Dev &gt; QA &gt; UAT &gt; PROD**, ensuring all the software prerequisites are in place for each stage can be quite demanding.

As a more practical and scalable approach, I’ve decided to **containerize my application using tools like Docker**. This will simplify the setup and make it easier to manage across environments.

Stay tuned for the next article, where I’ll walk through the containerization process!
