Jenkins Tutorial For Beginners: Practical Guide

You are currently viewing Jenkins Tutorial For Beginners: Practical Guide
Please share

In this Jenkins tutorial for beginner series, You will learn all the essential topics for a DevOps engineer to understand Jenkins better with step-by-step practical tutorials.

What is Jenkins?

Jenkins is a continuous open-source integration written in Java. It was forked from Hudson Project after a dispute with Oracle. Since the fork, Jenkins has grown to be much more than a continuous integration solution.

Jenkins is not just a Continuous Integration tool anymore. Instead, it is a Continuous Integration and Continuous delivery tool. You can orchestrate application deployments using Jenkins with a wide range of freely available community plugins and native Jenkins workflows.

Jenkins also supports GitOps workflows with Jenkins X. It helps you accelerate the continuous delivery pipeline on Kubernetes.

Jenkins Use Cases

The following are the main Jenkins use cases from my experience extensively working on Jenkins.

  1. Continuous Integration: With Jenkins pipelines, we can achieve CI for both applications and infrastructure as code.
  2. Continuous Delivery: You can set up well-defined and automated application delivery workflows with Jenkins pipelines.
  3. Automation & Ad-Hoc Tasks: With Jenkins jobs and pipelines, you can automate infrastructure components and perform ad-hoc infrastructure tasks (Backups, remote executions, etc.).

Jenkins Tutorials For Beginners

In this collection of Jenkins tutorial posts, I will cover various Jenkins tutorials, which will help beginners get started with many of the Jenkins core functionalities.

I have categorized the list of Jenkins beginner tutorials into multiple sections. From Jenkins installation to advanced concepts like shared libraries are covered in this tutorial list.

It is a growing list of Jenkins step-by-step guides. I will add all the latest tutorials to this list.

How Does Jenkins Works?

In this section, you will learn the very basics of Jenkins that every beginner should know. Overall you will learn how Jenkins works as a CI/CD tool.

Jenkins Core Features

Let’s have look at the overview of key Jenkins 2.x features that you should know.

  1. Pipeline as Code
  2. Shared Libraries
  3. Better UI and UX
  4. Improvements in security and plugins

Pipeline as Code

Jenkins introduced a DSL by which you can version your build, test, and deploy pipelines as code. Pipeline code is wrapped around a groovy script that is easy to write and manage. An example pipeline code is shown below.

node(‘linux’){
  git url: 'https://github.com/devopscube/simple-maven-pet-clinic-app.git'
  def mvnHome = tool 'M2'
  env.PATH = "${MNHOME}/bin:${env.PATH}"
  sh 'mvn -B clean verify'
}

Using pipeline as a code you can run parallel builds on a single job on different slaves. Also, you have good programmatic control over how and what each Jenkins job should do.

Jenkinsfile is the best way to implement Pipeline as code. There are two types of pipeline as code.

  1. Scripted Pipeline and
  2. Declarative Pipeline.

I recommend using only a declarative pipeline for all your Jenkins-based CI/CD workflows, as you will have more control and customization over your pipelines.

Jenkins 2.0 has a better User interface. The pipeline design is also great in that the whole flow is visualized. Now you can configure the user, password, and plugins right from the moment you start the Jenkins instance through awesome UI.

Also, Jenkins Blueocean is a great plugin that gives a great view of pipeline jobs. You can even create a pipeline using the blue ocean visual pipeline editor. Blueocen looks like the following.

like the following.

Jenkins Shared Libraries

Jenkins shared library is a great way to reuse the pipeline code. You can create your CI/CD code libraries, which can be referenced in your pipeline script. In addition, the extended shared libraries will allow you to write custom groovy code for more flexibility.

Here is how shared libraries work.

  1. The common pipeline shared library code resides on a version control system like GitHub.
  2. The shared library GitHub repo needs to be configured in Jenkins global configuration. It enables access to the library for all Jenkins jobs.
  3. You have to add an import statement to import the shared libraries and use it in the pipeline code in individual jobs. During job builds, first, the shared library files get checked out.

GitOps With Jenkins X

Jenkins X is a project from Jenkins for CI/CD on Kubernetes. This project is entirely different from normal Jenkins.

Jenkins X has the following key features.

  1. GitOps-based Tekton pipelines
  2. Environment Promotion via GitOps
  3. Pull Request Preview Environments
  4. Feedback and chat on Issues and Pull Requests

Conclusion

All the Jenkins tutorials mentioned in this article will help you take your Jenkins knowledge to the next level.

Jenkins has a huge community and, you can find support in different forums if you face any issues.