CI/CD (Continuous Integration/Continuous Delivery) is a holistic DevOps process that focuses on creating a compatible blend between the development cycle and the operations process. This is done by automating workflows and rolling out automatic updates to improve ROI. The CI/CD pipeline implementation is the backbone of the entire DevOps paradigm and facilitates the process of introducing the product to the marketplace faster than ever before.
Continuous Integration, which was first proposed as a term by Gary Booch, integrates the source code with the repository. This facilitates the developers to carry out the development process in a quick and sophisticated manner.
CI is not entirely an essential prerequisite required for creating a stable software product. However, it definitely serves an important role when developing software products or components that require frequent changes. Furthermore, it also ensures that all the components of an application are integrated properly.
Continuous Delivery, on the other hand, is a set of software development practices that ensures the deployment of code to production while performing efficient testing in the process. Precisely speaking, CD starts where CI ends. Continuous Delivery is responsible for pushing the code to the testing environment where different tests such as system testing, unit testing, and integration testing are performed.
Jenkins is one of the most widely used open-source CI/CD DevOps tools. It enables developers to implement CI/CD pipelines within the development environment in a comprehensive manner. Jenkins is written in Java and supports various version control tools including Git and Maven.
Its popularity is based on the fact that Jenkins is an open source repository of rich integrations and plugins that are well documented and extensible, based on an extended community of developers who have developed hundreds of plugins to accomplish almost any task.
Jenkins runs on the server and requires constant maintenance and updates. The availability of Jenkins as a cross-platform tool for Windows, Linux, and various operating systems makes it stand out among other DevOps tools. Moreover, it can easily be configured using CLI or GUI.
Configuring automated CI/CD with Jenkins and GitHub is a simple and straightforward process and can help automate the entire workflow. Integrating Jenkins with GitHub enables the developers to pull the source code from any Git repository in a hassle-free manner.
To implement it on the server or a remote computer, simply replace localhost with the IP Address of the target machine. Jenkins provides long-term support and weekly releases for several Operating Systems. For the scope of this blog, we will be setting up Jenkins on a local Ubuntu machine. To use the Ubuntu repository, execute the command in the terminal:
The second step is to run Jenkins. However, you can also run Jenkins on several platforms including Docker, Kubernetes, and Windows. Notice here that you will need to install Docker or Kubernetes if you are planning to run Jenkins on these platforms. In this tutorial, we will run Jenkins on localhost on Linux.
When you configure Jenkins for the first time, it is crucial to unlock it using an automatic password. For this setup, type :8080 in the browser, and wait for the Getting Started page to appear. The automatically-generated password is stored in /var/jenkins_home/secrets/initialAdminPassword file. The file can be also accessed via the command-line interface using the cat command with the filename.
You will see a new form appear in the webhooks section. In the Payload URL field, type in the Jenkins endpoint. In our case, it is localhost: 8080. Since the localhost is behind a Firewall, make sure to make it visible to your public GitHub repository by using a webhook proxy service. In our case, we have used SocketXP. If you have a specific URL, make sure that it is publicly available. At the end of the URL, type /github-webhook/.
The next step is to configure the project on the Jenkins dashboard. In the General tab, choose your GitHub Project, and enter the GitHub Repository URL. Now, head over to the Source Code Management tab to add the credentials.
Now, head over to the Build Triggers section to set the triggers for Jenkins. The purpose of triggers is to necessarily indicate to Jenkins when to build the project. Select Poll SCM section, which queues VCS on the predefined schedule. The predefined schedule is ***** which represents every minute. That means, our Jenkins job will check for the change in our repository every single minute.
Finally, you have successfully integrated Jenkins with the GitHub repository. With each push, commit, or update, GitHub will trigger the Jenkins job, which in turn will execute the necessary steps to deploy the changes.
DevOps is an ever-evolving ecosystem in the development industry, and the CI/CD tools in this domain are highly critical. CI/CD practices effectively handle the misalignment between developers and the operational team. There are several tools built for this purpose in the marketplace today, but Jenkins holds an established position in the industry as well as a promising future ahead of it because of its open-source benefits and a wide range of plugins. Furthermore, it integrates well with GitHub allowing productivity and flexibility in the DevOps cycle.
We hope that this detailed guide will assist you in setting up your first Jenkins CI/CD build with GitHub repository successfully. Stay tuned for more tutorials and articles on the latest trends in the software and IT industry!
Haris has been working as a professional software engineer as well as a passionate technology writer and blogger for over four years. He possesses a keen interest in consistently exploring the domains of web development, software engineering, and cyber security and has been actively covering the latest technology trends in his blogs and articles.
64591212e2