Create a Jenkins CICD Pipeline with SonarQube Integration to perform Static Code Analysis

The hands-on lab is part of this learning path

Lab Steps

lock
Logging in to the Amazon Web Services Console
lock
Connecting to the Virtual Machine using SSH
lock
Launch Jenkins and SonarQube Docker Containers
lock
Login to SonarQube and Generate Security Token
lock
Log in to Jenkins and Complete the Default Installation
lock
Install and Configure SonarQube and Gradle Plugins
lock
Create and Execute Jenkins Pipeline Gradle Job
lock
Review SonarQube Static Analysis Report
lock
Validate AWS Lab

Ready for the real environment experience?

DifficultyIntermediate
Max Duration1h 30m
Students92
Ratings
4.3/5
star star star star star-half

Description

Lab Overview

Integrating Jenkins with SonarQube provides you with an automated platform for performing continuous inspection of code for quality and security assurance.

In this Lab, you will launch a Jenkins and SonarQube CICD environment using Docker containers on a provided EC2 instance. You will then configure a Jenkins build pipeline to build, compile, and package a sample Java servlet web application. The build pipeline will publish the source code into SonarQube, which in turn will perform a static analysis of the code to detect bugs, code smells, and security vulnerabilities.

This lab is aimed at DevOps and CICD practitioners, and, in particular, build and release engineers interested in managing and configuring Jenkins together with SonarQube to perform automated static code analysis.

Lab Objectives

Upon completion of this Lab, you will be able to:

  • Install and configure a Jenkins and SonarQube CICD environment using Docker containers
  • Configure Jenkins with the Gradle plugin to perform the core build and packaging for a sample Java servlet web application
  • Configure Jenkins with the SonarQube Scanner plugin for automated static code analysis
  • Create and setup a Jenkins build pipeline using a Jenkinsfile stored within a GitHub repo
  • Use the SonarQube web application to examine and review the generated static analysis report

Lab Prerequisites

You should:

  • Be comfortable with SSH to remotely administer a Linux-based server
  • Be comfortable with basic Linux administration

Lab Environment

This Lab will start with the following AWS resources being provisioned automatically for you:

  • A single EC2 instance, named cicd.platform.instance, which will have a public IP address attached

To achieve the Lab end state, you will be walked through the process of:

  • SSHing into the EC2 instance, named cicd.platform.instance
    • Use Docker Compose to launch the following Docker containers:
      • Jenkins
      • SonarQube
      • Postgres
      • Socat
  • Using a browser, administer and configure Jenkins - installing the required plugins. Connectivity to Jenkins will be done via the cicd.platform.instance Public IP address 
  • Using a browser, administer and configure SonarQube. Connectivity to SonarQube will be done via the cicd.platform.instance Public IP address 
  • Create a Jenkins build pipeline and configure it to build a sample Java servlet web application hosted on GitHub, with the source code later being forwarded into SonarQube for static code analysis
  • Execute the Jenkins build pipeline and confirm that it has completed successfully, forwarding the source code over to SonarQube for static code analysis
  • Confirm that SonarQube has recieved and performed static code analysis and generated a project report

 

 

About the Author

Students12028
Labs28
Courses65
Learning paths14

Jeremy is the DevOps Content Lead at Cloud Academy where he specializes in developing technical training documentation for DevOps.

He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 20+ years. In recent times, Jeremy has been focused on DevOps, Cloud, Security, and Machine Learning.

Jeremy holds professional certifications for both the AWS and GCP cloud platforms.