Jenkins Jenkins Agents and Distributed Builds 2 — Questions and Answers
Question 1: What is an inbound (JNLP) Jenkins agent?
- An agent that is always connected to the controller
- An agent that initiates the TCP connection outward to the controller (agent connects to Jenkins) (Correct answer)
- An agent running inside Jenkins itself
- An agent that only runs scheduled jobs
Correct answer: An agent that initiates the TCP connection outward to the controller (agent connects to Jenkins)
An inbound or JNLP agent initiates the connection from the agent to the controller, which is useful when the controller cannot reach the agent directly.
Question 2: What is the advantage of using Docker containers as Jenkins agents?
- They provide persistent workspaces across builds
- They offer clean, isolated, and reproducible build environments that are discarded after each build (Correct answer)
- They reduce Jenkins plugin requirements
- They allow builds to run without a controller
Correct answer: They offer clean, isolated, and reproducible build environments that are discarded after each build
Docker agent containers provide a clean, isolated environment for each build, ensuring reproducibility and preventing dependency pollution between builds.
Question 3: What is the purpose of the 'Node' block in a Scripted Pipeline?
- Defines a network node for Jenkins
- Allocates an executor on a specified agent to run a block of pipeline code (Correct answer)
- Creates a new Jenkins agent
- Configures a Kubernetes node pool
Correct answer: Allocates an executor on a specified agent to run a block of pipeline code
In Scripted Pipeline, the `node` block allocates an executor on a matching agent and wraps the code that should run in that agent's workspace.
Question 4: How can you limit which jobs run on a specific Jenkins agent?
- By setting an IP whitelist on the agent
- By using labels on the agent and specifying those labels in job configurations (Correct answer)
- By configuring a job whitelist in agent settings
- By disabling the agent between specific builds
Correct answer: By using labels on the agent and specifying those labels in job configurations
Labels assigned to agents are matched by job configurations or pipeline `agent` directives to control which jobs run on which agents.
Question 5: What happens to an agent's workspace after a build completes by default?
- It is deleted automatically
- It persists on the agent filesystem for the next build of the same job (Correct answer)
- It is archived to the controller
- It is compressed and stored for 30 days
Correct answer: It persists on the agent filesystem for the next build of the same job
By default, Jenkins keeps the workspace on the agent between builds to enable faster incremental builds by reusing previously checked-out files.
Question 6: What is the Jenkins Kubernetes Plugin's pod template used for?
- Defining the Docker image used in Docker Pipeline steps
- Specifying the containers, resources, and configuration of the Kubernetes pod used as a build agent (Correct answer)
- Configuring Kubernetes cluster credentials
- Templating Helm chart values for deployment
Correct answer: Specifying the containers, resources, and configuration of the Kubernetes pod used as a build agent
A pod template defines what containers, volumes, and resource requests the dynamically provisioned Kubernetes build agent pod should have.
What is an inbound (JNLP) Jenkins agent?