Showing posts with label jenkins agent. Show all posts
Showing posts with label jenkins agent. Show all posts

Saturday, 6 December 2025

How to Add a windows Agent to jenkins

 Prerequisite

  • Jenkins controller: Ubuntu 22 on AWS EC2

  • On Controller (Ubuntu Jenkins)

    • Port 8080 open

    • Port 50000 open

  • New agent: Windows Server (or Windows 10/11)--Lunch a new windows instance.


Then launch.... when instance is running ...Click connect to see how to connect ...then click Rdp ang get password to get password



Click Decrypt pasword to get password




Open RDP on your computer
Enter computer: Public Dns
Username: Administrator
Click connect and Enter the password




1. Prep the Windows machine

On the Windows box (the future agent):

  1. Install Java (same major as controller, e.g. JDK 17 or 21)

  2. Add Java to PATH (optional but helpful)

    • System Properties → Advanced → Environment Variables

    • Under System variables, edit Path → add:
      C:\Program Files\Java\jdk-21\bin

  3. Create a Jenkins work directory

    • For example: C:\jenkins

    • Make sure the user that will run the agent (e.g. jenkins or your login) has full rights.



  4. Network

    • Windows server must be able to reach the Jenkins URL over HTTP/HTTPS

    • If using inbound TCP agent port (default 50000), make sure it’s open on security group if needed

2. Create the Windows node in Jenkins

On the Jenkins controller UI:

  1. Go to Manage Jenkins → Nodes (or “Manage Nodes and Clouds”).

  2. Click New Node.

  3. Name it e.g. windows-agent-1.

  4. Choose Permanent Agent → OK.

Fill in:

  • # of executors: 1 (or more if the box is strong)

  • Remote root directory: C:\jenkins

  • Labels: e.g. windows maven (you’ll use these in jobs)

  • Usage: “Use this node as much as possible”

Launch method (very important)

Set Launch method to:

Launch agent by connecting it to the controller

This means the Windows machine will run java -jar agent.jar and connect in.

Click Save.

You’ll now see the node page with instructions like “Launch agent”, “jnlp” etc.



Save 
Then from the Agent browser browse to the Jenkins







Copy the 2 commands and run from the Agent commandline




if you face issues or errors; check if port is open and all firewall

Run on Jenkins Terminal
sudo ufw allow 8080/tcp






Your Agent is now connected 




Thursday, 17 September 2020

How to Specify Particular Jenkins Agent(Slave) to Build jobs

 When you have multiple agent available, whether you are using a classic job type (Freestyle, Maven, etc) or a Pipeline (even Multibranch Pipeline), you can select a specific agent to build your project.

In a classic job type, you will find a Restrict where this project can be run checkbox and text field in the properties of the job



In a (Multibranch) Pipeline, you can specify this in the parameter of the node block:

node('foo') {}

The value of both the text field and the node parameter are the same: it can be the agent name, or a Groovy boolean expression.

Using the agent name, you make the job tied to this specific agent. This can be problematic when the build load grow, your agent becomes less and less available.

The best solution is to use the labels. When you configure your agents, you can put a space-separated list of labels on your agent. Those can be used to describe what the agent can be used for: mavennpm, etc. It can also describe what the agent is running on: windowslinuxx64, etc. This will create pools of agents based on the labels. Then, on your job configuration, you can use those label in a Groovy boolean expression to select the correct agent for your job:

  • “I need an agent running on linux”: linux
  • “I need an agent running on windows with maven”: windows && maven
  • “I need an agent with a jdk-8 and running either on windows x32 or linux x64”: jdk-8 && ((windows && x32) || (linux && x64))

The expression can be as complex as you need. However, the expression cannot be a regexp. It can only be a boolean expression.





Bash Script to Install Artifactory in Ubuntu 22

JFrog Artifactory OSS 7.21.5 — Install (Bash Script) This script installs Artifactory OSS (no Docker, no Pro, works on Ubuntu 22 EC2). ...