Checkpoint Lab — SSH, Inbound, WebSocket, Windows, and Ephemeral Agents: Connectivity, Remoting, and Agent Lifecycle
Operate a remote-style disposable agent through connect, build, forced disconnect, safe recovery, destroy/recreate, and evidence capture while preserving exact build/source attribution and removing bootstrap credentials at the end.
Learning objectives
- Bring up one disposable remote-style WebSocket agent with explicit Java/Remoting/image identity.
- Predict and verify connection, queue, workspace and retained-build state changes.
- Force one bounded disconnect and diagnose its actual effect before reconnecting.
- Replace the worker/node identity and prove the new agent executes the same workload.
- Destroy ephemeral worker state while retaining build/source/artifact attribution and excluding secret values.
1. Scenario
You maintain a Jenkins controller behind HTTPS. General CI workers are agent-initiated because the controller cannot initiate connections into the worker network. Build evidence must survive worker replacement. Your task is to create one disposable WebSocket worker, run a build, force a disconnect, recover once, then replace the worker identity entirely.
2. Baseline and assumptions
- Jenkins
2.568.3 LTS; controller Java 21. - Agent JVM: Java 21.
- Built-in node executors:
0. -
Primary node:
ch18-ws-a, labelch18-remote, one executor. -
Reviewed container option:
jenkins/inbound-agent:3391.va_37fa_a_305d6d-2-jdk21; record architecture-specific digest if used. -
Manual-JAR option:
agent.jardownloaded from this controller. - No proprietary repository, production credential or external deployment target.
3. Preflight evidence
Record:
- controller core and Java versions;
- node name, labels, executor count, launcher and remote root;
- agent Java version and Remoting/image identity;
- Jenkins URL hostname and whether WebSocket traverses a proxy;
- source repository URL + exact commit SHA for the synthetic Jenkinsfile;
- build job full name and expected artifact name;
Record only the inbound credential reference/handling method, never the secret.
4. Predict two state changes before acting
-
Disconnect prediction: when
ch18-ws-ais terminated, Jenkins will mark the node offline; one new job requiringch18-remotewill wait rather than run on the built-in node. -
Recreation prediction: after replacing the worker
with
ch18-ws-b, the old workspace disappears, but build A’s Jenkins record and archived evidence remain addressable by the original build number/source SHA.
5. Checkpoint Pipeline
pipeline {
agent { label 'ch18-remote' }
options { timestamps(); timeout(time: 5, unit: 'MINUTES') }
stages {
stage('Capture') {
steps {
sh '''
set -eu
mkdir -p out
{
echo "job=$JOB_NAME"
echo "build=$BUILD_NUMBER"
echo "node=$NODE_NAME"
echo "labels=$NODE_LABELS"
echo "workspace=$WORKSPACE"
echo "source=${GIT_COMMIT:-synthetic-no-scm}"
id
java -version 2>&1 | head -n 3
} | tee out/agent-evidence.txt
sha256sum out/agent-evidence.txt | tee out/agent-evidence.sha256
'''
archiveArtifacts artifacts: 'out/*', fingerprint: true
}
}
stage('Safe wait for disconnect drill') {
steps { sleep time: 90, unit: 'SECONDS' }
}
stage('Post-wait identity') {
steps {
sh 'printf "node=%s workspace=%s\\n" "$NODE_NAME" "$WORKSPACE"'
}
}
}
}
If your Pipeline is SCM-backed, record the exact commit SHA. If it is not, state that limitation explicitly rather than inventing a source identity.
6. Connect ch18-ws-a
Use either the controller’s agent.jar or the pinned
official inbound image. Supply the secret through a protected file
or runtime secret mechanism, not source control or a build
parameter. Confirm the node shows online and capture a redacted
connection log including Remoting version and Java/work-dir
evidence.
7. Run build A and preserve baseline evidence
Trigger the Pipeline. During the safe wait, preserve build number/URL, node/workspace, source SHA, archive digest and agent connection state. This is the baseline that must remain attributable after the worker disappears.
8. Force the disconnect
During the 90-second wait, stop the disposable process/container for
ch18-ws-a. Capture the first disconnect evidence before
taking further action:
- agent log ending/channel close;
- node offline state/cause;
- build A stage/result at that moment;
-
one additional queued build B and its
whytext.
Do not assume build A must resume or must fail; record the actual step behavior.
9. Recover once, safely
Restart ch18-ws-a once using the same valid configured
identity. Capture the reconnection event and final build A state. If
build A does not resume, preserve the error and do not hide it with
repeated retries. Run one short new build only if needed to prove
the node is healthy.
10. Destroy/recreate the agent identity
- Stop
ch18-ws-apermanently. - Preserve evidence from its remote root, then remove the disposable root.
-
Create node
ch18-ws-bwith labelch18-remoteand a new remote root. - Connect using its new inbound material.
- Run build C using the same reviewed Jenkinsfile/source revision.
-
Verify build C records
ch18-ws-band its new workspace while build A remains unchanged.
11. Verification checklist
- Built-in node remained at zero executors throughout.
- Agent Java is supported and Remoting/image identity is recorded.
- Build A remains linked to its original build number, source revision and archived SHA-256 evidence.
- Queued build B never silently ran on the controller.
-
Replacement build C ran on
ch18-ws-bwith a different workspace/root. -
Old
ch18-ws-aworkspace/root was removed after evidence capture. - No inbound secret, SSH key or API token appears in console output or archived files.
- Disconnect/reconnect/replacement timestamps and actual build outcomes are recorded without rewriting history.
12. Required evidence packet
-
baseline.md: Jenkins/Java versions, built-in executors, launcher and proxy assumptions. -
agent-a.md: node labels, remote root, Java, Remoting/image tag+digest and redacted connection evidence. -
build-a.jsonor reviewed metadata: build number/URL/cause/source/node/result. -
agent-evidence.txt+ SHA-256 digest from build A. -
disconnect.md: timestamp, first agent/controller evidence, actual stage/result. -
queue-b.json: reviewed queue item ID/reason while the agent is offline. -
reconnect.md: single recovery attempt and outcome. -
agent-b.md: new node identity, Java/Remoting/image evidence and new workspace root. build-c.json: replacement build attribution.-
teardown.md: old/new worker root cleanup and credential-reference retirement; no secret values. -
assumptions-limitations.md: local simulation boundaries and any missing Windows/SSH direct run.
13. Cleanup and rollback
- Stop replacement agent process/container.
- Remove disposable work directories after reviewed evidence is saved.
- Retire/delete disposable nodes and their inbound material.
- Remove lab-only SSH keys/known-host entries if an SSH variant was used.
- Remove lab-only API credentials.
- Keep only non-secret evidence needed for learning.
14. What Chapter 18 adds to the production operating model
You can now explain an agent connection as a chain of independently verifiable state: controller node configuration selects a launcher; bootstrap identity authenticates the intended peer; transport crosses firewall/proxy/SSH boundaries; Remoting creates the channel; a supported Java process exposes executors/workspaces under an OS identity; and teardown must remove transient worker state without erasing retained build/source evidence.
Chapter 19 builds on this lifecycle model by placing build steps inside Docker environments and examining Docker Pipeline, sidecars, registries and image workflows.
Knowledge check
Answer before revealing the explanation.
1. What must remain attributable after an ephemeral agent is destroyed?
The Jenkins job/build number and URL, source revision, build cause, node name/labels, archived evidence and any external side-effect identifier. The worker filesystem itself may be gone.
2. Why is a forced disconnect not equivalent to a build failure?
It is a transport/lifecycle event. Depending on the step and durability semantics, a build may wait, fail, or recover. Determine the actual run state from the build record and logs instead of assuming.
3. What proves secret rotation succeeded without revealing the secret?
Evidence that the old node/process can no longer authenticate, the replacement node with a new identity connects, provider/controller audit or node-state records show the transition, and no secret value appears in logs/artifacts.
4. What is the correct action if the reverse proxy cannot support the WebSocket lab?
Use the documented inbound TCP path in the disposable environment or fix the proxy configuration. Do not disable TLS/authentication or run the build on the controller as a shortcut.
5. Which evidence should be captured before deleting the disposable agent?
Connection/Remoting/Java metadata, node/label/workspace identity, build and source IDs, disconnect/reconnect timestamps, reviewed logs, artifact digests and teardown/cleanup observations—excluding all secret values.
Official references and version notes
-
Jenkins LTS changelog
and
Java support policy
— lab baseline
Jenkins 2.568.3 LTS; Jenkins system components, including agents, require Java 21 or 25 on this baseline. - Using Jenkins agents and Managing Nodes — distributed execution, node configuration, Windows agent examples, and lifecycle concepts.
-
Jenkins Remoting
and
Launching inbound agents
— obtain
agent.jarfrom the controller; inbound command,-webSocket, work directory, and direct TCP guidance. -
SSH Build Agents plugin
— baseline
3.1097.v868116049892; SSH launch requires verified server identity and least-privilege agent credentials. -
Official Jenkins inbound-agent images
— reviewed lab image line
jenkins/inbound-agent:3391.va_37fa_a_305d6d-2-jdk21. Pin a reviewed tag/digest for repeatable labs rather than usinglatest. - Controller Isolation — keep the built-in node at zero executors and do not use controller-local builds as a connectivity workaround.
- Installing Jenkins — standalone Jenkins uses the supported Jetty/Winstone stack; WebSocket-agent support depends on a compatible servlet/proxy path.
Keep the academy open
Support free, practical DevOps education.
Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this
address.