Black Friday Deal : Up to 40% OFF! + 2 free self-paced courses + Free Ebook  - SCHEDULE CALL

- DevOps Blogs -

A Starter Guide to Jenkins Cheat Sheet you Need to Know

DevOps enthusiasts are generally looking to explore different tools that are frequently used in the workplace. If you are one of them then you have landed on the right page. DevOps professionals are generally paid higher and high in-demand worldwide. Keeping all these things in mind, let me introduce you to one of the most popular DevOps tools, Jenkins.

What is Jenkins?

Jenkins is an automation tool written in Java programming language and suitable Continuous Integration tasks. It is used for continuous building of projects and you can quickly integrate the changes when needed. Also, Jenkins helps in the rapid deployment of a project by utilizing a wide number of deployment technologies. The acceleration in the development phase is achieved by automating tasks. Like a team lead, Jenkins will continuously check and evaluate the code for identifying unexpected errors early in the development phase.

What is Continuous Integration (CI)?

CI is a software development practice that helps developers to commit changes frequently to the source code in a shared repository. Every commit is pulled continuously and built. Jenkins is a CI tool that continuously builds, pulls, and tests the source code using plugins. in this blog, we will discuss the Jenkins cheat sheet for beginners that is necessary to learn before you start with the software development process using DevOps.

Quick History

In the year 2006, Kohsuke started a project with the name Hudson. Later on, the name of this project was changed to Jenkins, instead of Hudson. If you are searching for Jenkins and find some information about the Hudson then you don’t have to get surprised because both are the same things. Hudson’s project is still into existence but in the corporate world. At the same time, Jenkins is on fire these days and getting huge acceptance by DevOps users worldwide.

Jenkins Installation

In this section, we will discuss the installation of Jenkins on Ubuntu. Here are the steps, you need to follow while installing Jenkins on Ubuntu.

  • First of all, you should install Java. $ sudo apt update $ sudo apt install openjdk-8-jdk
  • In the second step, the Jenkins repository should be added. $ wget -q -o -https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
  • Now, add the Jenkins Repository to the system $sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable_binary/>/etc/apt/sources.list.d/jenkins.list'
  • In the 4th step, you should install Jenkins $ sudo apt update $ sudo apt install Jenkins
  • Once you have setup the installation, it is the right time to verify the Jenkins Installation. $systemctl status Jenkins
  • Now, Jenkins is ready to run on your system, you can access it through the following link. http://localhost:8080

Various Jenkins Jobs

When using Jenkins, you can work on the following jobs during the software development process.

Read: What is Chef Programming Language? Chef Tutorial Guide for Beginner

Various Jenkins Jobs

  • Freestyle: This Jenkins job can be used for almost any type of project to provide the maximum flexibility.
  • Pipeline: Using this Jenkins job, instead of running multiple jobs for different stages of software development, you can run the entire workflow as a single code.
  • Multiconfiguration: This Jenkins jobs allows you to run and test the same project into different development environments.
  • Folder: This job allows developers to build folders and create similar types of jobs in one or more folders.
  • GitHub Organization: This Jenkins job will help to create multiple pipeline jobs for each repository that contains a Jenkins File.
  • Multibranch Pipeline: It helps you to implement different Jenkins Files for multiple branches of the same project.

What is Jenkins Pipeline?

Using the Jenkins Pipeline, you can run the entire workflow as a single code, instead of running multiple jobs for different stages of software development. The code is stored in the Jenkins file and it is written using the Groovy DLS programming language. It is based on the following two syntaxes.

First is the Scripted Pipeline and the other is Declarative Pipeline. In the Scripted Pipeline, the code is written using the Jenkins UI instance and enclosed within the node block. Its syntax can be given below.

node {
scripted pipeline code
}

For the declarative pipeline, the code is enclosed within the pipeline block and it is written locally within a file.

Pipeline {
declarative  pipeline code
}

Steps for Creating a Pipeline in Jenkins

Once you are sure of what is Pipeline and its different types, let us see how to create a pipeline in Jenkins. Using the following steps, you can create both types of pipelines in Jenkins, either it is scripted pipeline or declarative pipeline.

  1. First of all, login to the Jenkins platform and Chose “New Item” option from the dashboard.
  2. In the next step, enter the name of the pipeline according to the nature of the project and select the option “Pipeline Project” then choose “OK” to move the next step.
  3. Also mention if you want to build a scripted or declarative pipeline. For this purpose, you have to scroll down and choose the needed option.
  4. If you have chosen the Scripted Pipeline option then you have to work on the Pipeline Script and start typing your code.
  5. For the Declarative Pipeline, the approach will be different and you have to select the Pipeline script from SCM and enter the repository URL.
  6. Here, you should add the path of the script and give the name of Jenkins file that can be accessed through SCM. Now, click on the Apply button and choose the “Save” button.

Plug-ins in Jenkins

Jenkins installation comes with 2K+ plugins and each has unique functionality. When it comes to the software development process then most commonly plug-ins that are preferred by developers are given below.

Read: DevOps Engineer Salary in India – What You Really Need to Know

Plug-ins in Jenkins

You should follow the below steps for installing the above plugins or this step can be used to install almost any Jenkins plugin.  Go to the Jenkins Dashboard, choose the option “Manage Plugins” and browse the list of available plugins. Here, you can search your favorite plugin and install it on your Jenkins framework right away to make the development process easier.

Building Pipeline with Example

The pipeline concept in Jenkins is used for chaining various jobs together and you can run them together into a sequence. Let us understand how to build a pipeline in Jenkins with an example.

Go to the Jenkins Dashboard, choose the option “Manage Plugins” and browse the list of available plugins. Here, you can search your favorite plugin and install it on your Jenkins framework right away to make the development process easier.

  • In the first step, generate 3 jobs that are freestyle in nature. This Jenkins job is used for almost any type of project to provide maximum flexibility.
  • You must be wondering how to chain all 3 jobs together. Here is a quick method for the integration of all 3 jobs in the easiest way.
  • Now, you have to add a view to the pipeline. For this purpose, go to the Jenkins Dashboard, add a view, Enter the name for the view, build a pipeline view then choose the “OK” option. Moving ahead, you have to configure the view where you can browse for the pipeline flow option, select initial jobs then choose OK option in the end.
  • Once you have added jobs, integrated them, and added a view for each of the jobs. It is the right time for running the Build Pipeline.
  • Congratulations, you are done!

Jenkins Pipeline Basics

When you are working on Jenkins Pipeline, you must be aware of basic terminologies to use each of the options in the best way. In this section, we will discuss a few common Jenkins terminologies that are common for both, either scripted or declarative pipeline.

  1. What is Pipeline? – It is a block defined by users and contains all types of stages. It is taken as an important part of the declarative pipeline syntax.
  2. What is Node? - It can be referred to as a machine that is generally used to execute the entire workflow in Jenkins. It is taken as the important part of the scripted pipeline syntax.
  3. What is Scripted Pipeline? - . In the Scripted Pipeline, the code is written using the Jenkins UI instance and enclosed within the node block.
  4. What is Declarative Pipeline? - For the declarative pipeline, the code is enclosed within the pipeline block and it is written locally within a file.
  5. What is Agent? – It instructs Jenkins on how to allocate resources for the build. It can be used for the entire pipeline or it can be utilized at a particular stage. The different parameters of the agent are discussed below.Jenkins agent
    • Any” option is used to run a pipeline or a stage for an available agent.
    • None” option is used for the root of the pipeline and it indicates that there is no global event for the complete pipeline and each stage should its own agent.
    • The third parameter is “Label” that executes the pipeline or stage for the labeled agent.
    • Steps parameter is used to carry out jobs in a sequence.
    • Last is the “Docker Container” that is used as the execution environment for the pipeline at a particular stage.

Jenkins Pipeline Example:

node {
state ('SCM checkout') {
//checkout from your SCM (Source control Management)
//for ex: Git Checkout
}
State('Build') {
//compile code
//install dependencies
//perform Unit Test, Integration Test
}
state ('Test') {
//resolve test server dependecies
//perform UAT
}
Stage ('deplou') {
//deploy code to prod server
//solve dependency issues
}

Tips & Tricks for Jenkins

You must be eager to know how to start, restart, or stop the Jenkins? Here are the commands to follow for your reference. These commands are easy to run and learn.

Read: What Is Artificial Intelligence? A Beginner Guide To Artificial Intelligence
$sudo service Jenkins restart
$sudo service Jenkins stop
$sudo service Jenkins start

In the next step, let us see how to design a custom build in Jenkins using the core plugin? When you are using the plugin, most of the work is done by the plugin and you just have to set or configure features. Here are the basic steps to follow for building a customized pipeline. You can play with command and work as per the requirement. The only condition is that you should know how to work on the tool and a basic idea of Linux/Unix commands too. It will help you to learn the tool quickly.

  • First, you have to initialize the Jenkins.
  • Now, you have to copy the Code to $Jenkins_Home/plugins.
  • Remove the directory that was expanded earlier.
  • Now, you have to create an empty file with the name <plugin>.hpi.pinned
  • After this, you can start Jenkins and your custom build is ready.

How to create a Snippet Generator?

Snippet Generator is a tool used to create code in a scripted pipeline. Let us understand the concept with the help of an example.

  • In the first step, create a pipeline job then click the configure option.
  • After this, go to the pipeline definition and work on the pipeline script.
  • Now, click the pipeline syntax and go to the snippet generator option.
  • Now, select Git and give the repository URL.
  • Now, scroll down and write the code for Pipeline script.
  • In the last step, copy the script into the UI of the pipeline script.

Security Feature in Jenkins

  • Jenkins can secure configurations for multiple users in place.
  • Go to manage Jenkins’ options and configure global security features.
  • Now set parameters and enable the security section.
  • In the next step, add users and go to the manage user option to add permissions.
  • Now set authorization by configuring global security options and click on matrix-based security options
  • In the end, add the required permission for the user.

Now, you have the basic idea of the tool and you are ready to enter the DevOps space with depth knowledge of Jenkins features and commands. Also, you can build pipeline and club multiple jobs together to save resources and to increase the deployment time.

Final Steps:

Jenkins Cheat Sheet for beginners is a must go through the blog for people who want to learn Jenkins or want to get into DevOps space. It is not easy learning all features and commands theoretically but you have to practice them thoroughly.

JanBask Training offers instructor-led LIVE practical training where you will be assisted on how to install Jenkins on your system and start working over it. Most importantly, you will get a chance to work on a minimum of two Jenkins projects and enhance your skills to implement in the workplace.

So, join the Jenkins training program right away and start learning the amazing DevOps tools with the JanBask Training team right away.

Read: What is Nagios? Nagios Configure & Install Tutorial Guide for Beginner


fbicons FaceBook twitterTwitter lingedinLinkedIn pinterest Pinterest emailEmail

     Logo

    JanBask Training

    A dynamic, highly professional, and a global online training course provider committed to propelling the next generation of technology learners with a whole new way of training experience.


  • fb-15
  • twitter-15
  • linkedin-15

Comments

Trending Courses

Cyber Security Course

Cyber Security

  • Introduction to cybersecurity
  • Cryptography and Secure Communication 
  • Cloud Computing Architectural Framework
  • Security Architectures and Models
Cyber Security Course

Upcoming Class

-0 day 22 Nov 2024

QA Course

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing
QA Course

Upcoming Class

1 day 23 Nov 2024

Salesforce Course

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL
Salesforce Course

Upcoming Class

-0 day 22 Nov 2024

Business Analyst Course

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum
Business Analyst Course

Upcoming Class

-0 day 22 Nov 2024

MS SQL Server Course

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design
MS SQL Server Course

Upcoming Class

1 day 23 Nov 2024

Data Science Course

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning
Data Science Course

Upcoming Class

-0 day 22 Nov 2024

DevOps Course

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing
DevOps Course

Upcoming Class

5 days 27 Nov 2024

Hadoop Course

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation
Hadoop Course

Upcoming Class

-0 day 22 Nov 2024

Python Course

Python

  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation
Python Course

Upcoming Class

8 days 30 Nov 2024

Artificial Intelligence Course

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks
Artificial Intelligence Course

Upcoming Class

1 day 23 Nov 2024

Machine Learning Course

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning
Machine Learning Course

Upcoming Class

35 days 27 Dec 2024

 Tableau Course

Tableau

  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop
 Tableau Course

Upcoming Class

-0 day 22 Nov 2024

Search Posts

Reset

Receive Latest Materials and Offers on DevOps Course

Interviews