DEV Community

Tech Tobé
Tech Tobé

Posted on

Jenkins CI/CD Freestyle Project: A Comprehensive Guide

Brief overview: 

Here we'll explore essential tools and techniques to create a seamless CI/CD pipeline. Through hands-on experience, we'll learn how to build, analyze, deploy, and collaborate on code using popular tools like Maven, SonarQube, Nexus, Tomcat, GitHub, and Jenkins.

Table of Contents

  1. Introduction
  2. Prerequisites
  3. Step-By-Step Guide a) Getting started with Jenkins i) Accessing Jenkins Dashboard ii) GitHub Credentials iii) Setting Up a Freestyle Job b) Setting Up Our Continuous Integration Tools with Jenkins i) Maven-Jenkins Integration ii) SonarQube-Jenkins Integration iii) Tomcat-Jenkins Integration iv) Nexus-Jenkins Integration v) Notifications vi)GitHub Webhook
  4. Conclusions
  5. Attributions

**

How to Deploy an Apache Maven Server Using the AWS EC2 Service

**

1. Introduction

In the fast-paced world of software development, Continuous Integration and Continuous Deployment (CI/CD) pipelines have become indispensable.

CI/CD pipelines have made software development easier by making the process faster, helping people work together better, and making sure high-quality apps are delivered quickly. With these pipelines, developers can focus on writing code while the pipeline automatically takes care of other tasks, like building, testing, and deploying the apps. This way, developers can work smarter and come up with more creative ideas.

This step-by-step guide will navigate us through the creation of an end-to-end CI/CD deployment using Jenkins, incorporating essential tools like Maven, SonarQube, Nexus, Tomcat, GitHub, and Notifications.

Jenkins is a Java-based open-source automation tool designed specifically for Java-based projects.

These commands are compatible with the bash and the sh shell.1

2. Prerequisites

Before diving into the implementation, ensure the following prerequisites are in place:

  • A basic understanding of Jenkins and the Groovy scripting language.
  • Jenkins and Java JDK installed on a server with a functional Jenkins account.
  • Essential Jenkins plugins: Maven plugin, Email Extension, SSH Agent, Thin Backup, Deploy to container, Safe Restart, Publish over SSH.
  • Access to Jenkins Dashboard.
  • A GitHub account with a project repository.
  • Credentials for GitHub, SonarQube, Nexus, Maven, and Tomcat.

3. Step-By-Step Guide

3.1 Getting started with Jenkins

3.1.1 Accessing Jenkins Dashboard
  • Access the Jenkins Dashboard by entering the unique Jenkins URL into a web browser. The URL format should be: http://[PublicIP]:8080. Replace [PublicIP] with the Jenkins server’s Public IP address. Note: The default port to access Jenkins is port 8080.
  • Sign in using your Jenkins credentials.
3.1.2 GitHub Credentials
  • Configure GitHub credentials:
    • Access GitHub on a web browser.
    • Go to GitHub developers settings.
    • Navigate to the “personal access token” section.
    • Create a personal access token with Full access and a validity of 30 days.
    • Save the token securely.
  • Navigate back to Jenkins dashboard on a web browser (Continued in the next section).
3.1.3 Setting Up a Freestyle Job
  • Create a new Freestyle Job:
    • On the Jenkins dashboard, select “New item”.
    • Provide a name for the item and select “Freestyle project”.
    • Input a brief description of the project.
    • Configure source code repository and other details.

3.2 Setting Up Our Continuous Integration Tools with Jenkins

3.2.1 Maven-Jenkins Integration
  • Maven streamlines project building and management:
    • Navigate to “Manage Jenkins” > “Global tool configuration”.
    • Configure Maven project and specify goals.
3.2.2 SonarQube-Jenkins Integration
  • Integrate SonarQube analysis into the project:
    • Ensure SonarQube service is running.
    • Edit the build script with SonarQube server URL and login credentials.
    • Specify SonarQube goals in Jenkins configuration.
3.2.4 Tomcat-Jenkins Integration
  • Deploy the application to Tomcat from Jenkins:
    • Create a user for Jenkins to access Tomcat remotely.
    • Modify Tomcat configuration files.
    • Configure Jenkins project to deploy to Tomcat.
3.2.5 Nexus-Jenkins Integration
  • Integrate Nexus with Jenkins for artifact management:
    • Create repositories in Nexus.
    • Edit the build script with Nexus repository details.
    • Modify Maven settings via Jenkins server.
    • Specify Maven goals in Jenkins configuration.
3.2.6 Notifications
  • Integrate email notifications for build status:
    • Configure SMTP server details.
    • Specify recipient email addresses.
    • Add email notification commands.
3.2.7 GitHub Webhook
  • Automate the process with GitHub webhooks:
    • Add webhook in GitHub repository settings.
    • Copy and save the payload URL.
    • Configure Jenkins project to trigger on push events.

4. Conclusions

By following these steps, an End-to-End Jenkins CI/CD Pipeline incorporating Maven, SonarQube, Nexus, Tomcat, GitHub, and Notifications is constructed. This pipeline enhances software development by automating integration, testing, and deployment, accelerating delivery, minimizing errors, and fostering collaboration. Continuous monitoring ensures code quality, while Nexus simplifies artifact management, optimizing efficiency, reducing time-to-market, and elevating software quality. This streamlined workflow ensures efficient and reliable software delivery.

  5. Attributions

Jenkins Documentation(Landmark technologies )

Maven Documentation

SonarQube Documentation

Nexus Documentation

Tomcat Documentation

GitHub Documentation

Got any questions? Why not schedule a tutoring block?

Top comments (0)