【 note 】 this article translation: www.edureka.co/blog/jenkin…
This article focuses on the Jenkins architecture and the Jenkins build pipeline, and shows you how to create a build in Jenkins. Now is the right time to learn about Jenkins’ architecture.
Jenkins architecture
Let’s modify the separate Jenkins architecture that I explained to you in my last blog. The diagram below depicts the same architecture.A single Jenkins server is insufficient to meet certain requirements, such as:
- Sometimes you may need several different environments to test your build. A single Jenkins server cannot complete this operation.
- If larger, heavier projects are built on a regular basis, a single Jenkins server will not be able to simply handle the entire load.
In order to meet the above requirements, Jenkins distributed architecture is introduced.
Jenkins Distributed architecture
Jenkins uses a master-slave architecture to manage distributed builds. In this architecture, the master and slave communicate via the TCP/IP protocol.
Jenkins master node
Your primary Jenkins server is the primary node. The job of the master node is to handle:
- Schedule a build job.
- The build is dispatched to the slave node that actually executes.
- Monitor slave nodes, possibly bringing them online and offline as needed.
- Document and display build results.
- Jenkins’ primary node can also perform the build job directly.
Jenkins from node
Slave nodes are Java executables running on remote computers. The following are the characteristics of Jenkins from nodes:
- Receive a request from Jenkins’ primary contact.
- Slave nodes can run on a variety of operating systems.
- The slave node’s job is to follow orders, including executing build jobs assigned by the master node.
- You can configure the project to always run on a specific slave node or a specific type of slave node, or just let Jenkins choose the next available slave node.
The figure below is self-explanatory. It is managed by one Jenkins master node and three Jenkins slave nodes.Now, let’s look at an example where Jenkins is used to test in different environments, for example: Ubuntu, MAC, Windows, etc. As shown below:Perform the following functions in the figure above:
- Jenkins periodically checks the Git repository for any source code changes.
- Each build requires a different test environment, which is not possible for a single Jenkins server. To perform tests in different environments, Jenkins used a variety of slave nodes, as shown in the figure.
- The Jenkins master node requires these slave nodes to perform tests and generate test reports.
Jenkins builds the pipeline
It is used to understand the task Jenkins is currently performing. Often, several developers are making several different changes at the same time, so it is useful to know which changes are being tested, which are being queued, or which builds are broken. This is where the pipe appears. The Jenkins pipeline gives you an overview of the testing scope. In the build pipeline, the entire build is subdivided into parts, such as unit testing, acceptance testing, packaging, reporting, and deployment phases. Pipeline phases can be executed serially or in parallel, and if one phase succeeds, it automatically moves to the next phase (thus having the relevance of the “pipe” name). The following figure shows the appearance of multiple build pipes.Hopefully you’ve understood the theoretical concepts. Now, let’s have a hands-on experience. I’m going to create a new assignment in Jenkins, and this is aFreestyle event. However, there are three options available. Let’s take a look at the types of build jobs available in Jenkins.
Freestyle events:
A freestyle build job is a generic build job that provides maximum flexibility. The freestyle build job is the most flexible and configurable option available for any type of project. Setup is relatively simple, and many of the options we configured here also appear in other build jobs.
Multiple configuration jobs:
Multi-configuration projects (also known as matrix projects) allow you to run the same build job on different environments. It is used to test applications on different environments, different databases, and even different build machines.
Monitor external jobs:
By building jobs by monitoring external jobs, you can focus on non-interactive processes, such as CRon jobs.
Maven project:
The Maven 2/3 Project is specifically adapted to the build effort of the Maven project. Jenkins understands Maven POM files and project structure, and can use the information gleaned from the POM files to reduce the effort required to set up the project.
Create a build using Jenkins
** Step 1: ** From the Jenkins interface home page, selectNew Item.** Step 2: ** Enter a name and selectFreestyle project. Step 3:On the next page, you can specify the job configuration. You will soon find that there are many Settings available when creating a new project. On this configuration page, you can also choose to add build steps to perform additional operations, such as running scripts. I will execute a shell script.This will provide you with a text box in which you can add any commands you need. You can use scripts to run a variety of tasks, such as server maintenance, version control, reading system Settings, and so on. I’ll use it to run simple scripts.** Step 4: ** Save the project and you will be taken to the project Overview page. Here, you can view information about the project, including its build history.** Step 5: ** Click build Now on the left to start building.** Step 6: ** To see more information, click on the build in the Build History area, which will take you to a page with an overview of the build information.** Step 7: The ** console output link page is particularly useful for scrutinizing job results.** Step 8: ** If you go back to the Jenkins home page, you will see an overview of all projects and their information, including status.The generated state is represented in two ways, one is a weather icon, the other is a color ball. The weather icon is particularly useful because it can display multiple versions of records in a single image. As shown above, the sun represents the success of all my constructions. The color of the ball gives us the state of that particular build; in the figure above, the color of the ball is blue, indicating that that particular build was successful.