How to Set Up a New Jenkins Build Agent

choubertsprojects

The Best WordPress plugins!

1. WP Reset

2. WP 301 Redirects

3. WP Force SSL

In this tutorial, we’ll walk through the steps to set up a new Jenkins build agent. The first step will be setting up a proper SSH key for authentication and then moving into configuring our agent with these options: Node.js, GIT repository URL, and some security best practices such as disabling password-based logins.,

Jenkins is a software automation platform that can be used to build, test and deploy applications. This article will show you how to set up a new Jenkins build agent.

How to Set Up a New Jenkins Build Agent

Are you running out of Jenkins executors, or are your Jenkins Windows tasks stuck in a queue? If that’s the case, you’ll need to add additional Jenkins agents.

In this article, you’ll learn how to add a Jenkins agent Windows node to your software development environment to meet an ever-increasing resource demand!

Prerequisites

You’ll need the following items to follow along with this article.

  • Working installation of a Jenkins controller equal to or greater than 2.176.1; the controller is referred to as the master node in this article.
  • Any Windows OS installation that is supported will be referred to as a Jenkins agent node.

What is the difference between Jenkins Agents and Jenkins Agent Controller?

The job is an important part of Jenkins. Jobs are build automation instances that execute a specific set of tasks. Supporting various task configurations necessitates the use of an automation system to distribute build jobs over several nodes, which is basically a Jenkins agent or controller environment.

Jenkins agents can run on physical machines, virtual machines, Kubernetes clusters, and Docker images, among other things. A Jenkins agent is a node-based program that is tasked by the controller with running a job.

The agent controller, often known as the master node, is in charge of managing the many Jenkins agents. The controller, in a single Jenkins node setup, may also operate as a Jenkin agent and conduct build processes. This arrangement becomes restrictive as surroundings get increasingly complicated.

Preventing Jobs from Running on the Controller Master Node

You must first remove the master node from the build agent pool before adding another Jenkins agent. By removing the master node from this pool, the controller is provided with sufficient resources to coordinate construction tasks. The appropriate parameters to prevent the master node from conducting a task are outlined below.

  1. Using a browser, go to the Jenkins user interface. The Jenkins Controller is configured to utilize the IP 192.168.x.x:8080 in this tutorial.

Using Jenkins to access the Dashboard.Using Jenkins to access the Dashboard.

2. When the Jenkins Dashboard displays, choose Manage Jenkins from the drop-down menu.

Select Manage Jenkins from the drop-down menu.Select Manage Jenkins from the drop-down menu.

3. From the System Configuration section, select the Configure System option.

Go to System Configuration.Go to System Configuration.

4. Scroll down the page to the # of executors option and change the number to 0. This option prevents the master node, also known as the controller, from doing any build tasks.

Set the number of executors to 0.Set the number of executors to 0.

5. Find the Jenkins URL on the same page. Instead of localhost:8080, change the URL to the IP address and port used in the browser.

If the agent node’s IP address is wrongly configured, it may try to communicate with the controller using localhost rather than the right IP address. You may prevent future agent communication issues by configuring the correct IP address!

Replace the IP address in Jenkins' URL with the correct one.Replace the IP address in Jenkins’ URL with the correct one.

6. Confirm and apply the new settings by clicking Save.

Inbound Agents TCP Port Configuration

The TCP inbound port parameters must be configured to tell Windows Jenkins Agent nodes how to best run the job service and communicate back to the controller. The Jenkins agent will know how to connect to the Jenkins controller via the network if the TCP incoming port settings are defined.

  1. From the Jenkins dashboard, go to the Manage Jenkins configuration page once again.

2. Locate the TCP port choices in the Configure Global Security section, as shown below.

Go to the Global Security Configuration section.Go to the Global Security Configuration section.

3. Locate the Agents section and the TCP port for incoming agents by scrolling down. Change the Disable option to Random. Jenkins chooses a random accessible port number and shares it with an agent on their first connection to the Jenkins HTTP port when using the random setting.

Set the incoming TCP port for inbound agents to Random.Set the incoming TCP port for inbound agents to Random.

4. Finally, click the Save button to save your changes.

On the Jenkins Controller, create a new Jenkins Agent Node.

It’s time to construct your own Jenkins Agent node once you’ve specified all of the necessary information. Create the working directory on the Windows node first. Create the directory C:Jenkins on the Windows node.

Follow the steps below to setup your new node after the working directory has been established.

  1. Select Manage Nodes and Clouds from the Jenkins dashboard.

To manage nodes and clouds, go to Manage Nodes and Clouds.To manage nodes and clouds, go to Manage Nodes and Clouds.

2. On the left-hand menu, choose New Node. The Nodes list will only display the master node at first if the controller is the sole agent.

In Jenkins, create a new node.In Jenkins, create a new node.

3. Select the option for Permanent Agent and provide a Node name, which in this example is MyWindowsAgent1. You may pick a more suitable identification for your environment. You could also see a Copy Existing Node option if you have more agents. Finally, press the Ok key.

Type in the name and type of the node.Type in the name and type of the node.

4. Set up the new agent using the parameters shown below. The choices marked in green are the defaults.

  • The number of executors is usually equal to the number of agent cores. Below is a PowerShell snippet that will let you do precisely that.

Select-Object -Property Number* | Get-CimInstance -ClassName Win32 Processor | Get-CimInstance -ClassName Win32 Processor

  • Jenkins’ Remote Work Directory is located at C:Jenkins.
  • The agent is launched by connecting it to the master.

Create a new Jenkins Agent node and configure it. Create a new Jenkins Agent node and configure it.

The agent launch options have changed in versions after 2.176.1, according to a recent Cloudbees.com solutions post. “Launch agent by connecting to the master” has replaced “Launch agent through Web Start.”

5. Click the Save button, then go to the Node list page, where you’ll see the new Windows Jenkins Agent node.

6. To get the Agent installation links, click on the name of the new node, MyWindowsAgent1.

Go to the newly created Windows node.Go to the newly created Windows node.

7. Connect to the Windows node where the Jenkins agent will be hosted through a remote desktop (RDP) connection.

8. Open a browser and go to http://controllerip:port/computer/nodename on the soon-to-be Windows agent.

9. Click the Launch button to start the Jenkins agent installation by downloading the agent installer.

To install the agent, follow the instructions and links provided.To install the agent, follow the instructions and links provided.

Steps to Follow

There are several ways to put your newfound agents to work. There are various options to automate your build environment, from running PowerShell scripts in Jenkins to running Jenkins in Docker!

Jenkins is a software automation server that allows users to build, test, and deploy applications. This article will teach you how to set up a new Jenkins Build Agent on Linux. Reference: how to install jenkins agent on linux.

Related Tags

  • launch agent by connecting it to the controller
  • jenkins agent windows
  • jenkins agent configuration
  • install jenkins agent windows
  • jenkins node configuration

Table of Content