Jenkins Jenkins Distributed Builds 2 — Questions and Answers
Question 1: How do you add a new permanent agent in Jenkins?
- Go to Manage Jenkins > Manage Nodes and Clouds > New Node (Correct answer)
- Use the Jenkins CLI `add-node` command only
- Edit config.xml directly
- Create a Dockerfile for the agent
Correct answer: Go to Manage Jenkins > Manage Nodes and Clouds > New Node
Permanent agents are added through Manage Jenkins > Manage Nodes and Clouds > New Node, where you configure the agent's connection method, label, and root directory.
Question 2: What does 'number of executors' define on a Jenkins agent?
- The number of concurrent builds the agent can run simultaneously (Correct answer)
- The number of CPU cores allocated to Jenkins
- The number of pipelines the agent can store
- The maximum number of plugins active on the agent
Correct answer: The number of concurrent builds the agent can run simultaneously
Each executor on an agent represents one concurrent build slot; an agent with 4 executors can run 4 builds simultaneously.
Question 3: In Jenkins, what is an 'ephemeral agent'?
- An agent that is dynamically provisioned for a single build and destroyed afterward (Correct answer)
- An agent that runs offline most of the time
- A test agent that never saves state
- A virtual agent without a real OS
Correct answer: An agent that is dynamically provisioned for a single build and destroyed afterward
Ephemeral agents (common with Kubernetes or Docker plugins) are created on-demand for each build and removed after the build completes, ensuring clean environments.
Question 4: What is the Jenkins 'availability' strategy `Take this agent offline when idle` used for?
- Automatically disconnect the agent after a period of inactivity to save resources (Correct answer)
- Shut down the agent OS when idle
- Prevent new builds when the agent is busy
- Mark the agent as offline after a build failure
Correct answer: Automatically disconnect the agent after a period of inactivity to save resources
This availability strategy disconnects the agent after a configurable idle delay, useful for cloud or expensive agents to reduce costs when not in use.
Question 5: How does the Jenkins SSH Build Agents plugin connect to an agent?
- The controller SSHes into the agent and starts the agent process (Correct answer)
- The agent SSHes into the controller
- Uses SSH tunneling for JNLP
- Agent uses SSH key to authenticate to Jenkins REST API
Correct answer: The controller SSHes into the agent and starts the agent process
With the SSH Build Agents plugin, the Jenkins controller initiates an SSH connection to the agent machine and remotely starts the Jenkins agent JAR process.
Question 6: What environment variable is automatically set by Jenkins to identify the agent name where a build runs?
- NODE_NAME (Correct answer)
- AGENT_NAME
- BUILD_NODE
- JENKINS_AGENT
Correct answer: NODE_NAME
Jenkins automatically sets the `NODE_NAME` environment variable to the name of the agent (or 'built-in' for the controller) where the current build is running.
How do you add a new permanent agent in Jenkins?