How to Implement CI-CD Pipeline With Jenkins?
How-to-Implement-CI-CD-pipeline-with-Jenkins

Introduction

Jenkins is an open-source automation server intended to automate repetitive technical tasks involved in the continuous integration and delivery of software.

This tutorial will explain you how to implement the continuous integration and continuous deployment with Jenkins to test an application for changes pushed to GitHub Repositories. Whenever the updated code gets pushed to Git repository, Jenkins gets notified to test this code.

Prerequisites

  • Jenkins server should be up and running.
  • GitHub personal access token.
  • GitHub project’s repository URL.

    To copy the GitHub project’s repository URL, log in to Github account and switch to the repository of your GitHub account.

    Open up the drop-down menu of “Clone or download” button and select the URL type e.g. SSH or HTTPS then copy the URL.
    a screenshot of a cell phone

Steps to Implement CI-CD Pipeline With Jenkins

Steps to Configure GitHub Personal Access Token into Jenkins

  1. Open Jenkins and click on Credentials.
a screenshot of a cell phone
2. Expand the drop-down menu of global and click on Add credentials.
a screenshot of a cell phone
3. Select “Secret text” and enter the personal access token in the “Secret” input field.
Click on “Ok” button to apply the changes.

Setup Jenkins Access to GitHub Server

  1. Click on Manage Jenkins.
a screenshot of a cell phone
2. Click on “Configure System”.
a screenshot of a cell phone
3. Find the “GitHub” section from the configuration window, and click on “Add GitHub Server”, then select “GitHub Server” from the drop-down menu.
a screenshot of a cell phone
4. Open the drop-down menu of Credentials and select the personal access token. Then click on the “Test Connection” button.
Click on Save button to apply the changes.

Steps to Create and Configure New Pipeline in Jenkins

    1. Click on New Item.
    2. Select the Pipeline from the available options and enter the item name; e.g. zehntech_pipeline, then click OK.
    a screenshot of a social media post
    3. Click on the checkbox of the “GitHub project” and enter the Github project’s repository URL in the “Project URL” input field.
    4. Click on the “Build Triggers” from the menu and select the checkbox for the “GitHub hook trigger for GITScm polling.”
    a screenshot of a cell phone
    5. Select Git in the SCM menu in Pipeline section and enter the repository URL
    Save and Apply the changes.
    6. Open the Jenkins pipeline and click on “Build Now” to start the pipeline execution then click on “Full Stage View” to see the execution of your pipeline.

Summary

In this tutorial, we have created a new pipeline in Jenkins and configured it with the GitHub project repository for continuous integration and continuous deployment.

Now, if any changes are committed to the repository, they will get detected by this pipeline.

Related Posts