docker run … eclipse-temurin:17-jre java -jar jenkins.war shows the Java version error; right side opens the Java support policy table, highlighting “Java 21/25 from 2.555.1 on”.Jenkins Hour 8 (optional): 50 Production Issues + 50 Interview Questions
- Given a raw error message, be able to tell which installation/plugins/upgrades, Pipeline & builds, agents/credentials/cloud deployment, security/performance/operations layer it falls into, and name the first diagnostic command.
- Understand the mechanisms: Java version checks, the plugin dependency graph and
Failed to load, CPS execution and persistence (whyNotSerializableException), the Script Security sandbox, and the reasons the queue blocks (CauseOfBlockage), remoting channels, credential lookup (ID + scope + type), CSRF crumbs and API tokens, and the permission matrix. - Be able to work in a
~/jenkinslabCompose environment or kind clusterlabto reproduce, diagnose, fix and clean up 16 typical faults; for cloud-platform issues, diagnostic commands and sample expected output are provided. - Be able to answer the 50 Jenkins interview questions using the structure “30-second answer → principles → code → production experience”, and handle common follow-up questions.
- Use mock interviews (timed + self-assessed) to measure your mastery rate and find weak modules.
1-Hour Time Allocation Table
| # | Time | Module | Core Content | Animations · Interactive | Labs |
|---|---|---|---|---|---|
| 0 | Before Class | Usage Guide & Fault Lab Environment | Reuse ~/jenkinslab (jenkins + agent1 + gitea); API token,lab8 folder and two helper scripts | Environment self-check | Generate mkjob.sh / runjob.sh |
| 1 | 00–08 | A · Installation, Plugins & Upgrades | Issues 1–12: Java version too old, volume permissions, plugin dependency failures, core version too low, plugin disabled, update center certificate, old data, reverse proxy, NoSuchMethodError after upgrade, image tag drift, jenkins-plugin-cli conflict, empty Jenkins URL | Controller startup sequence fault simulator | Java 17 startup · volume permissions · plugin disabled · plugin-cli conflict |
| 2 | 08–16 | A · Pipeline & Builds | Issues 13–25: NotSerializableException, sandbox rejection, Method too large, No such DSL method, Invalid agent type, secret interpolation warning, CPS method mismatch, exit code, wrapper script, revision not found, Jenkinsfile not found, Webhook not triggering, shared library structure | “Pipeline failed” troubleshooting tree | Matcher serialization · sandbox · Declarative validation · secret interpolation |
| 3 | 16–24 | A · Agents, Credentials & Cloud Deployment | Issues 26–38: label with no nodes, executor exhaustion, inbound port unreachable, channel closed, SSH host key, insufficient disk, credential not found / wrong type, Docker socket, Pod creation rejected, OOMKilled, Azure federated credentials, AWS credentials | “Build doesn't run / breaks midway” troubleshooting tree | Label errors · agent offline · credential ID · Pod OOM (kind) |
| 4 | 24–30 | A · Security, Performance & Operations | Issues 39–50: No valid crumb, Overall/Read, SSO callback URL, builds on the built-in node, security warnings, heap out of memory, controller slowdown, disk full, cron jobs bunching up, JCasC unknown attribute, credentials undecryptable after restore, two controllers sharing JENKINS_HOME | Simulator of a single request's authentication chain | crumb · memory diagnostics · JCasC validation · disk thresholds |
| 5 | 30–37 | B · Architecture & Fundamentals | Interview 1–13 | Mock Interview | 2 scenario questions |
| 6 | 37–44 | B · Pipeline Design | Interview 14–25 | Mock Interview | 2 scenario questions |
| 7 | 44–52 | B · Scaling, Kubernetes & Cloud | Interview 26–38 | Mock Interview | 3 scenario questions |
| 8 | 52–60 | B · Security Governance & Scenario Design | Interview 39–50 | Mock Interview | 3 scenario questions |
| — | After Class | Cheat Sheet · Comprehensive Drill | 50 “error → first command → fix” entries; 50 flashcards; 8 mixed faults; full mock interviews | Full Mock Interview | 12-question final quiz |
Knowledge Coverage Matrix
| Topic | m1 | m2 | m3 | m4 | m5 | m6 | m7 | m8 |
|---|---|---|---|---|---|---|---|---|
| controller / agent / queue / executor | — | — | ● | ● | ● | — | ● | — |
| Installation, Java, Docker images, upgrades | ● | — | — | ● | ● | — | ● | — |
| Plugin dependencies & governance | ● | ● | — | ● | ● | — | — | ● |
| Pipeline / CPS / shared libraries | — | ● | — | — | ● | ● | — | ● |
| SCM / Multibranch / Webhook | ● | ● | — | — | ● | ● | — | — |
| Credentials & secrets | — | ● | ● | ● | ● | ● | ● | ● |
| Kubernetes plugin / Helm chart | — | — | ● | ● | — | — | ● | ● |
| Azure / AWS keyless authentication | — | — | ● | — | — | — | ● | ● |
| Authentication, authorization, CSRF, Script Security | — | ● | — | ● | — | ● | — | ● |
| Performance, JVM, backup, JCasC | ● | — | — | ● | ● | ● | ● | ● |
Not covered in this course (where to learn)
- Jenkins basics (setup wizard, first Jenkinsfile, credentials) → Lesson 1; full walkthrough of Pipeline syntax and Multibranch → Lesson 2.
- Full pipelines for deploying to Azure / AWS → Lesson 3 / Lesson 4; JCasC, Job DSL, shared libraries and deploying Jenkins with Helm → Lesson 5; SSO, RBAC, Script Security and the supply chain → Lesson 6; troubleshooting methodology and migration → Lesson 7.
- Problems with the container image itself (Dockerfile, image size, build cache) → Docker 8 Hours; Pod scheduling, CrashLoopBackOff and other Kubernetes-native faults → Kubernetes 8 + 1 Hours; Helm release issues → Helm Lesson 8. This lesson only covers issues that surface “through Jenkins”.
- Faults in GitHub Actions / Azure Pipelines themselves → GitHub 8 Hours · Azure DevOps 8 Hours.
- Developing Jenkins plugins (Java, Stapler, Jelly) → refer to the jenkins.io developer documentation; not covered in this course.
How to Use This Course
- Open the corresponding module's Quick View, paste the most distinctive words from the error (such as
NotSerializable,not permitted,label,crumb) into the filter box. - Click a table row to jump straight to Issue Details, and follow “diagnose → compare with the output → fix”.
- Not sure which layer it is? Use the Animations tab's decision trees / simulators.
- First look at the Quick View, and pick out the questions you're unsure about, by difficulty.
- Mock Interview: random questions, a 2-minute countdown, answer first and then check, self-rate as “got it / partial / didn't know”; scores are saved in this browser.
- Answer structure: One-sentence conclusion → principle → code/commands → pitfalls.
- Cheat Sheet Suitable for printing and posting at your desk.
- Comprehensive Drill: 8 mixed faults + full mock interview (10 chosen from 50) + final quiz.
- Each question links back to the matching module in Lessons 1–7, so you can revisit it.
Entry structure of Parts A / B
Symptom → root cause (at the mechanism level) → diagnostic command → sample expected output → fix → prevention & best practices → see Lesson N. Titles use the exact error text Jenkins actually prints where possible: strings marked “source verified” have been checked against the current source of the jenkinsci repositories (Jenkins core, workflow-cps, pipeline-model-definition, credentials-binding, kubernetes, configuration-as-code, remoting, docker image scripts, etc.); parts from the JVM, Docker, Git, Gitea and cloud CLIs are marked “check against actual output”.
Question → 30-second answer → in-depth answer (principles, code) → common follow-ups → bonus points → common wrong answers. Difficulty:BeginnerIntermediateAdvanced.
Relationship to the First Seven Lessons
| Lesson | Most-referenced content in this lesson |
|---|---|
| Lesson 1 Core Fundamentals | controller/agent/executor/queue, Docker images and setup wizard, plugin system, credential basics,~/jenkinslab |
| Lesson 2 Pipeline Core | CPS and persistence, Declarative/Scripted, agent/when/parallel, stash, Docker agent, Multibranch and Webhook |
| Lesson 3 Azure · Lesson 4 AWS | Managed identities, workload identity, OIDC, instance profiles, ACR/ECR pushes, cloud agents |
| Lesson 5 Configuration as Code & Kubernetes | JCasC, Job DSL, shared libraries, Helm chart, Kubernetes plugin, backup & upgrade, monitoring |
| Lesson 6 Enterprise Security & Governance | Authentication/authorization/CSRF, SSO & RBAC, credential domains & external secrets, Script Security, plugin security, auditing |
| Lesson 7 Deep Troubleshooting | Logs & script console, stuck queues, CPS/serialization/sandbox, plugin conflicts, JVM performance, high availability & migration |
jenkins/jenkins:2.580.2-jdk21 (also -lts-jdk21,-jdk25 and other tags). The official Helm chart jenkins/jenkins latest 5.13.3 (appVersion 2.580.2). Plugin versions are listed at the source page. All “expected output” shown is illustrative, and names, times and version numbers will differ from your environment.Module 0 · Usage Guide & Fault Lab Environment
~/jenkinslab (jenkins + agent1 + gitea) from Lesson 1 and the kind cluster from Lesson 5 lab, create a new lab8 folder used only for “creating faults”- Confirm that the three Compose services are healthy, Jenkins is version 2.580.2, and agent1 is online with the
linux dockerlabel. - To
admingenerate an API token, and use two small scripts to create and run lab pipelines through the REST API, so you don't have to keep clicking through the UI. - Understand the lab safety rules: only create faults in the
lab8folder andlab8-*namespace, and clean up immediately when done.
Prerequisites
- Complete Lesson 1 Module 0:
~/jenkinslab/compose.yamlincludesjenkins(127.0.0.1:8080,127.0.0.1:50000, volumesjenkins_home),agent1(labellinux docker),gitea(127.0.0.1:3000, repositorylab/myapp), and credentialsgitea-myapp. - The Kubernetes lab in Module 3 requires Lesson 5 kind cluster
lab, namespacejenkinsHelm release in thejenkins(with a Kubernetes cloud configured). Without it, the other labs still work. - Tools: Docker (including Compose v2), curl, jq; optional: kubectl, helm, kind.
Step 1: Environment self-check
cd ~/jenkinslab
docker compose ps --format 'table {{.Service}}\t{{.Image}}\t{{.Status}}'
curl -sI http://127.0.0.1:8080/login | grep -i '^x-jenkins:'
SERVICE IMAGE STATUS agent1 jenkinslab/agent1:jdk21 Up 2 hours gitea gitea/gitea:28.4 Up 2 hours jenkins jenkins/jenkins:2.580.2-jdk21 Up 2 hours X-Jenkins: 2.580.2
Consistent with Lesson 1: agent1 is an inbound agent (image jenkinslab/agent1:jdk21, based on jenkins/inbound-agent, mounts docker.sock, label linux docker, 2 executors), built-in node has 0 executors; Gitea user lab, repository lab/myapp, credential gitea-myapp, the Lesson 1 Pipeline job myapp (disabled from Lesson 2 onward), the Lesson 2 Multibranch job myapp-multibranch, credential registry-creds (Gitea token, write:package), the Lesson 7 fault toolkit ~/jenkinslab/faults/ (jobs faultbox,faultbox-hog); on kind, Jenkins is generated by the Lesson 5 seed job platform/seed generated myapp/myapp. In this lesson's labs, work only in the lab8 folder, and do not modify these jobs.
Step 2: API Token & lab8 Folder
In the upper-right corner of the interface, admin → Security → API Token → Add new Token generate a token. When the scripts call the REST API, use API token (not a password) for Basic authentication, which avoids needing a CSRF crumb (Issue #39 explains why).
export JENKINS_URL=http://127.0.0.1:8080 JUSER=admin read -rs JTOKEN; export JTOKEN # paste the token and press Enter; it will not show on screen or in history curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/whoAmI/api/json?tree=name,authorities" ; echo # create folder lab8 (Folders plugin) curl -fsS -u "$JUSER:$JTOKEN" -H 'Content-Type: application/xml' -X POST \ --data-binary '<com.cloudbees.hudson.plugins.folder.Folder/>' "$JENKINS_URL/createItem?name=lab8" && echo "lab8 created"
{"_class":"hudson.security.WhoAmI","authorities":["authenticated"],"name":"admin"}
lab8 created
Step 3: Two Helper Scripts
mkjob.sh Wrap a .groovy file as a Pipeline job config.xml (sandbox enabled) and create/update lab8/<name>; runjob.sh trigger a build, wait for it to finish, and print the last N lines of the console log.
mkdir -p ~/jenkinslab/lab8 && cd ~/jenkinslab/lab8
cat > mkjob.sh <<'EOF'
#!/usr/bin/env bash
# Usage: ./mkjob.sh <job name> <pipeline.groovy>
set -euo pipefail
: "${JENKINS_URL:=http://127.0.0.1:8080}"; : "${JUSER:=admin}"; : "${JTOKEN:?run export JTOKEN first}"
name=$1
body=$(sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g' "$2")
xml="<flow-definition plugin=\"workflow-job\"><definition class=\"org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition\" plugin=\"workflow-cps\"><script>${body}</script><sandbox>true</sandbox></definition></flow-definition>"
api() { curl -fsS -u "$JUSER:$JTOKEN" -H 'Content-Type: application/xml' -X POST --data-binary "$xml" "$1"; }
api "$JENKINS_URL/job/lab8/job/$name/config.xml" 2>/dev/null || api "$JENKINS_URL/job/lab8/createItem?name=$name"
echo "job lab8/$name ready"
EOF
cat > runjob.sh <<'EOF'
#!/usr/bin/env bash
# Usage: ./runjob.sh <job name> [number of log lines to show, default 25]
set -euo pipefail
: "${JENKINS_URL:=http://127.0.0.1:8080}"; : "${JUSER:=admin}"; : "${JTOKEN:?run export JTOKEN first}"
J="$JENKINS_URL/job/lab8/job/$1"; C=(curl -fsS -u "$JUSER:$JTOKEN")
next=$("${C[@]}" "$J/api/json?tree=nextBuildNumber" | jq -r .nextBuildNumber)
"${C[@]}" -X POST "$J/build?delay=0sec" >/dev/null
echo "queued #$next"
until "${C[@]}" "$J/$next/api/json?tree=building" 2>/dev/null | grep -q '"building":false'; do sleep 2; done
"${C[@]}" "$J/$next/consoleText" | tail -n "${2:-25}"
EOF
chmod +x mkjob.sh runjob.sh
printf 'node { echo "hello from ${env.NODE_NAME}" }\n' > hello.groovy
./mkjob.sh hello hello.groovy && ./runjob.sh hello 5
job lab8/hello ready queued #1 [Pipeline] node Running on agent1 in /home/jenkins/agent/workspace/lab8/hello [Pipeline] echo hello from agent1 Finished: SUCCESS
If you see Running on Jenkins in /var/jenkins_home/…, the built-in node's executor count is not 0 — this is itself Issue #42; in production it should be set to 0. runjob.sh If a build stays queued, it will wait indefinitely: press Ctrl+C to exit, then cancel it in the UI (Module 3 deliberately creates this situation).
Step 4 (optional): Jenkins on the lab kind cluster
kubectl config use-context kind-lab helm list -n jenkins kubectl -n jenkins get pod -l app.kubernetes.io/component=jenkins-controller kubectl -n jenkins port-forward svc/jenkins 8081:8080 >/dev/null 2>&1 & # access http://127.0.0.1:8081
NAME NAMESPACE REVISION STATUS CHART APP VERSION jenkins jenkins 3 deployed jenkins-5.13.3 2.580.2 NAME READY STATUS RESTARTS AGE jenkins-0 2/2 Running 0 1d
Connection to the Previous Lesson
- All the Lesson 7 troubleshooting tools are reused here:
docker compose logs jenkins,Manage Jenkins → System Log / System Information / Script Console,$JENKINS_URL/threadDump, the build'sconsoleTextand Pipeline Steps views, and the Kuberneteskubectl describe pod / logs. - All lab tasks in this lesson are placed in the
lab8folder, and the Kubernetes namespace uses the unified prefixlab8-.
Lab safety rules
$JENKINS_URL the Jenkins instance at 127.0.0.1:8080 (or 8081 for kind); in production, any operation that “modifies $JENKINS_HOME files” must be backed up first (Issue #49). Code in the script console is equivalent to arbitrary code execution on the controller.curl -fsS -u "$JUSER:$JTOKEN" -X POST "$JENKINS_URL/job/lab8/doDelete" && echo "lab8 deleted" docker volume rm lab8war 2>/dev/null; sudo rm -rf /tmp/lab8-home /tmp/lab8-plugins kubectl get ns -o name | grep '^namespace/lab8-' | xargs -r kubectl delete --wait=false rm -rf ~/jenkinslab/lab8
Self-check checklist
Module 1 · Part A: Installation, Plugins & Upgrades (Issues 1–12)
- Explain the controller startup order: the startup script (Docker image's
jenkins.sh) → JVM and Java version check → readJENKINS_HOME→ load plugins (topologically sorted by dependencies) → JCasC → load jobs and nodes → ready. Each step has its typical failures. - Make sense of Plugins Failed To Load the four causes: missing dependency, dependency version too low, dependency disabled, core version too low, and use
plugins.txt+jenkins-plugin-clito make the plugin set reproducible. - Design a safe upgrade process: pin image tags, rehearse on a replica first, upgrade core and plugins together, and keep a rollback-capable backup.
Filter by keywords from the error message (such as Java,Failed to load,certification,reverse proxy), then click a row to jump to the corresponding entry under “Issue Details”.
#1 Running with Java 17 from …, which is older than the minimum required version (Java 21).
$ java -jar jenkins.war Running with Java 17 from /usr/lib/jvm/java-17-openjdk-amd64, which is older than the minimum required version (Java 21). Supported Java versions are: [21, 25]
Symptom: After upgrading to 2.555.1 or a later LTS via system packages (apt/yum) or the WAR on a virtual machine, the service fails to start,systemctl status jenkins and keeps restarting. This rarely happens when running in containers, unless you changed the base JDK while building your own image.
Root cause:executable.Main Before loading any plugin, the runtime Java major version is checked: if it is below the minimum of the supported set, it throws UnsupportedClassVersionError; if it is above the maximum (e.g. Java 26), it requires adding --enable-future-java. Jenkins' Java support policy is “2+2+2”: starting with 2.555.1 LTS only Java 21 and 25 are supported; the last LTS for Java 17 is 2.541.3.
Diagnostic command
java -version # note that the java on PATH is not necessarily the one the service uses systemctl cat jenkins | grep -i -E 'JAVA_HOME|JAVA_CMD|ExecStart' journalctl -u jenkins -n 30 --no-pager
openjdk version "17.0.13" 2024-10-15 Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64" jenkins[2211]: Running with Java 17 from /usr/lib/jvm/java-17-openjdk-amd64, which is older than the minimum required version (Java 21).
Fix
sudo apt-get install -y openjdk-21-jre-headless # or Temurin 21 sudo systemctl edit jenkins # [Service] Environment="JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64" sudo systemctl restart jenkins # Also check Java on all agents: agent remoting also requires a supported Java version
Prevention & Best Practices
- Read before upgrading: LTS upgrade guide and Java support policy; Java 21 support runs to 2027-09, Java 25 to 2029-09.
- Prefer the official images (
-jdk21/-jdk25) tags, versioning the JDK together with Jenkins; upgrade agent images at the same time.
See also Lesson 1 Module 2 Installation & Initialization,Lesson 5 Module 6 Backup, Restore & Upgrade Strategy.
#2 Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
Symptom: Changing JENKINS_HOME to a host-directory bind mount or NFS makes the container exit immediately (exit 1).
Root cause: The official image runs as UID/GID 1000 (user jenkins, and the startup script's first step must write logs to JENKINS_HOME and copy /usr/share/jenkins/ref files in it. When the host directory is owned by root or another UID, writes fail. Named volumes (jenkins_home) are initialized by Docker to the image directory's ownership on first mount, so the Lesson 1 approach does not hit this. The same problem on Kubernetes is an unset fsGroup on the PVC.
Diagnostic command
docker compose logs jenkins --tail 5 ls -ldn /srv/jenkins_home # numeric UID/GID of the host directory docker run --rm --entrypoint id jenkins/jenkins:2.580.2-jdk21
drwxr-xr-x 2 0 0 4096 Nov 16 10:02 /srv/jenkins_home uid=1000(jenkins) gid=1000(jenkins) groups=1000(jenkins)
Fix
sudo chown -R 1000:1000 /srv/jenkins_home
# Kubernetes: the official Helm chart defaults to runAsUser/fsGroup 1000; set these for a custom StatefulSet
# securityContext: { runAsUser: 1000, fsGroup: 1000 }
Prevention & Best Practices
- Prefer named volumes or block-storage PVCs;
JENKINS_HOMErunning on NFS causes locking and performance problems (#45). - Don't use
--user rootto bypass it — running the controller as root expands the impact of any plugin vulnerability.
See Lesson 1 Module 2.
#3 Failed to load: Docker Pipeline (docker-workflow …) - Update required: … to be updated to … or higher
SEVERE jenkins.InitReactorRunner$1#onTaskFailed: Failed Loading plugin Docker Pipeline v653.v2f2c08eff0ec (docker-workflow) java.io.IOException: Failed to load: Docker Pipeline (docker-workflow 653.v2f2c08eff0ec) - Update required: Docker Commons Plugin (docker-commons 439.va_3cb_0a_6a_fb_29) to be updated to 445.v6b_646c962a_94 or higher
The same location may also show three other causes: Plugin is missing: {name} ({version}),Required plugin is disabled: … (#5),Jenkins ({version}) or higher required (#4). In the UI this corresponds to Manage Jenkins the “Plugins Failed To Load” administrative monitor at the top.
Symptom: After upgrading or installing a plugin and restarting, some features disappear: for example, in Declarative the agent { docker … } reports Invalid agent type (#17), or the Pipeline reports No such DSL method (#16).
Root cause: Each plugin's MANIFEST.MF declares its dependencies and minimum versions. On startup, PluginManager loads plugins in dependency topological order; if any dependency is unsatisfied, that plugin and all the plugins that depend on it are not loaded (cascading failure). The most common triggers: upgrading only one plugin in the UI, uploading a .hpi, or plugins.txt pinning a dependency to an old version in the
Diagnostic command
docker compose logs jenkins 2>&1 | grep -E 'Failed Loading plugin|Failed to load|Update required|Plugin is missing'
# Script console (Manage Jenkins → Script Console), listing plugins that failed to load:
# Jenkins.instance.pluginManager.failedPlugins.each { println "${it.name}: ${it.cause?.message}" }
Fix
# UI: Manage Jenkins → Plugins → Updates; upgrade the listed dependencies to the required versions → restart # Image-based: upgrade dependencies in plugins.txt and let jenkins-plugin-cli resolve the whole closure jenkins-plugin-cli --plugin-file plugins.txt --jenkins-version 2.580.2 --list --no-download
Prevention & Best Practices
- Upgrade plugins “as a group”: either update everything to the latest versions compatible with the current core, or use a tested
plugins.txtto lock the complete closure. - Rehearse upgrades first on a
JENKINS_HOMEreplica (#9); only perform verified operations in the production window.
See Lesson 1 Module 3 Plugin System,Lesson 7 Module 4 Plugin Dependency Conflicts & Upgrade Failures.
#4 Failed to load: … - Jenkins (2.568.1) or higher required
java.io.IOException: Failed to load: Role-based Authorization Strategy (role-strategy 928.vc60b_edb_fea_e1) - Jenkins (2.568.3) or higher required
Symptom: On an older core (for example, still on 2.541.3), a new plugin was uploaded by hand, or a plugins/ directory was copied from another instance; after restart the plugin fails to load. If the failing plugin is an authorization plugin, login permissions may also go wrong.
Root cause: Each plugin version declares Jenkins-Version (the minimum core version). The update center filters visible versions by the current core, but manual uploads or copied directories bypass this protection. Example from the 2026-11 update center: role-strategy 928.x requires core 2.568.3, and workflow-cps 4403.x requires 2.568.1.
Diagnostic command
curl -sI "$JENKINS_URL/login" | grep -i x-jenkins docker compose exec jenkins sh -c 'unzip -p /var/jenkins_home/plugins/role-strategy.jpi META-INF/MANIFEST.MF | grep -i Jenkins-Version'
X-Jenkins: 2.541.3 Jenkins-Version: 2.568.3
Fix
- Preferred: upgrade the core to the required LTS following the upgrade guide, then upgrade the plugins.
- If the core cannot be upgraded yet: install older plugin versions compatible with the current core (
jenkins-plugin-cli --jenkins-version 2.541.3will help you choose), and watch whether that old version has a security advisory.
Prevention & Best Practices
- Don't copy
plugins/directories between instances; useplugins.txtto rebuild. - If the core falls too far behind, security fixes become harder to obtain — follow each LTS baseline (about 12 weeks) at least once.
See Lesson 1 Module 3.
#5 Required plugin is disabled: … / Plugin is missing: …
java.io.IOException: Failed to load: Docker Pipeline (docker-workflow 653.v2f2c08eff0ec) - Required plugin is disabled: Docker Commons Plugin (docker-commons)
Symptom: To “slim down” plugins, an apparently unused plugin was disabled or uninstalled in the UI; after restart a chain of plugins failed to load. Or a plugin was deleted in the plugins.txt , but other plugins still depend on it (Plugin is missing).
Root cause: Disabling a plugin only places a marker in the plugins/ directory: a <plugin>.jpi.disabled marker file. The disabled plugin still exists, but plugins that depend on it refuse to load. The UI disable action has a dependency check (it warns “has, at least, one dependent plugin”), but direct file edits or batch disable/uninstall through JCasC or scripts do not.
Diagnostic command
docker compose exec jenkins sh -c 'ls /var/jenkins_home/plugins/*.disabled 2>/dev/null'
# Script console: who depends on docker-commons?
# Jenkins.instance.pluginManager.plugins.findAll { p -> p.dependencies.any { it.shortName == 'docker-commons' } }*.shortName
Fix
docker compose exec jenkins rm /var/jenkins_home/plugins/docker-commons.jpi.disabled docker compose restart jenkins # Or re-enable it under Manage Jenkins → Plugins → Installed plugins, then restart
Prevention & Best Practices
- Before slimming down plugins, use the Script Console or
jenkins-plugin-cli --listto map the dependency graph; remove the “top-level” plugins first, so the dependencies become orphans naturally. - Change the plugin set only through code changes (
plugins.txt/ Helm values), and review them.
See Lesson 1 Module 3,Lesson 6 Module 5 Plugin Security & Plugin Governance.
#6 SunCertPathBuilderException: unable to find valid certification path to requested target (update center / plugin download failure)
java.io.IOException: Failed to load https://updates.jenkins.io/update-center.json?id=default&version=2.580.2 to /var/jenkins_home/updates/default.json.tmp Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Symptom: On the corporate network, Plugins → Available is empty, update checks fail, and plugin downloads fail; on the same machine, curl https://updates.jenkins.io works fine.
Root cause: Egress passes through a TLS-intercepting proxy, which re-signs certificates with the company root CA. The OS trusts that root CA, but the Jenkins JVM truststore (inside the container, $JAVA_HOME/lib/security/cacerts) does not have it. It may also be that no HTTP proxy is configured (Manage Jenkins → System → HTTP Proxy Configuration).
Diagnostic command
docker compose exec jenkins curl -sSI https://updates.jenkins.io/update-center.json | head -1 docker compose exec jenkins sh -c 'echo | openssl s_client -connect updates.jenkins.io:443 -servername updates.jenkins.io 2>/dev/null | openssl x509 -noout -issuer'
issuer=CN = Corp TLS Inspection CA, O = Example Corp ← not a public CA, so the traffic is being intercepted
Fix
FROM jenkins/jenkins:2.580.2-jdk21 COPY corp-root-ca.crt /tmp/ USER root RUN keytool -importcert -noprompt -trustcacerts -alias corp-root -file /tmp/corp-root-ca.crt -cacerts -storepass changeit USER jenkins
Prevention & Best Practices
- Build the company CA and proxy configuration into a custom image (for both the controller and agents); do not turn off certificate verification.
- On restricted networks, set up an internal update center mirror, or pre-download the plugins in CI with
jenkins-plugin-cliand bake them into the image.
#7 Manage Old Data / CannotResolveClassException: configuration cannot be read after a plugin is removed
WARNING hudson.util.RobustReflectionConverter#doUnmarshal: Skipping a non-existent field … com.thoughtworks.xstream.mapper.CannotResolveClassException: hudson.plugins.sonar.SonarBuildWrapper
Symptom: After uninstalling a plugin, or after a plugin fails to load and is missing, Manage Jenkins shows an “Old Data / Unreadable Data” notice; the matching build step disappears from the job configuration page; and if the job is saved again, the old configuration is permanently discarded.
Root cause: Job, node and global configurations are JENKINS_HOME XML serialized by XStream under the JENKINS_HOME directory. When the plugin that owns a class is missing, Jenkins skips the elements it cannot parse and records them in OldDataMonitor; as long as they are not saved again, the original XML remains on disk.
Diagnostic command
docker compose logs jenkins 2>&1 | grep -E 'CannotResolveClass|Unreadable|OldData' | sort | uniq -c | head docker compose exec jenkins grep -rl 'SonarBuildWrapper' /var/jenkins_home/jobs --include=config.xml | head
Fix
- If you still need the feature: reinstall the plugin (at a version compatible with the one you had before uninstalling), and the configuration recovers automatically.
- If you confirm it is no longer needed: on the Manage Old Data page, click “Discard Unreadable Data”, or regenerate the configuration with Job DSL/JCasC.
Prevention & Best Practices
- Before uninstalling a plugin, grep for it
jobs/*/config.xmlto see who is using it; manage jobs with Job DSL/pipeline code so that configuration is not saved through the UI. - Enable the Job Configuration History plugin or take backups, so you can review the XML from before it was overwritten.
See Lesson 7 Module 4.
#8 It appears that your reverse proxy set up is broken.
It appears that your reverse proxy set up is broken.
Symptom: After accessing Jenkins through Nginx / Ingress / Application Gateway, saving configuration occasionally returns 403, some links redirect back to http:// or to an internal hostname, and links in build logs are wrong; the warning above appears at the top of the management page.
Root cause: Jenkins generates absolute URLs from request headers (Host,X-Forwarded-Proto,X-Forwarded-Port) and Jenkins URL The monitor has the browser access a test address; if the URL it is redirected back to does not match the configured one, it raises a warning. Common causes: the proxy does not forward X-Forwarded-Proto: https, rewrites the path (context path mismatch), or the Jenkins URL is set to an internal address.
Diagnostic command
curl -sI https://jenkins.example.com/manage/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/test | grep -i location curl -s -u "$JUSER:$JTOKEN" "$JENKINS_URL/scriptText" --data-urlencode 'script=println jenkins.model.JenkinsLocationConfiguration.get().url'
Fix
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1; # needed for WebSocket agents and SSE
proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";
}
Prevention & Best Practices
- Write the proxy configuration following the official reverse proxy documentation ; set the Jenkins URL to the external HTTPS address (#12).
- If you use a context path (
/jenkins), the controller's--prefixand the proxy path must match.
#9 After upgrade: java.lang.NoSuchMethodError / NoClassDefFoundError; some jobs or pages return 500
java.lang.NoSuchMethodError: 'void hudson.model.SomeClass.someMethod(java.lang.String)' at org.jenkinsci.plugins.someplugin.SomeStep$Execution.run(SomeStep.java:88)
Symptom: After upgrading the core LTS, Jenkins starts, but some jobs fail and some pages show “Oops!”; rolling back the core makes everything work again.
Root cause: The core removed or changed an old API, but a plugin still calls it with the old signature. A plugin's Jenkins-Version declares only a “minimum core”, not a “maximum core”; plugins that have not been updated for a long time (especially deprecated or unmaintained ones) are the most prone to this. Another cause is two plugins bundling different versions of the same library.
Diagnostic command
docker compose logs jenkins 2>&1 | grep -B2 -A6 -E 'NoSuchMethodError|NoClassDefFoundError' | head -40
# Which plugin provides the class? In the Script Console:
# println Jenkins.instance.pluginManager.whichPlugin(Class.forName('org.jenkinsci.plugins.someplugin.SomeStep', false, Jenkins.instance.pluginManager.uberClassLoader))?.shortName
Fix
- Upgrade the plugin to the latest version (this fixes it in most cases); for a deprecated plugin with no fixed version, find a replacement and remove the old one.
- Emergency: using the backup from #49, roll the core back to the previous LTS (change the image tag back); keep the plugins in their pre-upgrade state.
Prevention & Best Practices
- Upgrade rehearsal: copy
JENKINS_HOME→ start a replica controller (triggers disabled, outbound connections cut) → upgrade the core and all plugins → run smoke pipelines. - Before each upgrade, review the deprecated-plugin warnings in Manage Jenkins and the security advisories.
#10 docker compose pull causes Jenkins to be “upgraded unexpectedly” (latest / lts tag drift)
$ docker compose pull && docker compose up -d $ curl -sI http://127.0.0.1:8080/login | grep X-Jenkins X-Jenkins: 2.590 ← was 2.580.2 before; latest points to weekly
Symptom: No upgrade was planned, but after a routine pull pull, a node rebuild, or Kubernetes rescheduling, the Jenkins version changed, and then issues like #3 and #9 followed.
Root cause:jenkins/jenkins:latest Following the weekly tag; the lts, and lts-jdk21 tags move to the next LTS. imagePullPolicy: Always A rebuilt node, or a new node without a cache, also pulls the new version. The plugin directory lives in a volume and does not change with the image, so the core and plugins become mismatched.
Diagnostic command
docker compose config | grep 'image:'
docker image inspect jenkins/jenkins:lts-jdk21 --format '{{index .Config.Labels "org.opencontainers.image.version"}}' 2>/dev/null
Fix
# compose.yaml — pin to a specific LTS (for stricter control, also add an @sha256 digest)
services:
jenkins:
image: jenkins/jenkins:2.580.2-jdk21
Prevention & Best Practices
- Pin both the image tags and the Helm chart version (
controller.image.tag) ; upgrades happen as a PR. - Build your own image:
FROM jenkins/jenkins:2.580.2-jdk21+plugins.txt, versioning the core and plugins together.
See Lesson 1 Module 2,Lesson 5 Module 4 Running Jenkins on Kubernetes with Helm.
#11 jenkins-plugin-cli: depends on X:…, but there is an older version defined on the top level - X:…
$ docker build -t my-jenkins . … Plugin kubernetes:4560.vc25b_83890c34 depends on kubernetes-client-api:7.3.1-256.v788a_0b_787114, but there is an older version defined on the top level - kubernetes-client-api:6.10.0-240.v57880ce8b_0b_2
Symptom: Plugin installation fails while building a custom Jenkins image, or in the init container of the Helm chart; in the latter case the controller Pod gets stuck at Init:CrashLoopBackOff.
Root cause:plugins.txt explicitly pins an old version of a dependency, while a newer version of another plugin requires a higher one. The tool does not silently override explicit pins, so it fails. Another common failure: a plugin version requires a newer core (#4), or a pinned version has been removed from the update center.
Diagnostic command
docker run --rm -v "$PWD/plugins.txt:/p.txt:ro" --entrypoint jenkins-plugin-cli \ jenkins/jenkins:2.580.2-jdk21 --plugin-file /p.txt --list --no-download 2>&1 | tail -20 kubectl -n jenkins logs jenkins-0 -c init --tail 20 # plugin-install init container of the Helm chart
Fix
- Remove explicit pins on transitive dependencies, list only the “top-level” plugins, and let the tool resolve the closure; or upgrade the pinned version to the one the error asks for.
- Helm chart:
controller.installPluginslist only the top-level plugins with versions; when strict reproducibility is needed, build an image that bundles the plugins and setcontroller.installPlugins: false.
Prevention & Best Practices
- In CI, run
plugins.txtthe tool on--list --no-downloadas a check; when upgrading, update all versions at once and commit the complete generated manifest. - When building the image, add
--view-security-warningsto check for known vulnerabilities.
#12 Jenkins URL is empty but is required for the proper operation of many Jenkins features …
Jenkins URL is empty but is required for the proper operation of many Jenkins features like email notifications, PR status update, and environment variables such as BUILD_URL.
Symptom: The “Details” link in PR status (Gitea/GitHub checks) points to http://localhost:8080/… or is empty; links in email and Slack notifications do not open; env.BUILD_URL is null; inbound agents connect to the wrong address.
Root cause: Jenkins cannot reliably infer the external address from the request, so the administrator has to set it explicitly Manage Jenkins → System → Jenkins URL (the last step of the setup wizard). If you forget unclassified.location.url when initializing with JCasC or scripts, it will be empty or keep localhost.
Diagnostic command
curl -s -u "$JUSER:$JTOKEN" "$JENKINS_URL/scriptText" --data-urlencode 'script=println jenkins.model.JenkinsLocationConfiguration.get().url'
null
Fix
# JCasC
unclassified:
location:
url: "https://jenkins.example.com/"
adminAddress: "jenkins-admin@example.com"
Prevention & Best Practices
- The JCasC baseline must always include
location.url; for the matching reverse-proxy headers, see #8. - For the local lab environment, use
http://127.0.0.1:8080/; Gitea webhook callbacks, however, need an address reachable inside the container network (#24).
Controller startup sequence fault simulator
Select a fault, click “Run”, and see at which startup step the controller fails, what appears in the logs, and what state is left in the cluster or container. The stage order matches the initialization milestones of Jenkins core (plugin loading → extensions → job loading → completion), simplified.
~/jenkinslab. Labs 1-A, 1-B and 1-D use separate temporary containers and do not affect the lab Jenkins; Lab 1-C restarts the lab Jenkins.Lab 1-A: start 2.580.2 with Java 17 (#1)
docker volume create lab8war docker run --rm -u 0 -v lab8war:/w --entrypoint cp jenkins/jenkins:2.580.2-jdk21 /usr/share/jenkins/jenkins.war /w/ docker run --rm -v lab8war:/w eclipse-temurin:17-jre java -jar /w/jenkins.war --httpPort=8099
Running with Java 17 from /opt/java/openjdk, which is older than the minimum required version (Java 21). Supported Java versions are: [21, 25]
Jenkins is fully up and running and then press Ctrl+C):docker run --rm -v lab8war:/w eclipse-temurin:21-jre java -jar /w/jenkins.war --httpPort=8099 2>&1 | grep -m1 -E 'fully up|Running from'
docker volume rm lab8warLab 1-B: permissions on a bind mount (#2)
sudo mkdir -p /tmp/lab8-home && sudo chown root:root /tmp/lab8-home && sudo chmod 755 /tmp/lab8-home docker run --rm -v /tmp/lab8-home:/var/jenkins_home jenkins/jenkins:2.580.2-jdk21; echo "exit=$?"
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions? exit=1
Jenkins initial setup is required is enough; press Ctrl+C):sudo chown -R 1000:1000 /tmp/lab8-home docker run --rm -v /tmp/lab8-home:/var/jenkins_home jenkins/jenkins:2.580.2-jdk21 2>&1 | grep -m1 'initial setup'
sudo rm -rf /tmp/lab8-homeLab 1-C: disable a plugin that others depend on (#3, #5, #17)
cd ~/jenkinslab docker compose exec jenkins sh -c 'unzip -p /var/jenkins_home/plugins/docker-workflow.jpi META-INF/MANIFEST.MF | tr -d "\r" | grep -A2 Plugin-Dependencies' docker compose exec jenkins touch /var/jenkins_home/plugins/docker-commons.jpi.disabled docker compose restart jenkins && sleep 40 docker compose logs jenkins --since 2m 2>&1 | grep -E 'Failed Loading plugin|Required plugin is disabled'
Plugin-Dependencies: docker-commons:445.v6b_646c962a_94,… SEVERE jenkins.InitReactorRunner$1#onTaskFailed: Failed Loading plugin Docker Pipeline v653.v2f2c08eff0ec (docker-workflow) - Required plugin is disabled: Docker Commons Plugin (docker-commons)
If Docker Pipeline was not installed in Lesson 1, substitute any pair of plugins with a dependency relationship (for example, disable pipeline-model-api and observe pipeline-model-definition).
cd ~/jenkinslab/lab8
cat > m1c.groovy <<'EOF'
pipeline {
agent { docker { image 'python:3.12-slim' } }
stages { stage('t') { steps { sh 'python --version' } } }
}
EOF
./mkjob.sh m1c m1c.groovy && ./runjob.sh m1c 6WorkflowScript: 2: Invalid agent type "docker" specified. Must be one of [any, label, none] @ line 2, column 11. … Finished: FAILURE
cd ~/jenkinslab && docker compose exec jenkins rm /var/jenkins_home/plugins/docker-commons.jpi.disabled && docker compose restart jenkins
Lab 1-D: an outdated dependency pinned in plugins.txt (#11)
mkdir -p /tmp/lab8-plugins && cd /tmp/lab8-plugins printf 'kubernetes:latest\nkubernetes-client-api:6.10.0-240.v57880ce8b_0b_2\n' > plugins.txt docker run --rm -v "$PWD/plugins.txt:/p.txt:ro" --entrypoint jenkins-plugin-cli \ jenkins/jenkins:2.580.2-jdk21 --plugin-file /p.txt --list --no-download 2>&1 | grep -i 'older version' | head -3
… depends on kubernetes-client-api:7.x…, but there is an older version defined on the top level - kubernetes-client-api:6.10.0-240.v57880ce8b_0b_2
If the version you use does not resolve dependencies in --no-download mode, remove that parameter and add -d /tmp/x to actually download them.
printf 'kubernetes:latest\n' > plugins.txt docker run --rm -v "$PWD/plugins.txt:/p.txt:ro" --entrypoint jenkins-plugin-cli jenkins/jenkins:2.580.2-jdk21 --plugin-file /p.txt --list --no-download 2>&1 | tail -5
rm -rf /tmp/lab8-pluginsInstructional video (title and channel verified via YouTube oEmbed)
No verified video dedicated to troubleshooting Jenkins startup failures was found. Below is a 3-minute storyboard you can record yourself:
ls -ldn and id compare with UID 1000,chown then start.docker-commons.jpi.disabled, after restart the “Plugins Failed To Load” page lists two plugins; draw the dependency arrows and explain that you only fix the bottom-most one.plugins.txt Pin an old dependency,jenkins-plugin-cli --list reports an older version; it passes after removing the pin. Summary: four things — Java, permissions, the plugin closure, and label pinning.Official documentation
Module 2 · Part A: Pipeline & Builds (Issues 13–25)
- Distinguish at which layer a Pipeline failure occurs: compilation/validation (Groovy syntax, Declarative model validation, Method too large) → CPS execution on the controller (serialization, sandbox, CPS mismatch) → steps on the agent (exit code, durable task heartbeat) → SCM/triggers.
- Explain why local variables in Groovy code must be serializable, and
@NonCPSthe correct usage and cost of - Handle secrets correctly: single quotes + environment variables, rather than Groovy string interpolation.
Filter by keywords from the error message (such as NotSerializable,not permitted,DSL method,exit code) ; click a row to jump to “Issue Details”.
#13 java.io.NotSerializableException: java.util.regex.Matcher
an exception which occurred: in field org.jenkinsci.plugins.workflow.cps.CpsThread.program … Caused: java.io.NotSerializableException: java.util.regex.Matcher at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:…)
Symptom: The Pipeline fails at a seemingly unrelated step (sh,sleep,input); the same Groovy code runs fine locally in groovy Other common class names: groovy.json.internal.LazyMap (JsonSlurper result),java.net.URL connection,hudson.model.Run (old syntax).
Root cause: The Pipeline's Groovy is transformed by CPS (Continuation Passing Style) and executed on the controller. Whenever execution reaches a step that may run for a long time,the entire program state (including all local variables) is serialized to the build directory's program.dat, so the controller can resume after a restart. If a non-serializable object is on the stack at that point (such as Matcher), persistence fails and the build reports an error.
Diagnostic command
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/job/lab8/job/m2a/lastBuild/consoleText" | grep -n -B3 'NotSerializableException' # Find the last [Pipeline] step before the exception; that is where persistence was triggered. Then check which earlier variable holds that type.
Fix
// Encapsulate non-serializable processing in a @NonCPS method, returning only serializable results such as String/Map
@NonCPS
String parseVersion(String s) {
def m = (s =~ /myapp-(\d+\.\d+)/)
return m.find() ? m.group(1) : null
}
node {
def v = parseVersion('myapp-1.1')
sleep 1
echo "version ${v}"
}
// JSON: use readJSON (Pipeline Utility Steps) or JsonSlurperClassic, not JsonSlurper
Prevention & Best Practices
- A Pipeline is for orchestration, not for programming: put complex logic in a script invoked by
shor in a shared library's@NonCPSmethods. @NonCPSInside a must not call steps (sh,echoetc.), otherwise you will hit #19.
See Lesson 2 Module 1 Pipeline Architecture: CPS, Groovy & Persistence,Lesson 7 Module 3.
#14 org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod jenkins.model.Jenkins getInstance
Scripts not permitted to use staticMethod jenkins.model.Jenkins getInstance. Administrators can decide whether to approve or reject this signature. [Pipeline] End of Pipeline org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod jenkins.model.Jenkins getInstance
Symptom: The Jenkinsfile or a shared library calls internal Jenkins APIs (Jenkins.instance,currentBuild.rawBuild),new File(...) reflection, and so on; the build fails immediately.
Root cause: Jenkinsfiles from SCM and “untrusted” shared libraries always run inside the Groovy sandbox: every method call and property access is checked against a whitelist (built-in script-security plus administrator approvals). Signatures not on the whitelist are rejected and wait in Manage Jenkins → In-process Script Approval for an administrator's decision.
Diagnostic command
# Pending signatures (administrator):
curl -s -u "$JUSER:$JTOKEN" "$JENKINS_URL/scriptText" --data-urlencode \
'script=org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.get().pendingSignatures.each{ println it.signature }'
staticMethod jenkins.model.Jenkins getInstance
Fix
- Preferred: do not approve dangerous signatures (
Jenkins getInstance,rawBuild,File,Runtime execetc. — approving them effectively hands the controller to anyone who can edit the Jenkinsfile). Use steps instead:currentBuild.resultfor exampleenv.*,readFile/writeFile, orsh. - If you really need the internal API: place it in a trusted global shared library controlled by administrators (which does not run in the sandbox), expose controlled steps, and review changes to the library repository strictly.
Prevention & Best Practices
- Manage approval records with JCasC and review them regularly; an approved signature applies to all sandboxed scripts.
- Script Security vulnerabilities are frequent guests in Jenkins advisories — upgrade script-security and workflow-cps promptly.
See Lesson 6 Module 4 Script Security, Sandbox & Groovy Approval.
#15 General error during class generation: Method too large: WorkflowScript.___cps___…
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during class generation: Method too large: WorkflowScript.___cps___1 ()Lcom/cloudbees/groovy/cps/impl/CpsFunction; groovyjarjarasm.asm.MethodTooLargeException: Method too large: WorkflowScript.___cps___1 ()Lcom/cloudbees/groovy/cps/impl/CpsFunction;
Symptom: The Jenkinsfile keeps growing (dozens of stages, lots of when/parallel/script blocks), and after adding one more stage the Pipeline fails on the first line without executing anything.
Root cause: The JVM limits the bytecode of a single method to 64 KB. The whole Declarative pipeline {} block is compiled into one method, and the CPS transformation inflates the bytecode several times over.
Diagnostic command
wc -l Jenkinsfile; grep -c "stage(" Jenkinsfile; grep -c "script {" Jenkinsfile
Fix
- Move the logic in
script {}into methods at the bottom of the Jenkinsfile or into a shared libraryvars/*.groovy(methods are compiled separately from thepipelineblock). - For repeated stages, generate them with
matrixor a shared library; move variables out ofenvironmentinto the method's return value. - Some workflow-cps versions provide a “script splitting” system property to mitigate this (see the official documentationand the plugin release notes).
Prevention & Best Practices
- Keep the Jenkinsfile short: one declaration that calls a shared library; put the complexity in the library, with unit tests (JenkinsPipelineUnit).
#16 java.lang.NoSuchMethodError: No such DSL method 'xxx' found among steps [...]
java.lang.NoSuchMethodError: No such DSL method 'readJSON' found among steps [archiveArtifacts, bat, build, catchError, checkout, deleteDir, dir, echo, error, …]
Symptom: The Pipeline fails when calling a certain step; the same Jenkinsfile works on another Jenkins instance.
Root cause: The step is provided by a plugin (readJSON comes from Pipeline Utility Steps,sshagent comes from SSH Agent,withAWS comes from Pipeline: AWS Steps); the plugin is not installed, failed to load (#3), or the step name is misspelled. It may also be that the shared library was not loaded (a “custom step” defined in vars/xxx.groovy ).
Diagnostic command
# The list in the error message is the full set of steps currently available — search it # Pipeline Syntax generator: $JENKINS_URL/job/lab8/job/m2a/pipeline-syntax/ ; full step reference: /pipeline-syntax/html curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/pluginManager/api/json?depth=1&tree=plugins[shortName,active]" | jq -r '.plugins[]|select(.shortName=="pipeline-utility-steps")'
Fix
- Install or fix the plugin that provides the step; or use
sh 'jq …'and similar approaches that do not depend on a plugin. - Shared library steps: confirm that
@Library('mylib@v1.4') _is declared (or the library is set to implicit loading), and that the file name matches the call name (vars/deployApp.groovy→deployApp()).
Prevention & Best Practices
- Maintain a “list of plugins the Pipeline depends on” together with
plugins.txt; rebuild new instances from the same list.
#17 Invalid agent type "docker" specified. Must be one of [any, label, none]
WorkflowScript: 2: Invalid agent type "docker" specified. Must be one of [any, label, none] @ line 2, column 11.
agent { docker { image 'python:3.12-slim' } }
^
1 error
Other Declarative validation errors of the same kind include: Missing required section "stages",Unknown stage section "xxx". Starting with version 0.5, steps in a stage must be in a ‘steps’ block.,Invalid parameter "xxx", did you mean "yyy"?,Expected a stage (all checked against source).
Symptom: The Pipeline fails before executing any step; the start of the log shows WorkflowScript: line number: ….
Root cause: Before running, Declarative parses pipeline {} into a model and validates it. agent The types of docker/dockerfile are registered by plugins; ones such as docker come from Docker Pipeline,kubernetes come from the Kubernetes plugin. If the plugin is not installed or failed to load (#3, #5), the type list will not contain it.
Diagnostic command
# Validate the Jenkinsfile without running it (Declarative linter, HTTP endpoint) curl -s -u "$JUSER:$JTOKEN" -X POST -F "jenkinsfile=<Jenkinsfile" "$JENKINS_URL/pipeline-model-converter/validate"
Errors encountered validating Jenkinsfile: WorkflowScript: 2: Invalid agent type "docker" specified. Must be one of [any, label, none] @ line 2, column 11.
Fix
- Install or fix the Docker Pipeline plugin, and confirm that the agent has the Docker CLI and daemon access (#34).
- On Kubernetes, prefer
agent { kubernetes { yaml … } }, which does not depend on the Docker daemon.
Prevention & Best Practices
- Run the linter above (or
jenkins-cli declarative-linter) in PR checks or a pre-commit hook, so syntax errors never reach the main branch.
See Lesson 2 Module 3 agent, environment, parameters & when,Module 6 Docker Builds & Containerized Agents.
#18 Warning: A secret was passed to "sh" using Groovy String interpolation, which is insecure.
Warning: A secret was passed to "sh" using Groovy String interpolation, which is insecure. Affected argument(s) used the following variable(s): [GITEA_TOKEN] See https://jenkins.io/redirect/groovy-string-interpolation for details.
Symptom: The build succeeds, but the log shows the warning above; the build page also shows a “may have insecure interpolation of sensitive variables” notice.
Root cause:sh "curl -H 'Authorization: token ${GITEA_TOKEN}' …" In the command text, the variable ${} is replaced by Groovy on the controller first, so the plaintext secret becomes part of the command line: it appears in the agent's process list (ps), may be set -x printed, and log masking only matches complete strings (it cannot mask the value once it is URL-encoded or base64-encoded). With single quotes,$GITEA_TOKEN it is expanded by the shell on the agent from environment variables, so the secret never enters the command text.
Diagnostic command
grep -nE "sh[ (]+\"[^\"]*\\$\\{[A-Z_]*(TOKEN|PASS|SECRET|KEY)" Jenkinsfile vars/*.groovy
Fix
withCredentials([usernamePassword(credentialsId: 'gitea-myapp', usernameVariable: 'GITEA_USER', passwordVariable: 'GITEA_TOKEN')]) {
sh 'curl -fsS -H "Authorization: token $GITEA_TOKEN" http://gitea:3000/api/v1/user' // single quotes: expanded by the shell
}
Prevention & Best Practices
- Code review rule:
withCredentialsinside ashblock, always use single quotes; when concatenating non-secret variables is needed, usewithEnvorenvironment. - Log masking is a “last line of defense”, not a boundary: anyone who can modify the Jenkinsfile can always exfiltrate the secret (Lesson 6).
See Lesson 1 Module 6 Credentials & Security Basics,Lesson 6 Module 3 Credential Management.
#19 expected to call … but wound up catching … (CPS method mismatch)
expected to call WorkflowScript.buildAll but wound up catching sh; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/
Symptom: The warning above appears in the log, followed by odd behavior: a step runs only once, a loop ends early,sort/each the sh in the closure is skipped or errors out.
Root cause: CPS-transformed code can only be called by CPS code, in a “continuation” manner. If a CPS method or step is called from a non-CPS context (@NonCPS methods, constructors, Java library callbacks such as list.sort { }/toSorted comparators,toString()), the execution model gets out of step.
Diagnostic command
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/job/lab8/job/m2a/lastBuild/consoleText" | grep -n 'wound up catching'
Fix
// Wrong: calling a step inside a @NonCPS method
@NonCPS def buildAll(list) { list.each { sh "make ${it}" } }
// Right: keep the step in CPS code and use a plain for loop
def buildAll(list) { for (def m in list) { sh "make ${m}" } }
Prevention & Best Practices
- Rule:
@NonCPSdo only pure computation; in CPS code, preferforloops over Groovy collection closures for steps; do not call steps in class constructors.
#20 ERROR: script returned exit code 127 (or 1, 137, 143)
+ docker build -t myapp:1.1 . /home/jenkins/agent/workspace/lab8/m2e@tmp/durable-1a2b3c4d/script.sh.copy: 1: docker: not found [Pipeline] } ERROR: script returned exit code 127 Finished: FAILURE
Symptom:sh The step fails, and Jenkins only gives the exit code; the real cause is in the shell output above it.
Root cause:sh On the agent, the script is run with sh -xe (stops at the first error and echoes commands); any non-zero return fails the step. Quick reference for exit codes: 1 general error (test failure,grep no match); 127 command not found (the agent image lacks the tool, or PATH differs); 126 no execute permission; 137 killed by SIGKILL (commonly OOM, #36); 143 killed by SIGTERM (build aborted or timed out).
Diagnostic command
sh 'echo "node=$NODE_NAME"; id; echo "$PATH"; command -v docker python3 || true'
Fix
- 127: run on the correct agent (
agent { label 'linux && docker' }, #26), or install the tool into the agent image / use a container agent. - When you need to “allow failure”, handle it explicitly:
def rc = sh(script: 'pytest', returnStatus: true); when you need the output:returnStdout: trueand.trim(). - When the script contains a pipe, add
set -o pipefail(requires bash:sh '#!/bin/bash -e …'), otherwise a failure inpytest | teewill be swallowed.
Prevention & Best Practices
- Version the agent images and select them explicitly in the Jenkinsfile via labels or containers; do not rely on “some machine happens to have it installed”.
See Lesson 1 Module 7 Building myapp,Lesson 2 Module 8 Common Failures.
#21 wrapper script does not seem to be touching the log file in …@tmp/durable-…
wrapper script does not seem to be touching the log file in /home/jenkins/agent/workspace/lab8/m2f@tmp/durable-5f3e9a21 (JENKINS-48300: if on an extremely laggy filesystem, consider -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.HEARTBEAT_CHECK_INTERVAL=86400) ERROR: script returned exit code -1
Another similar message is process apparently never started in …@tmp/durable-… (also checked against source).
Symptom: A long-running sh suddenly fails with exit code -1; this mostly happens when the agent container is restarted, the disk is full, or the workspace is on a slow network filesystem.
Root cause:sh is a “durable task”: on the agent, a wrapper script runs your script in the background and periodically updates @tmp/durable-* directory's log file timestamp as a heartbeat; if the controller sees the heartbeat stop for a long time, it assumes the process is dead. Common causes: the wrapper process gets killed (container OOM, agent restart,ps is missing and causes problems), a full disk (#31), or an extremely slow filesystem.
Diagnostic command
docker compose exec agent1 df -h /home/jenkins/agent
docker compose exec agent1 sh -c 'command -v ps nohup || echo "missing ps/nohup"'
docker inspect --format '{{.State.OOMKilled}} {{.RestartCount}}' $(docker compose ps -q agent1)
Fix
- Clean up the disk, increase agent memory; the agent image must include
ps(procps) andnohup. - Keep the workspace on local disk rather than NFS; if slow storage must be used, increase the heartbeat check interval as the prompt suggests.
Prevention & Best Practices
- Include agent disk and memory in monitoring (Lesson 5 Module 7); set a reasonable memory limit on container agents.
#22 Couldn't find any revision to build. Verify the repository and branch configuration for this job.
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse master^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE
Symptom: A “Pipeline script from SCM” job or git/checkout step fails; the repository is reachable and the credentials are correct.
Root cause: The branch specifier does not match the repository's actual branch; the most common case is a job configuration */master while the default branch of a new Gitea/GitHub repository is main; it may also be that a refspec restricts fetching to certain branches, or that a shallow clone lacks the commit.
Diagnostic command
git ls-remote --heads http://127.0.0.1:3000/lab/myapp.git
9c1e… refs/heads/main
Fix
checkout scmGit(branches: [[name: '*/main']], userRemoteConfigs: [[url: 'http://gitea:3000/lab/myapp.git', credentialsId: 'gitea-myapp']]) // Better: switch to Multibranch, with automatic branch discovery, and call checkout scm directly in the Jenkinsfile
Prevention & Best Practices
- Use Multibranch / Organization Folder instead of jobs with manually configured branch names.
#23 Multibranch: ‘Jenkinsfile’ not found / Does not meet criteria —— no job is generated for the branch or PR
Checking branch feature/login
‘Jenkinsfile’ not found
Does not meet criteria
Checking pull request #12
Does not meet criteria
Processed 3 branches, 1 pull requests
Symptom: A new branch was pushed or a PR was opened, but no corresponding job appears in the Multibranch project; or the PR build runs the Jenkinsfile from the target branch.
Root cause: During a Multibranch scan, each head is checked against Project Recognizer (default: a file named Jenkinsfile exists at the root, case-sensitive; the path can be changed in Build Configuration) and Behaviors (which branches and PRs to discover, and the trust policy for PRs from forks). If the conditions are not met, the head is skipped. An untrusted fork PR uses the Jenkinsfile of the target branch, to prevent external contributors from changing the pipeline to steal secrets.
Diagnostic command
# For the Lesson 2 Multibranch job myapp-multibranch (on kind, Lesson 5 uses myapp/myapp) → Scan Repository Log; or curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/job/myapp-multibranch/indexing/consoleText" | tail -30 git ls-tree --name-only origin/feature/login | grep -i jenkinsfile
Fix
- Rename the file to
Jenkinsfile(or set Script Path to the actual path); check the “Discover branches / pull requests” strategy under Behaviors. - Fork PRs: keep the default “trust only contributors with write access”; when you need builds for external PRs, use a separate pipeline without secrets.
Prevention & Best Practices
- Use an Organization Folder to unify scan rules; trigger scans with Webhooks (#24), and keep periodic scans only as a fallback.
#24 Webhook not triggering: Gitea “webhook can only call allowed HTTP servers (check your webhook.ALLOWED_HOST_LIST setting)”
Delivery: Post "http://jenkins:8080/gitea-webhook/post": dial tcp 172.18.0.3:8080: webhook can only call allowed HTTP servers (check your webhook.ALLOWED_HOST_LIST setting), deny 'jenkins(172.18.0.3:8080)'
Symptom: After pushing code, Jenkins does nothing; a manual “Scan Repository Now” does discover the new commit.
Root cause: The Webhook chain has three links, any of which can break: ① whether the Git server can reach the Jenkins address (inside a container, localhost points to itself; by default Gitea forbids access to private addresses, so it needs [webhook] ALLOWED_HOST_LIST); ② whether the URL path matches the plugin endpoint (the Gitea plugin uses /gitea-webhook/post, the GitHub plugin uses /github-webhook/); ③ whether Jenkins matches the event to the project (repository URL matches the Multibranch configuration, secret matches).
Diagnostic command
docker compose exec gitea wget -qO- --post-data='{}' http://jenkins:8080/gitea-webhook/post ; echo " rc=$?"
docker compose logs jenkins --since 10m 2>&1 | grep -i webhook | tail
# Gitea UI: repository → Settings → Webhooks → Recent Deliveries
Fix
# Allow Gitea to call jenkins in the Compose network (app.ini or environment variable) # [webhook] # ALLOWED_HOST_LIST = private (already set in Lesson 1's compose.yaml; the hostname jenkins also works) # In the gitea service of compose.yaml: GITEA__webhook__ALLOWED_HOST_LIST: "private" docker compose up -d gitea # Webhook URL uses the container network address: http://jenkins:8080/gitea-webhook/post
Prevention & Best Practices
- In production, Webhooks to Jenkins go over an external HTTPS address with a shared secret; when Jenkins is on an internal network, use a relay or an entry point reachable from the network where the Git server is located.
- Keep low-frequency periodic scans as a fallback, but do not replace Webhooks with high-frequency SCM polling (#45).
See Lesson 2 Module 7.
#25 Library mylib expected to contain at least one of src or vars directories
Loading library mylib@main Attempting to resolve main from remote references... … ERROR: Library mylib expected to contain at least one of src or vars directories
Symptom: All Pipelines that use @Library('mylib') fail together; or a “custom step” used by certain projects suddenly no longer exists (#16).
Root cause: The root directory of a shared library repository must contain vars/ (global variables / custom steps) or src/ (Groovy classes), and optionally resources/. Common causes: the library sits in a subdirectory of the repository but no “Library Path” is configured; the default version (branch or tag) does not exist; or the library was refactored and its directories were moved.
Diagnostic command
git ls-tree --name-only -d origin/main # in the library repository: you should see vars and/or src # Manage Jenkins → System → Global Trusted Pipeline Libraries: check Default version, Library Path, and whether overriding the version is allowed
Fix
- Restore the directory structure or configure Library Path; point the default version at an existing branch or tag.
- Pin the library version in the Pipeline:
@Library('mylib@v1.4.0') _, and publish library releases with semantic version tags so that changes can be rolled back.
Prevention & Best Practices
- The shared library itself should have CI (JenkinsPipelineUnit unit tests + integration tests on a test Jenkins); changes to the main branch should not directly affect all projects.
“Pipeline failed” troubleshooting decision tree
Start from the first line of the error; the end gives the conclusion and the corresponding issue number.
~/jenkinslab/lab8,mkjob.sh,runjob.sh and the exported JTOKEN. All tasks are in the lab8 folder.Lab 2-A: Matcher spanning steps (#13)
cd ~/jenkinslab/lab8
cat > m2a.groovy <<'EOF'
node {
def m = ('myapp-1.1' =~ /myapp-(\d+\.\d+)/)
if (m.find()) {
sleep 1 // step boundary: program state is persisted here, and m is still in scope
echo "version ${m.group(1)}"
}
}
EOF
./mkjob.sh m2a m2a.groovy && ./runjob.sh m2a 8Caused: java.io.NotSerializableException: java.util.regex.Matcher … Finished: FAILURE
If your environment asks for approval of the java.util.regex.Matcher method, it means that signature is not on the whitelist — this is also the symptom of #14, which we will understand after Lab 2-B.
@NonCPS method returning a string:cat > m2a.groovy <<'EOF'
@NonCPS
String parseVersion(String s) { def m = (s =~ /myapp-(\d+\.\d+)/); return m.find() ? m.group(1) : null }
node { def v = parseVersion('myapp-1.1'); sleep 1; echo "version ${v}" }
EOF
./mkjob.sh m2a m2a.groovy && ./runjob.sh m2a 4version 1.1 [Pipeline] End of Pipeline Finished: SUCCESS
Lab 2-B: sandbox rejection and the approval queue (#14)
printf 'node { echo "executors: ${Jenkins.instance.numExecutors}" }\n' > m2b.groovy
./mkjob.sh m2b m2b.groovy && ./runjob.sh m2b 4Scripts not permitted to use staticMethod jenkins.model.Jenkins getInstance. Administrators can decide whether to approve or reject this signature. org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod jenkins.model.Jenkins getInstance Finished: FAILURE
curl -s -u "$JUSER:$JTOKEN" "$JENKINS_URL/scriptText" --data-urlencode 'script=org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.get().pendingSignatures.each{ println it.signature }'
printf 'node { echo "running on ${env.NODE_NAME}, build ${currentBuild.number}" }\n' > m2b.groovy
./mkjob.sh m2b m2b.groovy && ./runjob.sh m2b 3Lab 2-C: Declarative validation errors and the linter (#17)
cat > m2c.groovy <<'EOF'
pipeline {
agent { dockr { image 'python:3.12-slim' } }
stages { stage('test') { steps { sh 'python --version' } } }
}
EOF
curl -s -u "$JUSER:$JTOKEN" -X POST -F "jenkinsfile=<m2c.groovy" "$JENKINS_URL/pipeline-model-converter/validate"Errors encountered validating Jenkinsfile: WorkflowScript: 2: Invalid agent type "dockr" specified. Must be one of [any, docker, dockerfile, label, none] @ line 2, column 11.
dockr to label 'linux' and validate again, obtaining Jenkinsfile successfully validated.; then delete the stages block and observe Missing required section "stages".Lab 2-D: Groovy interpolation of secrets (#18)
cat > m2d.groovy <<'EOF'
node('linux') {
withCredentials([usernamePassword(credentialsId: 'gitea-myapp', usernameVariable: 'GITEA_USER', passwordVariable: 'GITEA_TOKEN')]) {
sh "curl -s -o /dev/null -w '%{http_code}\\n' -H 'Authorization: token ${GITEA_TOKEN}' http://gitea:3000/api/v1/user"
}
}
EOF
./mkjob.sh m2d m2d.groovy && ./runjob.sh m2d 10 | grep -A2 -E 'Warning|^\+ curl'Warning: A secret was passed to "sh" using Groovy String interpolation, which is insecure.
Affected argument(s) used the following variable(s): [GITEA_TOKEN]
+ curl -s -o /dev/null -w %{http_code}\n -H Authorization: token **** http://gitea:3000/api/v1/user$GITEA_TOKEN), and the warning disappears:cat > m2d.groovy <<'EOF'
node('linux') {
withCredentials([usernamePassword(credentialsId: 'gitea-myapp', usernameVariable: 'GITEA_USER', passwordVariable: 'GITEA_TOKEN')]) {
sh 'curl -s -o /dev/null -w "%{http_code}\n" -H "Authorization: token $GITEA_TOKEN" http://gitea:3000/api/v1/user'
}
}
EOF
./mkjob.sh m2d m2d.groovy && ./runjob.sh m2d 6+ curl -s -o /dev/null -w %{http_code}\n -H Authorization: token **** http://gitea:3000/api/v1/user
200
Finished: SUCCESSfor j in m2a m2b m2d; do curl -fsS -u "$JUSER:$JTOKEN" -X POST "$JENKINS_URL/job/lab8/job/$j/doDelete"; done
Instructional video (title and channel verified via YouTube oEmbed)
No verified video specifically covering CPS serialization and sandbox rejections was found. Storyboard:
sleep; open the build directory program.dat and explain that “every step boundary serializes”.@NonCPS, then demonstrate calling @NonCPS inside sh and get “wound up catching”.Jenkins.instance Rejected by the sandbox; open In-process Script Approval, explain the consequences of approving, then use env.NODE_NAME instead.sh in ps -ef (observe from a separate terminal on the agent).Official documentation
Module 3 · Part A: Agents, Credentials & Cloud Deployment (Issues 26–38)
- Understand why a queue item is still waiting (
CauseOfBlockage): labels with no nodes, nodes offline, executors fully occupied, throttling/locks, and know the fix for each. - Understand the remoting channel between agent and controller: inbound (TCP 50000 or WebSocket) and SSH connection methods, and what happens to a build when the channel drops.
- Troubleshoot credential errors in three steps: “ID → scope (System/Global/folder) → type”; and understand the cloud authentication chain: Jenkins credentials or managed identity → cloud CLI login → push/deploy.
Filter by keywords from the error message (such as label,executor,50000,credentials,OOMKilled,AADSTS) ; click a row to jump to “Issue Details”.
#26 Still waiting to schedule task / There are no nodes with the label ‘dockr’
[Pipeline] node Still waiting to schedule task There are no nodes with the label ‘dockr’
Other causes at the same location (all checked against source): All nodes of label ‘linux’ are offline,‘agent1’ is offline,‘agent1’ doesn’t have label ‘docker’,Waiting for next available executor on ‘agent1’ (#27),Jenkins is about to shut down,In the quiet period. Expires in …,Blocked by ‘…’.
Symptom: The build keeps showing “Queued”, and the log stops at [Pipeline] node; the tooltip for the item in the build queue in the UI gives the reason.
Root cause: The queue maintainer looks for “a node that can accept” each pending item: the label expression must match (case-sensitive,&&,||,!), the node must be online and have a free executor; matching clouds (Kubernetes, EC2 Fleet) can also create nodes on demand. If none of this holds, the queue item waits and does not fail automatically.
Diagnostic command
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/queue/api/json?tree=items[id,why,task[name]]" | jq '.items[]|{id,why,task:.task.name}'
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/computer/api/json?tree=computer[displayName,offline,assignedLabels[name]]" | jq -c '.computer[]|{n:.displayName,off:.offline,l:[.assignedLabels[].name]}'
# Test a label expression: the /label/linux%26%26docker/ page lists the matching nodes and clouds
{"id":17,"why":"There are no nodes with the label ‘dockr’","task":"part of lab8 » m3a #1"}
{"n":"Built-In Node","off":false,"l":["built-in"]}
{"n":"agent1","off":false,"l":["agent1","docker","linux"]}
Fix
- Correct the label in the Jenkinsfile (
agent { label 'linux && docker' }); or add that label to the node or Pod template. - Add a timeout to the Pipeline to avoid waiting “forever”:
options { timeout(time: 30, unit: 'MINUTES') }(note: a timeout at thepipelinelevel also counts queue time).
Prevention & Best Practices
- Name labels by “capability” (
linux,docker,jdk21), not by machine name; keep the label list in JCasC. - Monitor queue length and wait times (queue metrics from the Prometheus plugin, Lesson 5 Module 7).
See Lesson 1 Module 1 controller, agent, executor & queue,Lesson 7 Module 2 Stuck Builds.
#27 Waiting for next available executor on ‘agent1’ —— builds wait forever, even waiting on each other (deadlock)
Still waiting to schedule task Waiting for next available executor on ‘agent1’
Symptom: During peak hours many builds queue up; a more hidden case is a Pipeline that, inside node block, uses parallel to request several node, or uses the build step to trigger downstream jobs synchronously; the downstream jobs need the same executors, so all executors get occupied by “waiting upstream” jobs, forming a deadlock.
Root cause: Each executor runs only one task at a time; a Pipeline's node block holds its executor from entry to exit, even while it is inside input or sleep Inside a node block, waiting for manual approval or for downstream builds keeps the executor occupied for a long time.
Diagnostic command
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/computer/api/json?tree=busyExecutors,totalExecutors" curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/computer/agent1/api/json?depth=1&tree=executors[currentExecutable[url]]" | jq -r '.executors[].currentExecutable.url'
Fix
// input goes outside node (Declarative: stage-level agent none + input directive)
pipeline {
agent none
stages {
stage('build') { agent { label 'linux' }; steps { sh 'make' } }
stage('approve') { steps { input message: 'Deploy to prod?' } } // does not occupy an executor
stage('deploy') { agent { label 'linux' }; steps { sh './deploy.sh' } }
}
}
Prevention & Best Practices
- Use cloud agents (Kubernetes, EC2 Fleet) for elastic scaling; the executor count of a static agent ≈ the number of CPU cores.
- For downstream triggers, use
build job: 'x', wait: false, or ensure upstream and downstream use different label pools; control concurrency with Lockable Resources / Throttle Concurrent Builds.
See Lesson 2 Module 4 Parallel & Stage Control,Lesson 7 Module 2.
#28 http://jenkins:8080/ provided port:50000 is not reachable on host jenkins
INFO: Locating server among [http://jenkins:8080/] SEVERE: http://jenkins:8080/ provided port:50000 is not reachable on host jenkins java.io.IOException: http://jenkins:8080/ provided port:50000 is not reachable on host jenkins
Symptom: Inbound agents (jenkins/inbound-agent, Kubernetes Pod agents) stay offline, and the agent log keeps retrying.
Root cause: An inbound agent first contacts the controller over HTTP to obtain the TCP agent port (in the response header X-Jenkins-JNLP-Port), then establishes the remoting connection over TCP. Typical reasons TCP 50000 is unreachable while HTTP works: the port is mapped only to 127.0.0.1 (agents from other hosts cannot reach it), there is no jenkins-agent Service in Kubernetes, the firewall or LB only opens 443, or “TCP port for inbound agents” is set to random or disabled in the global security settings.
Diagnostic command
curl -sI http://127.0.0.1:8080/login | grep -i x-jenkins-jnlp-port docker compose exec agent1 sh -c 'timeout 3 bash -c "</dev/tcp/jenkins/50000" && echo open || echo closed' kubectl -n jenkins get svc jenkins-agent -o wide # the agent Service of the Helm chart
Fix
- Open the TCP port; or switch to WebSocket mode (add
-webSocket, and tick WebSocket on the Kubernetes cloud), which needs only one HTTP(S) port and suits setups behind a reverse proxy or Ingress (the proxy must support the Upgrade header, #8). - Fix the agent port (JCasC
jenkins.slaveAgentPort: 50000), rather than using a random port.
Prevention & Best Practices
- For agents across networks, prefer WebSocket or SSH; do not expose port 50000 to the public internet.
#29 hudson.remoting.ChannelClosedException: … The channel is closing down or has closed down
Cannot contact agent1: hudson.remoting.ChannelClosedException: Channel "hudson.remoting.Channel@6f1d2c3a:agent1": Remote call on agent1 failed. The channel is closing down or has closed down … Agent agent1 was deleted; cancelling node body ← common when a Kubernetes/cloud agent is reclaimed
Symptom: The build fails midway or gets stuck at a step; the agent shows offline and then back online. For a Pipeline,sh is a durable task: if the agent briefly disconnects and then reconnects, it can usually continue; if the agent process or container is killed, it cannot be recovered.
Root cause: The remoting channel drops: the agent process or container is OOM-killed or restarted, a network device times out an idle long-lived connection, the controller–agent ping times out, or a cloud agent is scaled in or preempted (Spot).
Diagnostic command
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/computer/agent1/api/json?tree=offline,offlineCauseReason"
docker compose logs agent1 --since 30m | tail -20
docker inspect --format 'OOM={{.State.OOMKilled}} restarts={{.RestartCount}}' $(docker compose ps -q agent1)
# Disconnect reason in the controller logs: Manage Jenkins → System Log; node page → Log
Fix
- Agent OOM: increase memory or limit build parallelism (JVM tool settings
-Xmx/MAVEN_OPTS); for container agents see #36. - Network idle disconnect: adjust the load balancer's idle timeout, or use WebSocket; if needed, adjust the remoting ping interval (see the official documentation).
- Spot / scale-in: use an on-demand node pool for critical pipelines; use
retry(conditions: [agent(), kubernetesAgent()], count: 2)to retry the wholenodeblock on a new agent.
Prevention & Best Practices
- Builds should be retryable (idempotent); publish artifacts last and only once.
#30 Host key verification failed. (Git over SSH / SSH agent connection)
stderr: Host key verification failed. fatal: Could not read from remote repository. … [SSH] WARNING: No entry currently exists in the Known Hosts file for this host. ← from the SSH Build Agents plugin; wording subject to actual output
Symptom: On the new agent, git clone git@… fails; or the SSH Build Agents plugin fails to connect to the new node.
Root cause: The SSH client requires the server host key to be in known_hosts . The Git plugin has a “Git Host Key Verification Configuration” (under global security: Known hosts file / Accept first connection / Manually provided keys / No verification); the SSH Build Agents plugin has a per-node “Host Key Verification Strategy”. Either is triggered when a new machine is added or a rebuilt server's host key changes.
Diagnostic command
ssh-keyscan -t ed25519 gitea.example.com docker compose exec agent1 sh -c 'cat ~/.ssh/known_hosts 2>/dev/null | wc -l'
Fix
# JCasC: change the Git host key verification strategy to “Manually provided keys” and write the ssh-keyscan output into it
security:
gitHostKeyVerificationConfiguration:
sshHostKeyVerificationStrategy:
manuallyProvidedKeyVerificationStrategy:
approvedHostKeys: |
gitea.example.com ssh-ed25519 AAAAC3Nza…
Prevention & Best Practices
- Do not choose “No verification” (man-in-the-middle risk); announce host key rotations in advance and update the configuration.
- The Gitea in the local lab environment uses HTTP + token (credential
gitea-myapp), so you will not hit this problem.
#31 Disk space is below threshold of 1.00 GiB. Only … left on /home/jenkins/agent.
Making agent1 offline temporarily due to the lack of disk space Disk space is below threshold of 1.00 GiB. Only 812.34 MiB out of 58.42 GiB left on /home/jenkins/agent.
Symptom: The agent is automatically marked offline, and all builds using its label start queuing (in the is offline of #26); or a build midway through reports No space left on device, #21.
Root cause: Node Monitors periodically check the free space of each node's workspace and temp directory, and take a node temporarily offline when it falls below a threshold. Common causes of space being consumed: workspaces are never cleaned up, Docker images and build caches pile up,@tmp/@2 directories, logs and test artifacts.
Diagnostic command
docker compose exec agent1 sh -c 'df -h /home/jenkins/agent; du -sh /home/jenkins/agent/workspace/* 2>/dev/null | sort -h | tail -5' docker system df # if the agent uses the host's Docker
Fix
docker compose exec agent1 sh -c 'rm -rf /home/jenkins/agent/workspace/*@tmp' docker builder prune -f --filter until=72h && docker image prune -af --filter until=168h # Recover the node: after disk space is restored, monitoring automatically logs “Putting agent1 back online”; you can also bring it online manually on the node page
Prevention & Best Practices
- Clean the workspace at the end of the pipeline
post { cleanup { cleanWs() } }(Workspace Cleanup plugin); prefer ephemeral agents (containers or Pods), whose workspaces are destroyed with them. - Schedule regular prune on Docker hosts; adjust thresholds in Manage Jenkins → Nodes → Node Monitoring , and do not simply lower them to “silence the alerts”.
See Lesson 2 Module 5 Artifacts, stash & Workspace Management.
#32 ERROR: Could not find credentials entry with ID 'registry-creds'
[Pipeline] withCredentials ERROR: Could not find credentials entry with ID 'registry-creds' Finished: FAILURE
Symptom: The credential clearly exists (the administrator can see it in the UI), but the Pipeline cannot find it; or it is available in folder A but not in folder B.
Root cause: Lookup is done by “ID + context”: ① IDs are case-sensitive and the spelling must match exactly; ② scope: System scoped credentials are used only by Jenkins itself (e.g. to connect agents) and are invisible to Pipelines; you need Global; ③ folder credentials are visible only to that folder and its children; ④ when “Authorize Project” is enabled, lookup is done as the triggering user, and a user without Credentials/UseItem permission will not see it either.
Diagnostic command
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/credentials/store/system/domain/_/api/json?tree=credentials[id,typeName,scope]" | jq -c '.credentials[]' curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/job/lab8/credentials/store/folder/domain/_/api/json?tree=credentials[id,typeName]" 2>/dev/null | jq -c '.credentials[]?'
{"id":"gitea-myapp","typeName":"Username with password","scope":"GLOBAL"}
{"id":"registry-creds","typeName":"Username with password","scope":"SYSTEM"} ← SYSTEM: not visible to Pipelines
Fix
- Change the scope to Global, or create it in the corresponding folder; correct the ID spelling.
- Put team credentials in a team folder (for permission isolation), rather than all in the global scope.
Prevention & Best Practices
- Use a uniform naming convention for credential IDs (in this course:
gitea-myapp,registry-creds), managed with JCasC or an external secrets provider (Vault, Key Vault, AWS Secrets Manager).
See Lesson 1 Module 6,Lesson 6 Module 3 Credential Management: Credential Domains, Vault & External Secrets.
#33 Credentials 'gitea-myapp' is of type 'SSH Username with private key' where 'Username with password' was expected
ERROR: Credentials 'gitea-myapp' is of type 'SSH Username with private key' where 'Username with password' was expected
Symptom: The ID is correct, but binding fails.
Root cause: Each binding accepts only specific credential types: usernamePassword ↔ Username with password; string ↔ Secret text; file ↔ Secret file; sshUserPrivateKey ↔ SSH Username with private key; cloud plugins have their own types (Azure Service Principal / Managed Identity, AWS Credentials).
Diagnostic command
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/credentials/store/system/domain/_/credential/gitea-myapp/api/json?tree=typeName,id"
Fix
// Choose the binding according to the credential type
withCredentials([sshUserPrivateKey(credentialsId: 'gitea-ssh', keyFileVariable: 'KEY', usernameVariable: 'U')]) { sh 'GIT_SSH_COMMAND="ssh -i $KEY" git fetch' }
withCredentials([usernamePassword(credentialsId: 'gitea-myapp', usernameVariable: 'U', passwordVariable: 'T')]) { sh 'git -c credential.helper= fetch "http://$U:$T@gitea:3000/lab/myapp.git"' }
Prevention & Best Practices
- Include the purpose and a type hint in the ID (for example
gitea-myappfor tokens,gitea-sshfor private keys); one credential per purpose.
See Lesson 1 Module 6.
#34 permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
+ docker build -t myapp:1.1 . permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: …: connect: permission denied ERROR: script returned exit code 1
Symptom: The agent has the Docker CLI, but image builds fail; running the same thing on the host with your own account works fine.
Root cause: The agent process runs as jenkins (UID 1000), and the mounted /var/run/docker.sock belongs to the host's docker group (GID varies by distribution), and the user inside the container is not in that GID.
Diagnostic command
docker compose exec agent1 sh -c 'id; ls -ln /var/run/docker.sock'
uid=1000(jenkins) gid=1000(jenkins) groups=1000(jenkins) srw-rw---- 1 0 988 0 Nov 16 08:00 /var/run/docker.sock
Fix
# compose.yaml: add the socket's GID as a supplementary group of the agent process
services:
agent1:
group_add: ["${DOCKER_GID:-999}"] # Lesson 1's approach: DOCKER_GID in .env is the socket's owning group (the GID seen with ls -ln above)
Prevention & Best Practices
- Security trade-off: access to the Docker socket is equivalent to root on the host. In production, prefer a dedicated build VM, rootless BuildKit, Buildah, or unprivileged image builds on Kubernetes (the original Kaniko repository was archived in 2025; evaluate maintained forks or alternatives).
- Do not use
chmod 666 /var/run/docker.sock.
See Lesson 2 Module 6 Docker Builds & Containerized Agents,Lesson 6 Module 6 Controller and Agent Isolation.
#35 ERROR: Unable to create pod kubernetes jenkins/… Forbidden: … cannot create resource "pods"
ERROR: Unable to create pod kubernetes jenkins/myapp-build-7-xk2lp-0bq3m-5k8s2. Failure executing: POST at: https://kubernetes.default/api/v1/namespaces/jenkins-agents/pods. Message: pods is forbidden: User "system:serviceaccount:jenkins:jenkins" cannot create resource "pods" in API group "" in the namespace "jenkins-agents".
A similar WARNING: Unable to create pod: … because kubernetes resource quota exceeded. indicates the namespace ResourceQuota is full (the plugin will retry).
Symptom: Builds on the Kubernetes cloud keep queuing (#26), and the errors above keep appearing in the controller log.
Root cause: The Kubernetes plugin uses the controller's ServiceAccount (or the credentials configured in the cloud) to call the API and create agent Pods. If you put agents in another namespace, customize the ServiceAccount, or turn off rbac.create in Helm values, you may be missing permissions in the target namespace for create/get/list/watch/delete pods,pods/exec,pods/log the relevant resources.
Diagnostic command
kubectl auth can-i create pods -n jenkins-agents --as system:serviceaccount:jenkins:jenkins kubectl -n jenkins logs jenkins-0 -c jenkins --since 10m | grep -E 'Unable to create pod|forbidden' | tail -3
Fix
# Helm values: when putting agents in a separate namespace, have the chart create the Role/RoleBinding in that namespace agent: namespace: jenkins-agents rbac: create: true
Prevention & Best Practices
- Agents use a dedicated namespace + ResourceQuota + LimitRange + NetworkPolicy; the controller's SA has Pod permissions only in that namespace, and agent Pods' SAs do not mount tokens by default.
See Lesson 5 Module 5 Kubernetes Plugin: Dynamic Pod Agents.
#36 Container … was terminated (Exit Code: 137, Reason: OOMKilled) / script returned exit code 137
jenkins-agents/myapp-build-12-abcde Container maven was terminated (Exit Code: 137, Reason: OOMKilled). —or— + mvn -B verify Killed ERROR: script returned exit code 137
Symptom: Tests or compilation in Pod agents fail randomly; the agent node disappears from Jenkins; sometimes the whole Pod is deleted, causing #29.
Root cause: The container exceeds resources.limits.memory, and the kernel OOM killer kills the process in the cgroup using the most memory: if it is your build process,sh exits with 137; if it is the container's main process (for example, the Java process in the jnlp container), the entire agent disconnects. JVM tools (Maven, Gradle) default to allocating heap as a share of the container limit, and parallel forks easily push it over.
Diagnostic command
kubectl -n jenkins-agents get pod -l jenkins/label --sort-by=.status.startTime | tail -3 kubectl -n jenkins-agents describe pod <pod> | grep -A3 -E 'Last State|Limits' kubectl -n jenkins-agents get events --field-selector reason=OOMKilling 2>/dev/null | tail
Fix
# Set reasonable requests/limits for the work container in the Pod template, and limit the JVM
containers:
- name: maven
image: maven:3.9-eclipse-temurin-21
resources:
requests: {cpu: "1", memory: "2Gi"}
limits: {memory: "3Gi"}
env:
- {name: MAVEN_OPTS, value: "-XX:MaxRAMPercentage=60"}
Prevention & Best Practices
- Also set requests/limits for the
jnlpcontainer (the Helm chart's defaults are small); when a Pod template fails, keep the Pod (podRetention: onFailure) for investigation, and clean up periodically.
See Lesson 5 Module 5,Kubernetes course (resources and OOM).
#37 AADSTS70021: No matching federated identity record found for presented assertion (Azure federated credentials)
+ az login --service-principal -u "$AZURE_CLIENT_ID" -t "$AZURE_TENANT_ID" --federated-token "$(cat $AZURE_FEDERATED_TOKEN_FILE)" ERROR: AADSTS70021: No matching federated identity record found for presented assertion. Assertion Issuer: 'https://…oic.prod-aks.azure.com/…/'. Assertion Subject: 'system:serviceaccount:jenkins-agents:default'. …
Similar errors: ERROR: Please run 'az login' to setup account. (not logged in at all); when pushing to ACR, unauthorized: authentication required (not az acr login authorized, or missing the AcrPush role).
Symptom: Logging in to Azure with Workload Identity from a Pod agent on AKS fails; or pushing to ACR is rejected after logging in with a managed identity on an Azure VM agent.
Root cause: When exchanging tokens for workload identity, Entra compares the federated credential's issuer issuer (the AKS OIDC issuer URL),subject subject (system:serviceaccount:<namespace>:<SA name>) and audience. If the Pod template does not specify the correct ServiceAccount (it falls back to default, uses a different namespace, or lacks the azure.workload.identity/use: "true" label, the values will not match.
Diagnostic command
az identity federated-credential list -g rg-jenkins-lab --identity-name id-jenkins-agent -o table
kubectl -n jenkins-agents get pod <pod> -o jsonpath='{.spec.serviceAccountName} {.metadata.labels.azure\.workload\.identity/use}{"\n"}'
az role assignment list --assignee <client-id> --scope $(az acr show -n acrjenkins12345 --query id -o tsv) -o table
Fix
# Pod template: use an SA that matches the federated credential's subject, and enable Workload Identity injection
metadata:
labels: {azure.workload.identity/use: "true"}
spec:
serviceAccountName: jenkins-agent # the SA is annotated with azure.workload.identity/client-id
Prevention & Best Practices
- No long-lived keys: on AKS use workload identity; on Azure VM agents use a managed identity (
az login --identity); keep roles minimal (grant AcrPush only for pushes). - Jenkins itself is not an OIDC issuer that Azure trusts natively; the OpenID Connect Provider plugin can let Jenkins issue id tokens, but you must expose Jenkins's issuer to Entra and evaluate that yourself (Lesson 3).
See Lesson 3 Module 2 Jenkins Identity on Azure,Module 7 Cloud Deployment Troubleshooting in Practice.
#38 Unable to locate credentials. You can configure credentials by running "aws configure".
+ aws ecr get-login-password --region ca-central-1 Unable to locate credentials. You can configure credentials by running "aws configure". ERROR: script returned exit code 253
Similar errors: no basic auth credentials (not logged in to ECR before docker push),AccessDenied … is not authorized to perform: ecr:InitiateLayerUpload (insufficient role permissions),name unknown: The repository with name 'myapp' does not exist (the ECR repository must be created in advance).
Symptom: The AWS CLI fails in an EC2 agent or EKS Pod agent, while it works on the host machine itself.
Root cause: The AWS SDK looks up credentials along the credential chain: environment variables → config files → Web Identity (IRSA) → EKS Pod Identity → container credential endpoint → EC2 instance metadata (IMDS). On EC2, accessing IMDSv2 from inside a container requires a hop limit ≥ 2; the instance has no attached instance profile; or the Pod's SA is not associated with an IRSA role or Pod Identity.
Diagnostic command
aws sts get-caller-identity aws configure list env | grep -E '^AWS_(ROLE_ARN|WEB_IDENTITY_TOKEN_FILE|CONTAINER_CREDENTIALS_FULL_URI)' || echo "no IRSA / Pod Identity environment variables" aws ec2 describe-instances --instance-ids <id> --query 'Reservations[].Instances[].MetadataOptions'
Fix
- EC2 agent: attach an instance profile; when accessing IMDSv2 from inside a container, set
HttpPutResponseHopLimitto 2. - EKS Pod agent: in the Pod template, use a ServiceAccount associated with Pod Identity / IRSA.
- When static keys are unavoidable, use the AWS Credentials plugin +
withAWS/withCredentialsbinding, and replace them with roles as soon as possible.
Prevention & Best Practices
- As the first step of the pipeline,
aws sts get-caller-identity, so the current identity is visible in the log and the problem is obvious.
See Lesson 4 Module 2 Jenkins Identity on AWS,Module 7 Cloud Deployment Troubleshooting in Practice.
“Build doesn't run / breaks midway” troubleshooting decision tree
Start from the symptom to reach a conclusion and the corresponding issue number.
~/jenkinslab; Lab 3-D requires the Jenkins on the kind cluster lab (Module 0, step 4, address http://127.0.0.1:8081, where you separately generate an API token and create the lab8 folder).Lab 3-A: wrong label, build waits forever (#26)
cd ~/jenkinslab/lab8
printf "node('dockr') { sh 'true' }\n" > m3a.groovy
./mkjob.sh m3a m3a.groovy
curl -fsS -u "$JUSER:$JTOKEN" -X POST "$JENKINS_URL/job/lab8/job/m3a/build?delay=0sec"; sleep 8
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/queue/api/json?tree=items[id,why]" | jq -c '.items[]'{"id":23,"why":"There are no nodes with the label ‘dockr’"}id=$(curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/queue/api/json?tree=items[id]" | jq '.items[0].id')
curl -fsS -u "$JUSER:$JTOKEN" -X POST "$JENKINS_URL/queue/cancelItem?id=$id"
curl -fsS -u "$JUSER:$JTOKEN" -X POST "$JENKINS_URL/job/lab8/job/m3a/1/stop" 2>/dev/null
cat > m3a.groovy <<'EOF'
node('linux && docker') { sh 'echo ok on $NODE_NAME' }
EOF
./mkjob.sh m3a m3a.groovy && ./runjob.sh m3a 3Lab 3-B: agent drops mid-build (#29)
cat > m3b.groovy <<'EOF'
node('linux') { sh 'for i in $(seq 1 60); do echo tick $i; sleep 2; done' }
EOF
./mkjob.sh m3b m3b.groovy
curl -fsS -u "$JUSER:$JTOKEN" -X POST "$JENKINS_URL/job/lab8/job/m3b/build?delay=0sec"; sleep 15
cd ~/jenkinslab && docker compose stop agent1 && sleep 20
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/job/lab8/job/m3b/lastBuild/consoleText" | tail -5tick 7 Cannot contact agent1: java.lang.InterruptedException ← or ChannelClosedException; wording varies by version
sh process has been killed and usually cannot be recovered; it eventually fails or must be aborted manually):docker compose start agent1 && sleep 30 curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/job/lab8/job/m3b/lastBuild/consoleText" | tail -4 curl -fsS -u "$JUSER:$JTOKEN" -X POST "$JENKINS_URL/job/lab8/job/m3b/lastBuild/stop" 2>/dev/null; cd ~/jenkinslab/lab8
Comparison: when only the network is cut and the process is not killed (the docker network disconnect), after the agent reconnects, the sh often continues — this is the value of a durable task.
Lab 3-C: credential ID and type (#32, #33)
cat > m3c.groovy <<'EOF'
node('linux') {
withCredentials([string(credentialsId: 'gitea-myapp', variable: 'T')]) { sh 'echo bound' }
}
EOF
./mkjob.sh m3c m3c.groovy && ./runjob.sh m3c 4ERROR: Credentials 'gitea-myapp' is of type 'Username with password' where 'Secret text' was expected Finished: FAILURE
gitea-myapp to Gitea-myapp, and get Could not find credentials entry with ID 'Gitea-myapp'; then change it to the correct usernamePassword binding and it succeeds.Lab 3-D (kind): Pod agent exceeds memory limit (#36)
JENKINS_URL=http://127.0.0.1:8081):export JENKINS_URL=http://127.0.0.1:8081 # also export that instance's JTOKEN; first create the lab8 folder as in Module 0, step 2
cat > m3d.groovy <<'EOF'
podTemplate(yaml: '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: py
image: python:3.12-slim
command: ["sleep"]
args: ["infinity"]
resources:
limits: {memory: "64Mi"}
''') {
node(POD_LABEL) {
container('py') { sh 'python -c "b = bytearray(512*1024*1024); print(len(b))"' }
}
}
EOF
./mkjob.sh m3d m3d.groovy && ./runjob.sh m3d 8Created Pod: kubernetes jenkins/m3d-1-xxxxx-yyyyy … + python -c b = bytearray(512*1024*1024); print(len(b)) Killed ERROR: script returned exit code 137 Finished: FAILURE
The process killed is the python process (the container's main process sleep is still running), so it appears as 137; if the main process is killed, you will see the Reaper's Container py was terminated message.
768Mi and re-run successfully; cleanup: curl -fsS -u "$JUSER:$JTOKEN" -X POST "$JENKINS_URL/job/lab8/doDelete"; export JENKINS_URL=http://127.0.0.1:8080Instructional video (title and channel verified via YouTube oEmbed)
No verified video dedicated to Jenkins queue-blocking reasons and troubleshooting Azure/AWS keyless authentication was found. Storyboard:
/label/dockr/ page showing 0 nodes.kubectl describe pod shows OOMKilled; change the limit and re-run.Official documentation
Module 4 · Part A: Security, Performance & Operations (Issues 39–50)
- Explain the order of checks for one HTTP request in Jenkins: reverse proxy → authentication (session / API token / SSO) → CSRF crumb (only for session-authenticated POSTs) → authorization (global matrix / roles / folders) → execution.
- Master the three core tools for controller performance problems: thread dumps, heap & GC, and
JENKINS_HOMEdisk and build-retention checks. - Understand that Jenkins (open-source edition) is a single-active application: one
JENKINS_HOMEcan run only one controller; backups must includesecrets/.
Filter by keywords from the error message (such as crumb,permission,AADSTS,OutOfMemory,casc) ; click a row to jump to “Issue Details”.
#39 HTTP ERROR 403 No valid crumb was included in the request
$ curl -u admin:MyPassw0rd -X POST http://127.0.0.1:8080/job/lab8/job/hello/build <title>Error 403 No valid crumb was included in the request</title>
Symptom: Scripts, callbacks from other systems, or browser form submissions through certain proxies return 403; the same operations done manually in the browser work fine.
Root cause: CSRF protection requires that session-based POST requests carry a crumb, and the crumb is bound to the web session. Using a password for Basic authentication creates a session, so a crumb is required; requests authenticated with API token authentication do not need a crumb. Behind a multi-replica load balancer, or when a proxy strips cookies, a crumb that does not match the session also yields 403.
Diagnostic command
curl -s -o /dev/null -w '%{http_code}\n' -u "admin:$JTOKEN" -X POST "$JENKINS_URL/job/lab8/job/hello/build" # with a token: 201
docker compose logs jenkins --since 5m 2>&1 | grep 'No valid crumb'
Fix
- Switch all automated calls to API tokens (one per system, individually revocable); for Webhooks, use the dedicated endpoint provided by the plugin (no crumb needed).
- When a session is required: first
GET /crumbIssuer/api/jsonfetch a crumb,carry the same cookie when you POST.
Prevention & Best Practices
- Do not disable CSRF protection (new versions no longer allow turning it off in the UI); do not let scripts use a person's password.
See Lesson 6 Module 1 Security Model: Authentication, Authorization & CSRF.
#40 anonymous is missing the Overall/Read permission (or an administrator locks themselves out)
Access Denied anonymous is missing the Overall/Read permission —or— alice is missing the Job/Build permission
Symptom: After changing the authorization strategy (matrix/roles) or SSO settings, nobody, including administrators, can access Jenkins; or a team suddenly cannot see its jobs.
Root cause: Authorization is evaluated on every request: user (and their groups) → global permissions (matrix/roles) → project/folder permissions (inheritable, or can be “blocked from inheritance”). Common mistakes: saving the matrix without granting yourself Overall/Administer; wrong SSO group mapping (Entra returns group object IDs, while the matrix uses group display names); forgetting to add the team after enabling “block inheritance”.
Diagnostic command
curl -fsS -u "alice:$ALICE_TOKEN" "$JENKINS_URL/whoAmI/api/json" | jq '{name,authorities}'
docker compose exec jenkins grep -A3 '<authorizationStrategy' /var/jenkins_home/config.xml
Fix
# Lockout recovery (official “Disable security” procedure): stop → back up → edit config.xml → start → reconfigure immediately docker compose stop jenkins docker compose run --rm --entrypoint sh jenkins -c 'cp /var/jenkins_home/config.xml /var/jenkins_home/config.xml.bak && sed -i "s#<useSecurity>true</useSecurity>#<useSecurity>false</useSecurity>#" /var/jenkins_home/config.xml' docker compose start jenkins # NO authentication at this point! Operate only on an isolated network, and restore security as soon as authorization is fixed # When using JCasC: fix authorizationStrategy in the YAML and reload; this is safer than editing the XML
Prevention & Best Practices
- Manage authorization configuration with JCasC and review it; keep one “break-glass” local administrator account (store its credentials in a vault).
- For SSO group mapping, first use
whoAmIto confirm the actual values of authorities before writing them into the matrix.
#41 AADSTS50011: The redirect URI … specified in the request does not match the redirect URIs configured for the application
AADSTS50011: The redirect URI 'http://jenkins.example.com/securityRealm/finishLogin' specified in the request does not match the redirect URIs configured for the application '…'.
Symptom: After enabling Entra ID / OIDC login, clicking Sign in redirects to a Microsoft error page.
Root cause: The OIDC plugin (oic-auth) and the Microsoft Entra ID plugin (azure-ad) both build the callback address with Jenkins URL (e.g. …/securityRealm/finishLogin). If the Jenkins URL is set to http:// or an internal hostname (#12), or the reverse proxy does not pass X-Forwarded-Proto (#8), the generated address will not match the one registered in the application.
Diagnostic command
curl -s -u "$JUSER:$JTOKEN" "$JENKINS_URL/scriptText" --data-urlencode 'script=println jenkins.model.JenkinsLocationConfiguration.get().url' az ad app show --id <app-id> --query web.redirectUris
Fix
- Change the Jenkins URL to an external HTTPS address; add an exactly matching callback URI in the application registration (for the path, follow the documentation of the plugin in use).
- Before changing SSO, keep a logged-in administrator session open as a fallback, or prepare the recovery steps from #40.
Prevention & Best Practices
- Manage both the SSO configuration and the application registration as code (JCasC + Terraform); environments differ only in variables.
#42 Building on the built-in node can be a security issue. You should set up distributed builds.
Building on the built-in node can be a security issue. You should set up distributed builds. See the documentation. —— (when agents already exist) —— Building on the built-in node can be a security issue. You should set the number of executors on the built-in node to 0. See the documentation.
Symptom: A warning appears at the top of Manage Jenkins; the build log shows Running on Jenkins in /var/jenkins_home/workspace/….
Root cause: Builds running on the built-in node run as the same user and on the same filesystem as the controller process: anyone who can edit the Jenkinsfile can read $JENKINS_HOME/secrets,credentials.xml and even modify the configuration. Builds also compete with the controller for CPU, memory and disk (#44, #46).
Diagnostic command
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/computer/(built-in)/api/json?tree=numExecutors"
Fix
# JCasC jenkins: numExecutors: 0 mode: EXCLUSIVE
Prevention & Best Practices
- Run all builds on agents; in Declarative, use lightweight steps with
agent none+ stage-level agent, rather than falling back to the built-in node.
#43 Warnings have been published for the following currently installed components:
Warnings have been published for the following currently installed components: Script Security Plugin 1.xx: Sandbox bypass vulnerability … Jenkins 2.xxx core and libraries: …
Symptom: A red/yellow security warning appears at the top of the management page; or a security team scan finds known CVEs in Jenkins.
Root cause: The update center metadata includes published security advisories (for core and plugins). The Jenkins security team publishes advisories regularly (2026 has already seen several, such as 6/10, 6/24, 8/5, 9/2, 9/16 and 10/28); fixes usually land only in the latest weekly and LTS; and some plugins are suspended from distribution (for example, azure-cli,kubernetes-cd are already on the deprecated/suspended list).
Diagnostic command
docker run --rm -v "$PWD/plugins.txt:/p.txt:ro" --entrypoint jenkins-plugin-cli jenkins/jenkins:2.580.2-jdk21 --plugin-file /p.txt --view-security-warnings --no-download # UI: Manage Jenkins → Plugins → Updates (entries with security notices are flagged)
Fix
- Upgrade to the fixed version as the advisory describes; for plugins with no fix, apply the mitigations in the advisory, or uninstall and replace them.
- Do not simply “hide” the warnings (you can hide specific warnings in the Security settings, but only after confirming you are not affected).
Prevention & Best Practices
- Subscribe to the Jenkins security advisories mailing list; follow the least-plugins principle; keep a fixed monthly maintenance window.
See Lesson 6 Module 5 Plugin Security: Vulnerability Advisories & Plugin Governance.
#44 java.lang.OutOfMemoryError: Java heap space (controller)
SEVERE hudson.model.Executor#finish1: Executor threw an exception java.lang.OutOfMemoryError: Java heap space —— in a container —— $ docker inspect … → OOMKilled=true ← heap + non-heap exceed the container memory limit
Symptom: The UI gets slower and slower, and eventually stops responding or the process restarts; GC logs show frequent Full GC.
Root cause: Common memory hogs: huge build records being loaded (builds never cleaned up + frequent access to history and trend charts), huge console logs being processed on the controller, large files read on the controller side in a Pipeline (readFile one a few hundred MB in size), and plugin memory leaks. In a container, if only the JVM is set to a heap larger than the limit ( -Xmx), the symptom is the container being killed rather than an OOM exception.
Diagnostic command
curl -s -u "$JUSER:$JTOKEN" "$JENKINS_URL/scriptText" --data-urlencode 'script=def r=Runtime.runtime; println "max=${r.maxMemory()>>20}MB total=${r.totalMemory()>>20}MB free=${r.freeMemory()>>20}MB"'
docker stats --no-stream $(docker compose ps -q jenkins)
# Heap dump: add -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/jenkins_home/dumps to JAVA_OPTS in advance
Fix
# compose.yaml: set the heap as a proportion of container memory, leaving room for non-heap space
services:
jenkins:
environment:
JAVA_OPTS: "-XX:MaxRAMPercentage=60 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/jenkins_home/dumps"
mem_limit: 4g
Prevention & Best Practices
- Set build retention on all jobs (
options { buildDiscarder(logRotator(numToKeepStr: '30')) }); process large files on an agent'sshinstead. - Monitor heap usage and GC time (Prometheus plugin / OpenTelemetry), and alert rather than waiting for a crash.
See Lesson 7 Module 5 Performance: Controller Scale, JVM & Build Retention.
#45 controller is very slow: pages take tens of seconds to load, queue scheduling is delayed, CPU stays at 100% for long periods
"Handling GET /job/big/ from 10.0.0.12 : …" RUNNABLE at hudson.model.RunMap.… ← loading a large amount of build history "SCM polling for hudson.model.FreeStyleProject@…" RUNNABLE × 400 "jenkins.util.Timer [#3]" … waiting on …
Symptom: There is no explicit error, but everyone feels Jenkins is stuck; after a restart it is fine for a while, then slows down again.
Root cause: The controller takes on load it should not: hundreds of jobs polling SCM every minute, massive build histories, builds running on the built-in node (#42),JENKINS_HOME placed on a slow NFS, overly heavy Groovy logic in Pipelines (CPS runs on the controller), and periodic tasks from too many plugins.
Diagnostic command
for i in 1 2 3; do curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/threadDump" -o td-$i.html; sleep 10; done # take several dumps and compare
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/scriptText" --data-urlencode 'script=println Jenkins.instance.getAllItems(Job).collect{ it.builds.size() }.sum()'
# Support Core plugin: Manage Jenkins → Support → generate a support bundle (includes thread dumps, GC, plugins, slow requests)
Fix
- Change SCM polling to Webhooks (#24); set the built-in node to 0 executors; clean up historical builds and set build retention.
JENKINS_HOMEMove it to local SSD/block storage; use thePipeline speed/durabilitysetting (PERFORMANCE_OPTIMIZED) to reduce IO (trade-off: running pipelines may not be recoverable if the controller crashes).- When one controller cannot handle the load, split it into multiple controllers by team or business unit (horizontal sharding).
Prevention & Best Practices
- Capacity baseline: the controller's CPU, heap, GC, request latency and queue length should be on the dashboard (Lesson 5 Module 7).
#46 java.io.IOException: No space left on device (JENKINS_HOME is full)
WARNING hudson.model.Run#execute: … java.io.IOException: No space left on device at java.base/java.io.FileOutputStream.writeBytes(Native Method)
Symptom: Build logs are truncated, configuration saves fail (sometimes leaving a 0-byte config.xml), and the controller cannot start.
Root cause:JENKINS_HOME The fastest-growing contents of jobs/*/builds/ are usually the build directories (logs,archiveArtifacts artifacts),fingerprints/, the built-in node's workspace/ workspaces, plugin caches and logs,dumps/ and similar. Once full, XML files being written may be corrupted.
Diagnostic command
docker compose exec jenkins sh -c 'df -h /var/jenkins_home; du -xsh /var/jenkins_home/* 2>/dev/null | sort -h | tail -8' docker compose exec jenkins sh -c 'du -sh /var/jenkins_home/jobs/*/builds 2>/dev/null | sort -h | tail -5'
Fix
- Immediately: expand the volume; delete the largest old builds (through the UI or a script, not by deleting directories directly, to avoid index inconsistency).
- Store artifacts in an external repository instead (Nexus, Artifactory, ACR/ECR, S3/Blob, with the Artifact Manager plugin).
- Check for truncated or corrupted XML files (
find … -name config.xml -size 0), and restore them from backup.
Prevention & Best Practices
- Set a global default build retention policy (Build Discarder plugin); set a disk-usage alert threshold of 80%.
See Lesson 5 Module 6 Backup, Restore & Upgrade Strategy,Lesson 7 Module 5.
#47 Spread load evenly by using ‘H 2 * * *’ rather than ‘0 2 * * *’
Spread load evenly by using ‘H 2 * * *’ rather than ‘0 2 * * *’
Symptom: Every day at exactly 2:00 AM, hundreds of nightly builds enter the queue at once: agents are saturated, the controller stutters, and the Git server is overwhelmed by a flood of clone requests.
Root cause: The cron expression hard-codes the minute. Jenkins' H (hash) generates a stable “random” value from the job name, spreading jobs with the same expression across the time window (H 2 * * * is spread between 2:00 and 2:59,H/15 * * * * every 15 minutes but with different start points).
Diagnostic command
docker compose exec jenkins sh -c "grep -rhoE '<spec>[^<]+' /var/jenkins_home/jobs --include=config.xml | sort | uniq -c | sort -rn | head"
grep -rn "cron(" Jenkinsfile
Fix
pipeline {
triggers { cron('H 2 * * 1-5') } // a fixed minute during the 2 AM hour on weekdays
…
}
Prevention & Best Practices
- The
triggersin the Jenkinsfile should also useH(a Pipeline shows no form warning, so rely on review); avoid high-frequencypollSCM.
#48 JCasC: Invalid configuration elements for type: … Available attributes : … / No configurator found for the following root element
io.jenkins.plugins.casc.UnknownAttributesException: Invalid configuration elements for type: class jenkins.model.Jenkins : numExecutor. Available attributes : authorizationStrategy, crumbIssuer, labelString, mode, nodes, numExecutors, … —or— No configurator found for the following root element: kubernetes. This may indicate that the required plugin is not installed or failed to load. …
Symptom: The controller fails to start (a JCasC application failure at startup aborts initialization), or a configuration Reload fails; on Kubernetes it shows up as the controller container in CrashLoopBackOff.
Root cause: JCasC maps YAML keys to the plugin's @DataBound attributes: a typo, an attribute renamed after a plugin upgrade, or the plugin that provides that root element is not installed or failed to load (#3) will all produce errors. By default, unknown attributes are rejected.
Diagnostic command
# Validate only, do not apply (POST the YAML to the check endpoint; requires Overall/SystemRead) curl -s -u "$JUSER:$JTOKEN" -X POST --data-binary @jenkins.yaml "$JENKINS_URL/configuration-as-code/check" | jq . # See which attributes are available on this instance: Manage Jenkins → Configuration as Code → Documentation / View Configuration (export)
Fix
- Correct the key names according to the Available attributes listed in the error; first make sure the plugin loads successfully before applying its configuration.
- Export the configuration once before upgrading plugins (View Configuration); after upgrading, export again to compare and update the YAML in the repository.
Prevention & Best Practices
- In CI, run the JCasC YAML against a temporary Jenkins with the same plugin versions as production
check; plugin manifests and the YAML should be changed in the same PR.
#49 All credentials invalid after restoring from backup: javax.crypto.BadPaddingException / credential is empty
WARNING hudson.util.Secret#decrypt: Failed to decrypt secret javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
Symptom: After restoring a new controller from backed-up jobs/,config.xml and credentials.xml , all pipelines fail to log in to the Git / image registry, and the passwords on the credentials page are empty.
Root cause: Credentials are encrypted on disk; the key is stored in $JENKINS_HOME/secrets/ (master.key,hudson.util.Secret etc.). For “safety,” the backup script excluded secrets/, or backed up only part of the directories; after restore, they cannot be decrypted.
Diagnostic command
docker compose exec jenkins ls -l /var/jenkins_home/secrets/ | head docker compose logs jenkins 2>&1 | grep -c 'Failed to decrypt'
Fix
- Restore the complete
secrets/directory from the same backup point (it must matchcredentials.xml), then restart. - If the key is lost, all credentials must be re-entered — this is also why it is recommended to store credentials in an external secrets store (Vault, Key Vault, AWS Secrets Manager credentials provider) or to inject them from the environment via JCasC.
Prevention & Best Practices
- Back up the entire
JENKINS_HOME(you may excludeworkspace/,caches/), and store the backup itself encrypted; regularly rehearse restores, since a backup that has never been rehearsed does not count as a backup.
#50 Two controllers sharing one JENKINS_HOME: Collision detected / Multi-Attach error
SEVERE hudson.util.DoubleLaunchChecker#execute: Collision detected. timestamp=1763280000000, expected=1763279990000 ——Kubernetes—— Warning FailedAttachVolume Multi-Attach error for volume "pvc-…" Volume is already exclusively attached to one node and can't be attached to another
Symptom: In the name of “high availability”, the controller is set to 2 replicas on RWX storage, or during a rolling update old and new Pods run at the same time; afterwards configuration gets overwritten, build numbers are duplicated, and build records are corrupted; the management page shows a warning that “another Jenkins is using the same directory”. With RWO volumes, the new Pod gets stuck in ContainerCreating.
Root cause: All state in open-source Jenkins lives in memory plus JENKINS_HOME , with no distributed lock, and does not support multiple controllers using the same home. DoubleLaunchChecker detects conflicts by periodically writing .owner files, but it can only raise an alarm, not prevent corruption.
Diagnostic command
kubectl -n jenkins get statefulset jenkins -o jsonpath='{.spec.replicas} {.spec.updateStrategy.type}{"\n"}'
kubectl -n jenkins get pod -l app.kubernetes.io/component=jenkins-controller -o wide
kubectl -n jenkins get events --field-selector reason=FailedAttachVolume | tail -3
Fix
- Fix the controller replica count at 1 (the official Helm chart uses a StatefulSet, a single replica, and an RWO PVC); stop the extra instances immediately, and restore the damaged data from the most recent consistent backup.
- If you need higher availability: fast recovery (health checks + automatic rebuild + a small
JENKINS_HOME), with multiple controllers split by team; true active/active HA requires a commercial distribution (such as CloudBees CI).
Prevention & Best Practices
- Add “Jenkins is a single-active stateful service” to the architecture review checklist; guarantee RTO/RPO with backup and rebuild times.
See Lesson 7 Module 6 Reliability: High Availability, Disaster Recovery & Large-Scale Jenkins,Lesson 5 Module 4.
Authentication chain simulator for a request
Select a type of request, click “Run”, and observe at which check it fails and what it returns. The stage order corresponds to Jenkins's filter chain (authentication filter → CrumbFilter → object permission check → execution).
~/jenkinslab. Lab 4-C requires the Configuration as Code plugin (installed in Lesson 5; if not, install it under Plugins and restart).Lab 4-A: password vs API token and CSRF (#39)
read -rs JPASS # enter the admin password
curl -s -o /dev/null -w 'password: %{http_code}\n' -u "admin:$JPASS" -X POST "$JENKINS_URL/job/lab8/job/hello/build"
curl -s -o /dev/null -w 'token: %{http_code}\n' -u "admin:$JTOKEN" -X POST "$JENKINS_URL/job/lab8/job/hello/build"password: 403 token: 201
CJ=$(mktemp)
CRUMB=$(curl -s -c "$CJ" -u "admin:$JPASS" "$JENKINS_URL/crumbIssuer/api/json" | jq -r '.crumbRequestField+":"+.crumb')
curl -s -o /dev/null -w 'session+crumb: %{http_code}\n' -b "$CJ" -u "admin:$JPASS" -H "$CRUMB" -X POST "$JENKINS_URL/job/lab8/job/hello/build"
rm -f "$CJ"; unset JPASSLab 4-B: controller health snapshot (#44, #45)
curl -s -u "$JUSER:$JTOKEN" "$JENKINS_URL/scriptText" --data-urlencode 'script=def r=Runtime.runtime; println "heap max=${r.maxMemory()>>20}MB used=${(r.totalMemory()-r.freeMemory())>>20}MB"; println "threads=${Thread.allStackTraces.size()}"; println "jobs=${Jenkins.instance.getAllItems(Job).size()} builds=${Jenkins.instance.getAllItems(Job).collect{it.builds.size()}.sum()}"'
docker stats --no-stream --format '{{.Name}} {{.CPUPerc}} {{.MemUsage}}' $(docker compose -f ~/jenkinslab/compose.yaml ps -q jenkins)heap max=1024MB used=312MB threads=87 jobs=12 builds=41 jenkinslab-jenkins-1 0.85% 690MiB / 7.6GiB
curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/threadDump" | sed 's/<[^>]*>//g' | grep -E '^"' | cut -c1-70 | sort | uniq -c | sort -rn | head
Lab 4-C: JCasC validation of unknown attributes (#48)
cd ~/jenkinslab/lab8 cat > bad-casc.yaml <<'EOF' jenkins: numExecutor: 0 EOF curl -s -u "$JUSER:$JTOKEN" -X POST --data-binary @bad-casc.yaml "$JENKINS_URL/configuration-as-code/check" | jq .
[
{
"line": -1,
"message": "Invalid configuration elements for type: class jenkins.model.Jenkins : numExecutor.\nAvailable attributes : … numExecutors, …"
}
]numExecutors: 0 then run check again; it returns [] (no problems). check does not modify the instance; to apply the configuration, use Manage Jenkins → Configuration as Code.Lab 4-D: a disk threshold takes an agent offline (#31, #46)
100000GiB and save, then click “Refresh status”:sleep 10; curl -fsS -u "$JUSER:$JTOKEN" "$JENKINS_URL/computer/agent1/api/json?tree=offline,offlineCauseReason" | jq .
{
"offline": true,
"offlineCauseReason": "Disk space is below threshold of 100,000.00 GiB. Only 41.20 GiB out of 58.42 GiB left on /home/jenkins/agent."
}./runjob.sh hello: the build queues and shows ‘agent1’ is offline (press Ctrl+C to exit and cancel). Change the threshold back to 1GiB, and once the node comes back online automatically, the build continues.rm -f ~/jenkinslab/lab8/bad-casc.yamlInstructional video (title and channel verified via YouTube oEmbed)
No verified video specifically covering CSRF crumbs, lockout recovery, and backup/restore drills was found. Storyboard:
secrets/ gets a restore drill that shows all credentials invalid; then a successful restore from a complete backup.Official documentation
Module 5 · Part B: Architecture & Fundamentals (Interview 1–13)
- Be able to draw on a whiteboard the relationship between the controller, agents, executors, the queue and
JENKINS_HOME, and explain every step of a build from trigger to result. - Answer “why” questions: why the built-in node has 0 executors, why plugins are upgraded as a group, why credentials in the System scope are invisible to Pipelines, and why cron should use H.
- Every answer should map to a command or configuration, and cite one production experience.
Browse the questions and their focus first; mark the ones you are unsure about; click a row to jump to the detailed answer.
Q1. What is Jenkins' architecture? What does each of controller, agent and executor do?Beginner
30-second answer
Jenkins is a Java web application. controller The controller handles the UI/API, configuration, the scheduling queue and saving build records, and runs the Pipeline's Groovy orchestration logic on top of that; agent are the worker machines connected through the remoting channel that actually execute sh/bat and other steps; executor are concurrent slots on a node; each executor runs one task at a time. All state is stored in the controller's JENKINS_HOME .
In-depth answer
- Nodes = the built-in node + static agents + cloud agents (Kubernetes, EC2 Fleet, Azure VMs created on demand and reclaimed after use).
- remoting: a bidirectional RPC channel between controller and agent, which can be established via an inbound TCP port, WebSocket or SSH (Q5).
- In a Pipeline, the Groovy runs on the controller (CPS), and only steps are sent to agents — so complex Groovy logic consumes the controller's CPU.
Common follow-up
- If the controller goes down, what happens to running builds? A Pipeline can resume from
program.datafter a restart (depending on the durability setting and step types); Freestyle builds are lost. - Does open-source Jenkins have HA? No active/active HA (#50, Q29).
Bonus points
Mention that “master” has been renamed to controller and “slave” to agent, and that the built-in node's label is built-in; and proactively mention that the built-in node has 0 executors in production (Q6).
Common wrong answer
“Running the Jenkins service on agents too” — agents only run the remoting process (agent.jar).
See Lesson 1 Module 1.
Q2. What steps does a build go through from trigger to completion?Beginner
30-second answer
Trigger (Webhook, schedule, manual, upstream) → enters the queue (quiet period, de-duplication, blocking checks) → according to the label finds a matching, online node (or has a cloud create one) → allocates a free executor → prepares on the node workspace and checkout → runs the steps, streaming logs back to the controller → archives artifacts and test reports → writes the result (SUCCESS/UNSTABLE/FAILURE/ABORTED) and triggers post actions and notifications.
In-depth answer
- Queue item states: waiting (quiet period) → blocked (the same job is running, or a resource lock is held) → buildable (waiting for an executor) → pending (allocated, starting up).
whyfield gives the reason (#26). - Each
node/agentblock in a Pipeline requests an executor again, and theStill waiting to schedule taskin the log is exactly this step.
curl -s -u admin:$JTOKEN "$JENKINS_URL/queue/api/json?tree=items[why,task[name],buildable,blocked]"
Common follow-up
- Why does two consecutive pushes produce only one build? Duplicate triggers within the quiet period are merged.
Bonus points
Mention the “flyweight executor”: the Pipeline's own orchestration occupies an uncounted lightweight executor on the controller,node and only takes a real executor when
Common wrong answer
“The build starts immediately when triggered” — ignores the queue and scheduling.
Q3. What are the differences between Freestyle, Pipeline, Multibranch Pipeline and Organization Folder?Beginner
30-second answer
Freestyle Steps are configured in the UI, so the configuration is not in code; Pipeline describes the whole flow with a Jenkinsfile (Groovy DSL), which can be versioned and resumed after a restart; Multibranch scans one repository and automatically creates a Pipeline for each branch/PR that contains a Jenkinsfile; Organization Folder scans an entire organization (GitHub org, Gitea organization) and creates a Multibranch job for each repository.
In-depth answer
| Type | Where configured | Best for |
|---|---|---|
| Freestyle | XML in JENKINS_HOME | legacy, very simple jobs |
| Pipeline | Jenkinsfile (or a script in the job) | single flow |
| Multibranch | Jenkinsfile in the repository + scan rules | branch/PR builds (recommended default) |
| Organization Folder | organization-level scan rules | platform scale, dozens to hundreds of repositories |
Common follow-up
- How do you put the job configuration itself into code? Job DSL / JCasC (Q30).
Bonus points
Point out Multibranch's trust policy for fork PRs (#23) and the orphan-cleanup policy for jobs after their branches are deleted.
Common wrong answer
“A Pipeline is just another way of writing Freestyle” — ignores persistence, parallelism, code review and reuse.
Q4. What is the difference between Declarative Pipeline and Scripted Pipeline? How do you choose?Beginner
30-second answer
Both run on the same Pipeline engine (CPS). Declarative Declarative has a fixed structure (pipeline/agent/stages/steps/post), validates the model before running, and provides built-in when,options,post,input,matrix; it is readable and catches errors early; Scripted Scripted is node {} plus arbitrary Groovy — the most flexible, but it easily produces code that is hard to maintain and debug. Teams should default to Declarative, put complex logic in shared libraries, and use script {} when necessary.
In-depth answer
pipeline {
agent { label 'linux && docker' }
options { timeout(time: 30, unit: 'MINUTES'); buildDiscarder(logRotator(numToKeepStr: '30')) }
stages {
stage('test') { steps { sh 'pytest -q --junitxml=report.xml' } }
stage('image') { when { branch 'main' } steps { sh 'docker build -t myapp:${GIT_COMMIT:0:7} .' } }
}
post { always { junit 'report.xml' } }
}
Common follow-up
- When does Declarative validation happen? After compilation and before execution (#17); the linter can be run before committing.
Bonus points
Mention that Declarative's “restart from stage” works only for Declarative, and that pipeline blocks are subject to the 64 KB method limit (#15).
Common wrong answer
“Declarative cannot contain Groovy” — you can use script {} and external methods.
See Lesson 2 Module 2.
Q5. What connection methods does an agent have? What are the network requirements and suitable scenarios for each?Intermediate
30-second answer
SSH: the controller actively connects via SSH to the agent host and launches agent.jar, the agent must open port 22 and have Java; Inbound TCP: the agent actively connects to the controller's HTTP port to get information, then connects to TCP 50000; Inbound WebSocket: only one HTTP(S) port is used, suitable for traversing reverse proxies or Ingress; Cloud: the Kubernetes/EC2/Azure plugins create agents on demand, internally using one of the methods above.
In-depth answer
- Firewall direction: SSH is controller → agent; inbound is agent → controller (more convenient when the agent sits behind NAT or in the cloud).
- Inbound agents authenticate with a node secret; the Kubernetes plugin injects it automatically.
- Common failures: #28 port unreachable, #29 channel disconnect, #30 host key.
docker run -d --name agent2 jenkins/inbound-agent:latest-jdk21 -url https://jenkins.example.com -webSocket -name agent2 -secret @/run/secrets/agent2 -workDir /home/jenkins/agent
Common follow-up
- How do you connect a Windows agent? Run the inbound agent as a service, or use SSH (Windows OpenSSH).
Bonus points
Point out that both the agent and controller Java versions must be within the supported range (21/25 from 2.555.1 on), and that agent → controller access control is now tightened by default (Q41).
Common wrong answer
“JNLP must use Java Web Start” — that has long been deprecated; the current approach is agent.jar command line or container images.
See Lesson 1 Module 1.
Q6. Why should the executor count of the built-in node be set to 0 in production?Intermediate
30-second answer
Two aspects, security and stability: builds running on the built-in node share the same user and filesystem as the controller process, and can read secrets/,credentials.xml , and all configuration, which amounts to handing the controller to anyone who can edit the Jenkinsfile; builds also compete with the controller for CPU, memory and disk, slowing scheduling and the UI.
In-depth answer
- Jenkins shows an administrative monitor warning about this (#42).
- Complementary measures: agent → controller access control, builds in isolated ephemeral agents, and Declarative using
agent nonewith stage-level agents.
jenkins: numExecutors: 0 mode: EXCLUSIVE
Common follow-up
- Doesn't the Pipeline's orchestration also run on the controller? Yes, but it executes only sandbox-restricted Groovy, and it does not execute shell.
Bonus points
Mention that “the sandbox is not a complete security boundary”: Script Security vulnerabilities have been published, so you also need permission control over who can modify the Jenkinsfile.
Common wrong answer
“For performance” — only half the answer.
See Lesson 6 Module 6.
Q7. What is in JENKINS_HOME? What should a backup include, and what can be excluded?Intermediate
30-second answer
JENKINS_HOME It is Jenkins' only persistent state: config.xml together with each plugin's global configuration XML,jobs/ (job configuration and build records),nodes/,users/,plugins/,secrets/ (encryption keys),credentials.xml,fingerprints/. Back up everything; you may exclude workspace/,caches/,war/ and logs,must include secrets/, and rehearse restores regularly.
In-depth answer
- Consistency: an online backup may capture half-written files; use volume snapshots, or back up during a low-traffic period with quiet-down mode.
- Once configuration is code (JCasC + Job DSL + plugin manifests), the controller can be “rebuilt” rather than “restored”, and the backup focus shifts to build history and secrets.
Common follow-up
- What happens if secrets/ is lost? All credentials become undecryptable (#49).
Bonus points
Give RTO/RPO figures and a drill frequency, and note that the backup itself contains secrets and must be stored encrypted.
Common wrong answer
“Backing up the jobs directory is enough.”
See Lesson 5 Module 6.
Q8. What is the difference between LTS and weekly? How do you plan Jenkins upgrades?Intermediate
30-second answer
Weekly releases come out every week with the latest features; an LTS baseline is selected from an earlier weekly roughly every 12 weeks, followed by .2, .3 and similar fix releases (for example 2.580.1 → 2.580.2). Production uses LTS with pinned versions; the upgrade flow is: read the upgrade guide → rehearse on a replica (core + all plugins) → execute in the maintenance window → smoke test → keep a backup that can be rolled back.
In-depth answer
- Java: from 2.555.1 LTS, only 21 and 25 are supported (#1); Java 21 is supported until 2027-09, and Java 25 until 2029-09.
- Pin the image tags (
2.580.2-jdk21), and do not uselatest/lts(#10). - When a security advisory is released, fixes go only into the latest LTS and weekly — if you fall too far behind, you must upgrade across multiple versions.
Common follow-up
- How do the plugins get upgraded along with it? Q9.
Bonus points
Mention using a Helm chart or image build to treat “core + plugins + JCasC” as one versioned unit, and running a set of smoke pipelines on a staging controller.
Common wrong answer
“Just click upgrade in the UI.”
Q9. How do you manage dozens or hundreds of plugins? How do you avoid failures caused by plugin upgrades?Intermediate
30-second answer
Treat the plugin set as code: plugins.txt list only top-level plugins with pinned versions, and use jenkins-plugin-cli to resolve the full dependency closure and bake it into the image (or install via the Helm chart); upgrade as a group and test on a replica; follow the least-plugins principle and regularly clean up unused and deprecated plugins.
In-depth answer
- Unmet dependencies cascade into failures (#3–#5); manually uploading .hpi files bypasses the core version check (#4).
- Check security warnings:
jenkins-plugin-cli --view-security-warnings; watch for plugin status “suspended from distribution / deprecated” (for example azure-cli, kubernetes-cd).
FROM jenkins/jenkins:2.580.2-jdk21 COPY plugins.txt /usr/share/jenkins/ref/plugins.txt RUN jenkins-plugin-cli --plugin-file /usr/share/jenkins/ref/plugins.txt --verbose
Common follow-up
- Can I install plugins from the UI? Technically yes, but it is not reproducible; production instances should restrict it.
Bonus points
State the selection criteria for plugins: maintenance activity, install base, security advisory history, and whether there is an alternative (for example, using sh to call the CLI instead of a niche plugin).
Common wrong answer
“Tick everything for automatic updates.”
Q10. What credential types and scopes does Jenkins have? How do you use them safely in a Pipeline?Beginner
30-second answer
Common types: Username with password, Secret text, Secret file, SSH Username with private key, Certificate, plus cloud plugin types. Scopes: System (used only by Jenkins itself),Global (available to Pipelines); credentials can also be stored in a folder level to achieve team isolation. Pipelines use withCredentials or environment { X = credentials('id') } bindings to expose them as environment variables; in sh single quotes are used so the shell expands them, and the log masks them automatically.
In-depth answer
- Lookup rule: ID + context (folder) + type (#32, #33).
- Credentials on disk are encrypted with the key from
secrets/(#49); you can switch to external providers (Vault, Key Vault, AWS Secrets Manager). - Masking is limited: secrets that are encoded or split will not be masked; anyone who can edit the Jenkinsfile can obtain the secrets (#18).
Common follow-up
- How do you avoid long-lived cloud keys? Q31.
Bonus points
Mention credential usage tracking (fingerprints) and the permission over who may use a credential (Credentials/UseItem), and that PR builds should not get production credentials.
Common wrong answer
“Put the password in the environment block of the Jenkinsfile.”
Q11. What are the build trigger methods? Why is Webhook recommended? What is H in cron?Beginner
30-second answer
Trigger methods: SCM Webhook, SCM polling (pollSCM), scheduled (cron), upstream job, manual/API, parameterized trigger. Webhooks are event-driven and real-time, and add no polling load to the Git server or the controller; polling at scale produces a large number of requests (#45). In cron, the H hashes a fixed value from the job name, spreading jobs that share the same expression apart so they do not bunch up at the same moment (#47).
In-depth answer
triggers {
cron('H H(0-5) * * 1-5') // a fixed moment between hours 0 and 5 on weekdays
pollSCM('H/30 * * * *') // only as a Webhook fallback; keep the frequency low
}
Common follow-up
- A Webhook was received, but nothing triggered? Check the endpoint, the repository URL matching, and the secret (#24).
Bonus points
Mention that in Multibranch, a Webhook triggers a “scan / event handling”, and the branch source plugin decides which branch gets built.
Common wrong answer
“H is a random value that differs each time” — it is stable for the same job.
See Lesson 2 Module 7.
Q12. What are archiveArtifacts, stash/unstash, and external artifact repositories each used for?Intermediate
30-second answer
stash/unstash Used for within a single build to pass small files between different agents/stages; they are discarded when the build ends; archiveArtifacts to save files into the build record (stored by default on the controller in JENKINS_HOME), for downloading and traceability; formal release artifacts (images, packages) should be pushed to an external artifact repository (ACR/ECR, Nexus, Artifactory, S3/Blob), with Jenkins recording only references.
In-depth answer
- Large files via stash/archive all pass through the controller, consuming its bandwidth, memory and disk (#44, #46); the Artifact Manager plugin can switch storage to S3/Blob.
- The fingerprint records each file's MD5, used to trace “which build produced it and which builds used it”.
stage('build') { agent { label 'linux' } steps { sh 'python -m build'; stash name: 'dist', includes: 'dist/*.whl' } }
stage('test') { agent { label 'linux' } steps { unstash 'dist'; sh 'pip install dist/*.whl && pytest' } }
Common follow-up
- What about dependency caches? Do not use stash for caching; see Q35.
Bonus points
“Build once, deploy many”: images are promoted to each environment by digest, rather than rebuilt for each environment (Q24).
Common wrong answer
“Storing Docker image tar files with archiveArtifacts.”
See Lesson 2 Module 5.
Q13. How do labels and label expressions work? How do you design agent labels?Beginner
30-second answer
Each node has a set of labels (plus its own name as an implicit label); jobs select nodes through label expressions, which support &&,||,!, parentheses, for example linux && docker && !gpu. The scheduler looks among matching nodes for one that is online and has a free executor; when nothing matches, cloud plugins can create nodes by label. Labels should be named by “capability”, not by hostname.
In-depth answer
- Node usage modes: “use as much as possible” vs. “only run jobs whose labels match” (EXCLUSIVE).
- In the Kubernetes plugin,
POD_LABELgenerates a unique label for each podTemplate, to avoid reusing the wrong Pod. - Common failures: label misspelling or case mismatch (#26), and deadlocks caused by multiple pools sharing a label (#27).
Common follow-up
- How do I see which nodes a label matches? Open the
/label/<expression>/page.
Bonus points
Write the label list into JCasC or documentation as part of the “platform API”, and keep changes compatible.
Common wrong answer
“A label is just the node name.”
See Lesson 1 Module 1.
Scenario 5-1: one “do-everything” Jenkins server
A team has one Jenkins VM: 8 executors on the built-in node, all builds run there, 180 plugins are installed, there are no backups, and everyone has administrator rights. What do you do in your first month after taking over?
Key points of a reference answer
- Stop the bleeding: a complete backup
JENKINS_HOME(including secrets/) and a restore drill; record the core and plugin versions. - Security: revoke administrator rights, introduce matrix/role authorization and SSO (Q39, Q43); set the built-in node to 0 executors and introduce at least two agents (Q6).
- Repeatable: export JCasC, generate
plugins.txt, remove unused and deprecated plugins (Q9); migrate jobs to Multibranch + Jenkinsfile. - Operations: build retention policy, disk and heap monitoring, upgrade to the current LTS (Q8).
Scenario 5-2: all builds queued overnight
Every day starting at 2:00, hundreds of builds queue until 6:00; during the day all is normal. How do you locate and fix it?
Key points of a reference answer
- Look at the queue
why: is it insufficient executors (#27) or agents offline (#31). - Check the cron: a large number of
0 2 * * *(#47) → change toHand spread the windows. - Elasticity: use cloud agents for overnight jobs; limit concurrency of similar jobs (Throttle / Lockable Resources); reduce the frequency of jobs that do not really need to run every day.
Instructional video (title and channel verified via YouTube oEmbed)
Answer quality in third-party interview videos varies; follow this lesson and jenkins.io, and record your mock interview and replay it for self-assessment.
Module 6 · Part B: Pipeline Design (Interview 14–25)
- Use the mechanics of CPS and persistence to explain “strange” Pipeline behavior, and state the design principles.
- Be able to design a reusable, testable, versioned pipeline system (shared libraries + templates + linter + unit tests).
- Answer deployment control questions: approvals, concurrency, environment promotion, and “build once, deploy many”.
Browse the questions and their focus first, mark the ones you are unsure about; click a row to jump to the details.
Q14. Explain the Pipeline's CPS execution model. Why does NotSerializableException occur? What is @NonCPS?Advanced
30-second answer
The Pipeline's Groovy is transformed by CPS (Continuation Passing Style) and then executed step by step by an interpreter on the controller; at each step boundary, the entire program state is serialized to program.dat, so the controller can resume from the checkpoint after a restart. The trade-off: local variables must be serializable (otherwise #13), and some Groovy/Java features (certain closures, constructors, comparators) behave differently (#19). @NonCPS A method marked with it runs as ordinary Groovy in one go, cannot call steps inside it, and its return value must be serializable.
In-depth answer
- Steps (
sh) run as durable tasks on the agent via workflow-durable-task-step; the controller only waits for their results, so a brief agent disconnect can be survived. - The sandbox (Script Security) is another layer on top of the CPS interpreter: every call is checked against the whitelist (#14).
- The Durability setting (MAX_SURVIVABILITY / SURVIVABLE_NONATOMIC / PERFORMANCE_OPTIMIZED) determines how often state is written to disk and how recoverable it is (Q21).
@NonCPS
def parse(String json) { new groovy.json.JsonSlurperClassic().parseText(json) } // returns a serializable HashMap
Common follow-up
- Why are complex loops in a Jenkinsfile slow? Each step goes through CPS interpretation and runs on the controller, so move it to
shscript.
Bonus points
Be able to name program.dat,workflow/ the flow node XML in the directory, and the best practice that “a Pipeline is an orchestration language, not a general-purpose programming language”.
Common wrong answer
“The Jenkinsfile runs on the agent.”
Q15. How do you design and govern a Shared Library? What is the difference between trusted and untrusted libraries?Intermediate
30-second answer
A shared library is a Git repository,vars/ containing global steps (vars/buildPython.groovy → buildPython()),src/ containing Groovy classes,resources/ containing template files. It is configured at the global level (trusted, not run in the sandbox) or the folder level (untrusted, run in the sandbox). Pipelines pin a version @Library('platform@v2.3.0') _, and libraries are published with semantic version tags, with unit tests and a changelog.
In-depth answer
// vars/standardPipeline.groovy —— teams only write standardPipeline(lang: 'python')
def call(Map cfg = [:]) {
pipeline {
agent { label 'linux && docker' }
options { timeout(time: 30, unit: 'MINUTES') }
stages {
stage('test') { steps { sh(libraryResource("ci/${cfg.lang}-test.sh")) } }
stage('image') { when { branch 'main' } steps { buildImage(name: cfg.name ?: env.JOB_BASE_NAME) } }
}
}
}
- A trusted library can call Jenkins internal APIs (with broad permissions), so its repository must be strictly protected (branch protection, review); it is part of the supply chain.
- The “default version + allow version override” settings determine whether teams can use unreleased branches.
Common follow-up
- How do you test a library? JenkinsPipelineUnit unit tests + integration tests on a test Jenkins (Q18).
Bonus points
Mention that Method too large (#15) can be handled by moving logic out of the Jenkinsfile into a library; and libraryResource keeping shell scripts as plain files that can be tested separately.
Common wrong answer
“A shared library is just a copy-and-paste Jenkinsfile template.”
See Lesson 5 Module 3.
Q16. How are parallel and matrix used? What should you watch for with failFast, resources and logs?Intermediate
30-second answer
parallel Run multiple branches at the same time (each branch can run on a different agent); Declarative's matrix generates combinations along axes (such as Python version × OS) and runs them in parallel, supporting excludes. failFast true aborting the other branches when any branch fails. Watch the total executor count (#27), concurrency on shared resources (locks), and per-branch log viewing (Pipeline Graph View / Stage View).
In-depth answer
stage('test') {
matrix {
axes { axis { name 'PY'; values '3.11', '3.12', '3.13' } }
agent { docker { image "python:${PY}-slim" } }
stages { stage('pytest') { steps { sh 'pip install -r requirements.txt && pytest -q' } } }
}
}
- Number of branches × resources per branch = peak demand; in cloud agent scenarios, watch the quotas (#35).
Common follow-up
- Can nesting node inside parallel deadlock? Yes, if the outer level already holds an executor and the inner level waits on the same pool (#27).
Bonus points
Use lock(resource: 'staging-db') (Lockable Resources) to protect shared environments, and let non-critical branches catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE').
Common wrong answer
“The more parallel branches, the faster.”
Q17. What problems do when, input, timeout, retry and post each solve? What are the pitfalls?Intermediate
30-second answer
when Control whether a stage executes (branch, environment variable, expression, changeset),beforeAgent true avoiding requesting an agent for skipped stages; input wait for manual approval; timeout prevent hanging forever; retry retry unstable steps; post (always/success/failure/unstable/cleanup) for notifications and cleanup.
In-depth answer
- Pitfall 1:
inputPlacing it in a stage that occupies an agent keeps the executor occupied for a long time (#27) — use a stage-levelinputdirective on a stage that has no agent. - Pitfall 2:
pipelineleveltimeoutincludes queue time (#26). - Pitfall 3:
retryre-executes steps with side effects (deploy, publish); for agent disconnects, useretry(conditions: [agent()])more precisely.
stage('deploy-prod') {
when { beforeAgent true; branch 'main' }
input { message 'Deploy to prod?'; submitter 'release-managers' }
agent { label 'linux' }
options { timeout(time: 15, unit: 'MINUTES'); lock('prod-deploy') }
steps { sh './deploy.sh prod' }
}
Common follow-up
- How do you restrict who can approve?
submitterUse group names, combined with an authorization strategy.
Bonus points
Use milestone so that a newer build, once approved, automatically cancels older waiting builds (Q24).
Common wrong answer
“Putting input inside node is fine.”
See Lesson 2 Module 3.
Q18. How do you test a Jenkinsfile and a shared library, instead of “finding out after committing”?Intermediate
30-second answer
Layered approach: ① syntax — the Declarative linter (HTTP /pipeline-model-converter/validate or CLI declarative-linter) as a PR check; ② logic — unit tests for the shared library with JenkinsPipelineUnit (mocking steps); ③ integration — run sample projects on a test Jenkins (same plugin versions as production); ④ debugging —Replay re-run a particular build after modifying it, and Restart from Stage.
In-depth answer
curl -s -u "$JUSER:$JTOKEN" -X POST -F "jenkinsfile=<Jenkinsfile" "$JENKINS_URL/pipeline-model-converter/validate"
- Write script logic as standalone shell/Python files, which can run directly locally and in unit tests.
- JCasC + the plugin manifest let a “test Jenkins” be rebuilt with one command.
Common follow-up
- What are the risks of Replay? It requires the corresponding permission; the changes do not go into Git and are used only for debugging.
Bonus points
Note that the maintenance status of headless run options such as Jenkinsfile Runner must be evaluated yourself, and they should not be the only method.
Common wrong answer
“You can only run it on Jenkins and see what happens.”
See Lesson 5 Module 3.
Q19. What are the ways to build container images in Jenkins? What are the security trade-offs of each?Intermediate
30-second answer
① an agent mounts the host's Docker socket (simple but equivalent to root, #34); ② Docker-in-Docker (privileged container); ③ rootless BuildKit / Buildah building in unprivileged containers; ④ cloud build services (az acr build, AWS CodeBuild); ⑤ a dedicated build VM. On Kubernetes, avoid mounting the node socket; prefer ③ or ④.
In-depth answer
- The original Kaniko repository (GoogleContainerTools/kaniko) was archived in 2025; new projects should evaluate maintained forks or switch to BuildKit/Buildah.
- Whichever method you use: tag images immutably (Git SHA), and record the digest after pushing; SBOM and signing (Q45); credentials via
registry-credsor cloud identity.
// Option ④: hand the build to ACR; the agent does not need Docker
sh 'az acr build -r acrjenkins12345 -t myapp:${GIT_COMMIT:0:7} .'
Common follow-up
- What about build caching? BuildKit's registry cache (
--cache-to/--cache-from).
Bonus points
Point out that agent { docker } merely “running steps inside a container” is a different thing from “building images”.
Common wrong answer
“chmod 666 docker.sock is enough.”
Q20. What are the risks of PR builds from forks? How does Jenkins protect against them?Advanced
30-second answer
External contributors can modify the Jenkinsfile or build scripts, execute arbitrary code in CI, steal secrets, and tamper with artifacts. Multibranch's branch source plugins have a “trust” policy for fork PRs: by default only contributors with write access are trusted; untrusted PRs use the target branch's Jenkinsfile; but build scripts (Makefile, tests) still come from the PR, so PR builds must not be able to obtain production credentials, and must run on isolated ephemeral agents.
In-depth answer
- Credential isolation: PR builds use only read-only, low-privilege credentials; deployment credentials sit in a folder accessible only to the main-branch job.
- Agent isolation: one-off Pods/VMs, no network access to production, no shared cache (to prevent cache poisoning).
- When an external PR needs to run the full pipeline: trigger it via a maintainer comment or label, and run it only after a human has reviewed the code.
Common follow-up
- Does GitHub Actions' pull_request_target carry similar risks? Yes, it is the same class of problem.
Bonus points
Explain clearly that “whoever can modify the Jenkinsfile effectively has access to all credentials that pipeline can reach”.
Common wrong answer
“Logs mask secrets, so it is safe.”
See Lesson 2 Module 7,Lesson 6 Module 7 Supply Chain Security.
Q21. How do you optimize Pipeline performance and reduce pressure on the controller?Advanced
30-second answer
Let the controller only orchestrate: put logic in sh scripts, reduce the number of steps (run multiple commands in one sh instead of dozens of sh), avoid reading and writing large files on the controller side, and control log volume; set durabilityHint('PERFORMANCE_OPTIMIZED') for Pipelines that do not need crash recovery; externalize build retention and artifacts; use Webhooks instead of polling.
In-depth answer
- Every step generates a flow node and is persisted, so the more steps, the more IO.
- Large numbers of
echoand very long logs all go through controller storage; write test output to files and then parse it withjunit. - On the agent side: dependency caching (Q35), incremental builds, parallelism.
options { durabilityHint('PERFORMANCE_OPTIMIZED'); buildDiscarder(logRotator(numToKeepStr: '20')) }
Common follow-up
- What is the cost of PERFORMANCE_OPTIMIZED? If the controller exits abnormally, running Pipelines may not be recoverable.
Bonus points
Let the data speak: compare build duration, queue wait time and controller CPU/GC from Prometheus metrics before and after optimization (Q34).
Common wrong answer
“Add more executors to the controller” — it actually gets slower.
See Lesson 7 Module 5.
Q22. How are secrets masked in a Pipeline? What are the limits of masking?Intermediate
30-second answer
withCredentials Secrets are provided to steps as environment variables, and a filter is installed on the build log that replaces any string matching a secret exactly with ****. Limits: encoded values (base64, URL encoding), split values or character-by-character output cannot be matched; writing to files or artifacts is not masked; Groovy interpolation puts the secret on the command line (#18); and anyone who can modify the Pipeline can send the secret outside.
In-depth answer
- Principle: give secrets only to the steps that need them, with the narrowest possible scope; use short-lived tokens (cloud identity, OIDC) instead of long-lived keys (Q31).
- Log shipping (ELK/Splunk) must also account for secret leakage.
Common follow-up
- What if a secret leaks? Scenario question Q49.
Bonus points
Point out that set -x prints the expanded command, and Jenkins masking can catch the full value but not its variants.
Common wrong answer
“Once it is masked, it is absolutely safe.”
See Lesson 6 Module 3.
Q23. How do you implement a “build once, deploy to many environments” promotion flow? How do you design a parameterized build?Intermediate
30-second answer
CI builds the image only once (tagged with the Git SHA, with the digest recorded); afterward, dev → staging → prod deployments all use the same digest; environment differences come from configuration (Helm values, Key Vault), not from rebuilding. The deployment pipeline runs with parameters (image digest, target environment), or the main pipeline advances stage by stage with an approval before prod.
In-depth answer
parameters {
string(name: 'IMAGE_DIGEST', description: 'sha256:… from the CI build')
choice(name: 'TARGET', choices: ['dev', 'staging', 'prod'])
}
steps { sh 'helm upgrade --install myapp ./chart -n myapp -f values/${TARGET}.yaml --set image.digest=${IMAGE_DIGEST} --wait' }
- Parameters in Declarative take effect only after the first run (the parameter definition is stored in the job configuration); parameter values become environment variables, so watch for shell injection (in the
shshell step, quote them). - GitOps option: Jenkins only updates the version number in Git, and Argo CD/Flux does the deployment.
Common follow-up
- How do you roll back? Redeploy the last known-good digest.
Bonus points
Use fingerprints or deployment records to associate “which build was deployed to which environment”, to satisfy audit requirements (Q44).
Common wrong answer
“Each environment builds from source separately.”
Q24. What happens when multiple builds deploy to the same environment at the same time? How do you guarantee deployment order?Advanced
30-second answer
Use lock (Lockable Resources) to serialize deployments to the same environment; use milestone to guarantee ordering — once a newer build passes a milestone, older builds that have not yet passed are aborted automatically, so an old version cannot overwrite a new one; the same job can use disableConcurrentBuilds(abortPrevious: true).
In-depth answer
stage('deploy-staging') {
steps {
milestone(ordinal: 10)
lock(resource: 'env-staging') { sh './deploy.sh staging' }
milestone(ordinal: 20)
}
}
- The lock must wrap the whole critical section of “check + deploy + verify”; lock granularity should be per environment, not one global lock.
- When running concurrently across Jenkins instances or with other tools, the lock must live outside Jenkins (for example, the deployment tool's own lock, or GitOps).
Common follow-up
- Does Helm have its own lock? The pending state acts as a pessimistic lock, but it cannot replace serialization in CI (Helm course #2).
Bonus points
Point out that cancelling an in-progress deployment is more dangerous than queuing — deployment steps should not be abortPrevious interrupted.
Common wrong answer
“Stagger them with sleep.”
See Lesson 2 Module 4.
Q25. How are test results presented in Jenkins? What is the difference between UNSTABLE and FAILURE? How do you handle flaky tests?Beginner
30-second answer
The test tool outputs JUnit XML,junit after a step parses it, the build page shows trends and failing cases; when there are failing tests, the build is marked UNSTABLE (yellow) — meaning the build process succeeded but quality is below standard; FAILURE (red) means the step itself failed (compile error, script exited non-zero). Flaky tests must be isolated and fixed, not masked by unlimited retries.
In-depth answer
steps { sh 'pytest -q --junitxml=reports/junit.xml || true' } // let junit decide the result
post { always { junit allowEmptyResults: false, testResults: 'reports/*.xml' } }
- Coverage and static analysis: Coverage and Warnings Next Generation plugins, with quality gates.
- Flaky tests: tag them, isolate them into a separate job, track their failure rates; when necessary, allow a limited number of
retryretries.
Common follow-up
- Why
|| true? Avoidshletting the stage fail first; you can also usereturnStatus.
Bonus points
Write check results back to the Git platform (Checks API), so developers see failing cases directly in the PR.
Common wrong answer
“UNSTABLE is a failure.”
See Lesson 1 Module 7 Building myapp: Testing, Packaging & Archiving.
Scenario 6-1: 60 repositories, each with its own Jenkinsfile
The company has 60 Python/Java services, each repository's Jenkinsfile was copied and modified, and the security team requires image scanning and signing across all of them. How do you standardize within one quarter?
Key points of a reference answer
- Inventory: use a script to collect all Jenkinsfiles and cluster them into 3–4 patterns by language or deployment method.
- Shared library
standardPipeline: a parameterized pattern, with scanning and signing as steps inside the library,@Library('platform@v1')pinned versions (Q15). - Migration: migrate 3 pilot repositories first, and provide a migration PR bot; compare results while the old Jenkinsfiles are kept.
- Governance: library releases come with a changelog and a compatibility policy; Organization Folder unifies scanning; PR checks run the linter (Q18).
Scenario 6-2: the monorepo's pipeline keeps getting slower
A monorepo with 15 services builds and tests everything on every commit, taking 70 minutes. How would you design it?
Key points of a reference answer
- Build by changed paths:
when { changeset 'services/payment/**' }, or a script computes the affected services (dependency graph). parallel/matrixRun services in parallel; dependency cache and BuildKit cache (Q35); test sharding.- The main branch runs a periodic full build as a fallback; watch executors and quotas (Q16, #27).
- Metrics: trend of each stage's duration; optimize the slowest 20%.
Instructional video (title and channel verified via YouTube oEmbed)
No verified video specifically covering CPS internals or milestone/lock deployment control was found; follow the jenkins.io documentation.
Module 7 · Part B: Scaling, Kubernetes & Cloud (Interview 26–38)
- Be able to give a reference architecture for running Jenkins on Kubernetes, and explain why the controller is a single-replica StatefulSet.
- Answer scaling questions: when to shard, how to scale agents elastically, and how to monitor and cache.
- Be able to compare keyless authentication options on Azure and AWS, and explain the limits of Jenkins' own OIDC capabilities.
Browse the questions and their focus first; mark the ones you are unsure about; click a row to jump to the detailed answer.
Q26. How do you run Jenkins on Kubernetes? What does the official Helm chart do?Intermediate
30-second answer
Use the official jenkins/jenkins Helm chart (latest as of 2026-11: 5.13.3, appVersion 2.580.2): the controller runs as a single-replica StatefulSet runs,JENKINS_HOME on an RWO PVC; an init container installs controller.installPlugins; a sidecar watches ConfigMaps with a specific label and hot-reloads JCasC; it also creates the controller and agent Services (HTTP and 50000), RBAC, and a pre-configured Kubernetes cloud, so builds run in dynamic Pod agents.
In-depth answer
helm repo add jenkins https://charts.jenkins.io && helm repo update helm upgrade --install jenkins jenkins/jenkins -n jenkins --create-namespace --version 5.13.3 -f values.yaml
- Key values points: pin
controller.image.tag, resource requests/limits,JAVA_OPTS, persistent storageClass, Ingress + TLS,controller.JCasC.configScripts, and default resources for agents. - Plugin reproducibility: either pin
installPluginsversions, or build an image with the plugins baked in and turn off installation at startup (#11).
Common follow-up
- Why can't you run 2 replicas? #50 / Q29.
Bonus points
Mention the trade-off between PVC backups of the controller (volume snapshots or Velero) and PodDisruptionBudget (with a single replica, a PDB blocks node drains).
Common wrong answer
“Deployment + multiple replicas + RWX is high availability.”
See Lesson 5 Module 4 Running Jenkins on Kubernetes with Helm.
Q27. How does the Kubernetes plugin's Pod template work? What is the relationship between the jnlp container and the container() step?Intermediate
30-second answer
When a job matching a Pod template's label appears in the queue, the plugin calls the API to create a Pod: in it, jnlp container runs the inbound agent that connects to the controller, and other containers (maven, python, kubectl…) share the same workspace volume. Steps run in the jnlp container by default; container('maven') { sh … } uses exec to put a step into a specified container. The Pod is deleted when the build ends.
In-depth answer
pipeline {
agent { kubernetes { yaml '''
spec:
serviceAccountName: build
containers:
- name: python
image: python:3.12-slim
command: ["sleep"]
args: ["infinity"]
resources: {requests: {cpu: "500m", memory: "512Mi"}, limits: {memory: "1Gi"}}
''' } }
stages { stage('test') { steps { container('python') { sh 'pytest -q' } } } }
}
- Templates can inherit (
inheritFrom) and merge YAML;POD_LABELguarantees uniqueness;podRetentioncontrols whether the Pod is kept after a failure. - Common failures: #35 RBAC/quota, #36 OOM, ImagePullBackOff (the plugin takes the agent offline and cancels the build).
Common follow-up
- Why use sleep infinity in tool containers? To keep the container running so that exec can run steps in it.
Bonus points
Point out that each Pod's startup time (image pull, scheduling) is a cost, and the trade-off can be handled with image pre-pulling, node pool warm-up, or keeping a few idle Pods (idleMinutes).
Common wrong answer
“Every stage creates a new Pod” — it depends on where the agent is declared.
See Lesson 5 Module 5.
Q28. How much can one Jenkins controller handle? When do you need to split into multiple controllers?Advanced
30-second answer
There is no fixed number; the bottleneck is usually the controller: the number of concurrently running Pipelines (CPS runs on the controller), the number of jobs and build history, plugin load, and the controller's disk JENKINS_HOME IO. Agents can scale horizontally; the controller can only scale vertically. When there is sustained GC pressure, scheduling latency, or conflicting change, upgrade and plugin needs between teams, split by team or business domain sharding into multiple controllers, managed with the same JCasC/plugin baseline.
In-depth answer
- Metrics: controller CPU, heap usage and GC time, HTTP latency, queue wait, and the number of concurrently running Pipelines (Q34).
- Load reduction: 0 executors on the built-in node, Webhooks instead of polling, build retention, externalized artifacts (#44–#46).
- Cost of sharding: cross-controller visibility and duplicated credentials; reduce the cost with shared platform code (JCasC, Job DSL, shared libraries).
Common follow-up
- How does it compare with a SaaS like GitHub Actions? SaaS hands the controller's operations to the vendor (Q37).
Bonus points
Give a real sharding example: split by “business line”; the platform team maintains one template Helm release, and each controller is just a different set of values.
Common wrong answer
“Adding agents scales infinitely.”
See Lesson 7 Module 6 Reliability: High Availability, Disaster Recovery & Large-Scale Jenkins.
Q29. How does open-source Jenkins achieve high availability and disaster recovery?Advanced
30-second answer
Open-source Jenkins does not support active/active HA (multiple controllers cannot share JENKINS_HOME, #50). The practical approach is fast recovery: configuration as code (JCasC + plugin manifests + Job DSL) lets the controller be rebuilt within minutes; JENKINS_HOME take regular snapshots/backups and store them off-site; Kubernetes restarts the Pod automatically; agents are stateless. RTO depends on rebuild + restore time; RPO depends on backup frequency.
In-depth answer
- Active/passive: prepare the same Helm release (0 replicas) and data replication in a standby region; switch DNS on failure.
- Pipeline recoverability: on a planned controller restart, running Pipelines can be recovered (when the durability setting is appropriate).
- Commercial options (such as CloudBees CI) offer HA capabilities — you can mention them in an interview, but state that they are commercial products.
Common follow-up
- How often should restore drills be run? At least every quarter, and measure the actual RTO.
Bonus points
Point out that “backups must include secrets/” (#49) and that “the backup itself is highly sensitive data”.
Common wrong answer
“Two Pods + RWX storage.”
Q30. What do JCasC, Job DSL and shared libraries each manage? How do you make the whole of Jenkins “as code”?Intermediate
30-second answer
JCasC Manage global configuration (security, credential references, clouds, tools, global libraries); Job DSL (run by a seed job) or an Organization Folder manage jobs and folders; shared libraries + Jenkinsfile manage pipeline logic; plugin manifests + image/Helm values manage software versions. All four live in Git, changes go through PRs, and the controller can be rebuilt at any time.
In-depth answer
jenkins:
numExecutors: 0
securityRealm: {local: {allowsSignup: false}}
jobs:
- script: |
folder('team-a')
organizationFolder('team-a/repos') { … } # Job DSL snippet (requires the Job DSL plugin)
unclassified:
location: {url: "https://jenkins.example.com/"}
- Secrets do not go in YAML: use
${ENV_VAR}or substitute from a Kubernetes Secret / Vault variable. - Validation:
/configuration-as-code/check(#48), run it in CI against a temporary Jenkins.
Common follow-up
- What about changes made in the UI? Restrict administrator UI changes, or export and compare regularly, with Git as the source of truth.
Bonus points
Mention the JCasC sidecar hot-reload in the Helm chart, and configuration drift detection.
Common wrong answer
“JCasC can manage the contents of the Jenkinsfile.”
Q31. When deploying Jenkins to Azure / AWS, how do you avoid long-lived keys? Can Jenkins act as an OIDC issuer?Advanced
30-second answer
Give the compute resources that run the builds an identity: Azure VM agents use a managed identity (az login --identity), AKS Pod agents use workload identity (SA federated credential, #37); AWS EC2 agents use an instance profile, and EKS Pod agents use Pod Identity or IRSA (#38). Jenkins core itself does not issue OIDC tokens; the OpenID Connect Provider plugin (oidc-provider) can let Jenkins act as an issuer that signs id tokens for builds, after which a federated trust is configured in the cloud — this requires the cloud to be able to reach Jenkins' discovery document and JWKS, and the subject/audience claims must be designed carefully.
In-depth answer
| Where it runs | Azure | AWS |
|---|---|---|
| VM | Managed identity | Instance profile (IMDSv2, hop limit 2 inside containers) |
| Kubernetes Pod | Workload identity (federated credential subject = SA) | EKS Pod Identity / IRSA |
| Anywhere | Federated credential + Jenkins oidc-provider (self-evaluated) | IAM OIDC provider + Jenkins oidc-provider (self-evaluated) |
- Note: unlike GitHub Actions, you must control “which job or branch gets which identity” yourself, through agent isolation (different SAs/node pools) or token claims.
Common follow-up
- How do you isolate identities when several teams share agents? Use different Pod templates, SAs and namespaces, and restrict which clouds are available by folder (the Kubernetes plugin supports allowing a cloud per folder).
Bonus points
Point out least privilege (AcrPush rather than Contributor) and that “PR builds must never obtain a deployment identity”.
Common wrong answer
“Storing the AWS access key as a Jenkins credential is enough” — this can only be a transitional step.
Q32. How do you elastically scale VM-based agents? What should you watch for when using Spot/preemptible instances?Intermediate
30-second answer
On AWS, use the EC2 Fleet plugin (based on ASG/Spot Fleet, scaling by queue length) or the Amazon EC2 plugin; on Azure, use the Azure VM Agents plugin (creating VMs from templates). Map different instance sizes by label; set minimum/maximum capacity and idle retention time. Spot instances are cheap but can be reclaimed: builds should be retryable and short, and critical release pipelines should use on-demand capacity.
In-depth answer
- Images: use AMIs/images with tools pre-installed via Packer, to shorten startup time.
- Reclamation: when an agent is interrupted, the build fails (#29); use
retry(conditions: [agent()])to retry the wholenodeblock on a new node. - Cost: a trade-off between idle retention time and startup latency; scale to 0 overnight.
Common follow-up
- How do I choose between this and Kubernetes Pod agents? Use VMs when you need full VMs (Docker daemon, Windows, GPU, kernel modules); otherwise prefer Pods.
Bonus points
Mention that agents also need their Java and remoting versions upgraded with Jenkins (keep inbound agent image versions in step).
Common wrong answer
“Keeping 50 always-on agents is simplest.”
Q33. How do you do security isolation for agents on Kubernetes?Advanced
30-second answer
Put agents in a separate namespace (or even a separate node pool), and give the controller's SA Pod permissions only in that namespace. Agent Pods by default do not mount SA tokens, run as non-root, and are forbidden from privileged mode and hostPath (no docker.sock mounts). NetworkPolicy allows only the required destinations, such as the controller, Git and the image registry; ResourceQuota/LimitRange prevent resource exhaustion; different trust levels (PR vs release) use different Pod templates, SAs and node pools.
In-depth answer
- Enable the
restrictedlevel on the agent namespace via Pod Security Admission; use rootless approaches for image builds (Q19). - Cloud identities are bound per SA (Q31); the SA used by PRs has no cloud permissions.
- The Kubernetes plugin can restrict which folders may use which cloud.
Common follow-up
- What can an agent access on the controller? Agent → controller access is controlled (Q41), but the agent can still reach the controller's HTTP and agent ports.
Bonus points
Point out that “Pods on the same node can be attacked laterally via the node”; high-risk builds use a dedicated node pool plus taints.
Common wrong answer
“Containers are isolation in themselves; no extra measures are needed.”
Q34. How do you monitor Jenkins itself and its pipelines?Intermediate
30-second answer
controller: the Prometheus metrics plugin exposes /prometheus (JVM heap/GC, threads, HTTP, queue length, executor usage, build duration and results), paired with Grafana and alerting; the OpenTelemetry plugin sends each build, stage and step as traces to an observability platform, so you can see which stage is the bottleneck. Logs: controller logs and build logs are shipped externally (mind secrets). Black-box: availability probes against /login the Jenkins endpoint.
In-depth answer
- Key alerts: queue wait time, number of offline agents, disk usage (#46), heap usage and GC (#44), sudden spikes in build failure rate, and certificates or tokens about to expire.
- DORA metrics: deployment frequency and change lead time can be computed from build and deployment events.
Common follow-up
- How does Prometheus scrape it? The Helm chart can create a ServiceMonitor; configure endpoint permissions as needed.
Bonus points
Be able to describe the example where a trace reveals that “90% of the time is spent downloading dependencies”, which leads to introducing caching (Q35).
Common wrong answer
“Looking at the weather icon on the build page is enough.”
See Lesson 5 Module 7 Monitoring Jenkins,Prometheus & Grafana course.
Q35. How do you do dependency and build caching on ephemeral agents (Pods / one-off VMs)?Intermediate
30-second answer
Ephemeral agents have no local cache, so dependencies are downloaded again every time. Options: ① dependency proxies/mirrors (Nexus/Artifactory, pip/npm/Maven mirrors) for nearby downloads; ② the registry cache of Docker/BuildKit; ③ mount a shared cache volume in Kubernetes (PVC; beware concurrent writes and poisoning risk); ④ remote caches built into tools (Gradle Build Cache, Bazel). Do not use stash/archiveArtifacts as a cache.
In-depth answer
- Cache key: hash of the lock file (
requirements.txt,package-lock.json). - Security: PR builds get read-only cache access, and only the main branch can write, to prevent cache poisoning (Q20).
docker buildx build --cache-from type=registry,ref=acrjenkins12345.azurecr.io/myapp:cache \
--cache-to type=registry,ref=acrjenkins12345.azurecr.io/myapp:cache,mode=max -t …/myapp:${GIT_COMMIT} --push .
Common follow-up
- What if the cache becomes invalid? Version the cache keys, and clean up periodically.
Bonus points
Quantify the benefit of caching with OpenTelemetry data (Q34).
Common wrong answer
“Switching to always-on agents gives you a cache” — it sacrifices isolation and elasticity.
See Lesson 2 Module 5.
Q36. What is the recommended way to deploy to AKS / EKS from Jenkins?Intermediate
30-second answer
Two mainstream patterns: Push-based— in the deployment stage, Jenkins uses cloud identity to obtain a kubeconfig (az aks get-credentials + kubelogin, or aws eks update-kubeconfig), runs helm upgrade --install --wait, and the deployment identity is granted permissions only in the target namespace; GitOps— pull-based (GitOps): Jenkins only builds the image and updates the version number in Git, and Argo CD/Flux pulls and deploys inside the cluster. The latter keeps credentials out of the cluster, is auditable, and is easy to roll back.
In-depth answer
- Push-based essentials: deployment lock (Q24), approvals (Q17),
--wait+ timeout, post-deployment smoke tests, and rollback to the previous digest on failure. - AKS: Entra-integrated clusters need kubelogin in non-interactive mode (workloadidentity/azurecli); EKS: access entries authorize the CI role.
Common follow-up
- What about Container Apps / ECS? Use
az containerapp update/aws ecs update-service, the principle is the same (Lessons 3 and 4).
Bonus points
Point out that “Jenkins holding cluster-admin” is a common anti-pattern.
Common wrong answer
“Storing the kubeconfig file as a Jenkins credential and using it long-term.”
See Lesson 3 Module 5 Deploying to AKS,Lesson 4 Module 5 Deploying to EKS.
Q37. How do you assess and carry out a migration from Jenkins to GitHub Actions or Azure Pipelines?Advanced
30-second answer
Assess first, then migrate: inventory jobs, plugins, shared libraries, credentials and agent dependencies; group them by complexity, and migrate simple, independent repositories first. GitHub Actions Importer supports auditing, forecasting and conversion (dry-run/migrate) from Jenkins, and can report the conversion rate and the parts that need manual work; Azure Pipelines has no official equivalent automatic conversion tool, so it must be rewritten as YAML by hand. During migration, run both systems in parallel and compare results, and switch credentials to the platform's native approach (OIDC).
In-depth answer
- Difficulties: custom plugin features, complex Groovy in shared libraries, special environments on self-hosted agents, and differences in approval and environment models.
- Benefits and costs: removes controller operations versus runner fees, and adds platform lock-in.
- Not everything has to move: keeping Jenkins for special workloads (hardware, internal networks) is also a reasonable approach.
Common follow-up
- What about shared libraries? Rewrite them as reusable workflows / composite actions or templates.
Bonus points
Give metrics: compare build duration, failure rate and maintenance hours before and after migration.
Common wrong answer
“The tool can convert 100% automatically.”
See Lesson 7 Module 7 Migration,GitHub course,Azure DevOps course.
Q38. How do you upgrade Jenkins safely on Kubernetes (Helm chart, core, plugins)?Intermediate
30-second answer
Treat the upgrade as a release: in Git, change the chart version,controller.image.tag, plugin versions and JCasC; first rehearse on a staging controller (a replica restored from a production backup, with triggers disabled) helm upgrade and run the smoke pipelines; in production, during the maintenance window, use quiet-down to wait for running builds to finish → PVC snapshot → helm upgrade → upgrade → verify → if there are problems, roll back the image and the PVC snapshot.
In-depth answer
curl -X POST -u "$JUSER:$JTOKEN" "$JENKINS_URL/quietDown" # stop starting new builds helm diff upgrade jenkins jenkins/jenkins -n jenkins --version 5.13.3 -f values.yaml # helm-diff plugin helm upgrade jenkins jenkins/jenkins -n jenkins --version 5.13.3 -f values.yaml --wait --timeout 15m
- Notes: major chart version changes in values (read the CHANGELOG), Java version changes (#1), plugin installation failures that crash the init container (#11), and JCasC attribute renames (#48).
- Rollback:
helm rollbackrolling back only the Kubernetes objects,JENKINS_HOMEthat new plugins have rewritten may not be readable by the old version — this is why a PVC snapshot is needed.
Common follow-up
- How often should you upgrade? Once per LTS baseline, plus emergency upgrades triggered by security advisories.
Bonus points
State the post-upgrade verification checklist: login (SSO), agent connections, the Kubernetes cloud creating Pods, credentials available, shared libraries loaded, and one complete deployment pipeline.
Common wrong answer
“If helm upgrade fails, just run helm rollback.”
Scenario 7-1: set up Jenkins on AKS for 30 teams
Requirements: SSO, team isolation, no long-lived cloud keys, and disaster recovery within 1 hour. Give the architecture and key configuration.
Key points of a reference answer
- 3–4 controllers split by business domain (same Helm template, different values), each a single-replica StatefulSet with PVC snapshots (Q26, Q28, Q29).
- Entra ID login (azure-ad or oic-auth plugin); groups → folder permissions (Q39, Q43).
- Agent namespaces + workload identity: PR builds use an SA with no permissions, and release builds use an SA with AcrPush/deployment permissions (Q31, Q33).
- Everything as code (Q30); DR: rebuild in another region + restore the latest snapshot, drilled quarterly.
Scenario 7-2: release-day builds are 5× normal volume
On a monthly release day, the queue backlog is 2 hours. The budget is limited — what do you do?
Key points of a reference answer
- Elasticity: Kubernetes node pool autoscaling / raise the maximum capacity of the EC2 Fleet, and use Spot for non-critical jobs (Q32).
- Reduce load: caching (Q35), build only what changed, and lower the frequency of non-essential jobs; confirm the controller resources are not the bottleneck (Q28).
- Priority: release pipelines use a dedicated label pool, and other jobs are throttled (Throttle).
- Measure queue wait time and size capacity based on the data (Q34).
Scenario 7-3: management requires “migrate to GitHub Actions”
There are 400 Jenkins jobs, special features that depend on 20 plugins, and one large shared library. How would you respond and plan?
Key points of a reference answer
- First use the GitHub Actions Importer audit to get the conversion rate and blockers; estimate runner costs and maintenance savings (Q37).
- In batches: migrate simple repositories first; rewrite the shared library as reusable workflows; special hardware or internal-network jobs may stay on Jenkins.
- Compare results during the parallel-run period; migrate credentials to OIDC; define completion criteria and a rollback plan.
Instructional video (title and channel verified via YouTube oEmbed)
No verified video was found that specifically covers Jenkins integration with Azure workload identity / AWS Pod Identity, or migrating Jenkins with GitHub Actions Importer; refer to Lessons 3, 4 and 7 and the official documentation.
Module 8 · Part B: Security Governance & Scenario Design (Interview 39–50)
- Answer Jenkins security questions layer by layer: identity → authorization → code execution (sandbox, build location) → secrets → plugins & supply chain → auditing.
- Answer open-ended scenario questions with a structured approach: clarify requirements → constraints → plan → risks → metrics.
- Show prioritization in incident questions: stop the bleeding, preserve evidence, recover, and review.
Browse the questions and their focus first; mark the ones you are unsure about; click a row to jump to the detailed answer.
Q39. Walk through the Jenkins security model: authentication, authorization and folder permissions.Intermediate
30-second answer
Security Realm Handles “who you are”: Jenkins' own user database, LDAP, OIDC/Entra ID, SAML, GitHub OAuth. Authorization Strategy Handles “what you can do”: Matrix Authorization (global + project-level matrix) or Role-based Strategy (global, project and agent roles, matching projects by regex). Folders can set project-level permissions that children inherit (inheritance can be blocked), achieving team isolation. Automation uses API tokens; CSRF protection covers session requests.
In-depth answer
- Key permissions: Overall/Administer (equivalent to arbitrary code execution on the controller), Overall/Read, Job/Build, Job/Configure (being able to change a pipeline = being able to use its credentials), Credentials/UseItem, Run/Replay.
- Evaluation order and common 403s: #39 (crumb) vs #40 (permissions).
- Groups come from the Security Realm (for example Entra groups); group names or IDs written in the matrix must match the
whoAmIauthorities in the identity provider's token.
Common follow-up
- Who should have Administer? A very small number of platform administrators plus one break-glass account; everyday operations use lower privileges.
Bonus points
Mention that the “Authorize Project” plugin runs builds as the triggering user, which limits which jobs and credentials they can access.
Common wrong answer
“Logged-in users can do anything is enough.”
Q40. How do Script Security and the Groovy sandbox work? How do you govern script approvals?Advanced
30-second answer
Groovy from non-administrators (Jenkinsfiles, untrusted shared libraries, script fields in some plugins) runs in the sandbox; every method, field and constructor call is checked against a whitelist. Signatures not on the whitelist are rejected (#14) and enter In-process Script Approval, where an administrator approves or rejects them. Governance principles: do not approve dangerous signatures by default; meet needs through controlled steps in trusted shared libraries; manage approval records as code and review them.
In-depth answer
- Examples of dangerous signatures:
Jenkins getInstance,rawBuild,java.io.File,Runtime exec, reflection — once approved, they apply to all sandboxed scripts. - The sandbox is not a perfect boundary: script-security and workflow-cps have had multiple sandbox-escape vulnerabilities in the past, so you must also restrict who can modify Jenkinsfiles and upgrade promptly.
- Groovy run in the Script Console by an administrator is not subject to the sandbox (equivalent to arbitrary code execution on the controller).
Common follow-up
- Why are trusted shared libraries dangerous? They do not run in the sandbox, so write access to the library repository is equivalent to Jenkins administrator access.
Bonus points
Give an example of “rewriting an approval request as a controlled step”, for example using currentBuild.getBuildCauses() instead rawBuild.getCauses().
Common wrong answer
“Approve all pending items so the build passes.”
See Lesson 6 Module 4.
Q41. What is controller isolation? What can an agent do to the controller?Advanced
30-second answer
Controller isolation means: builds do not run on the controller (0 executors on the built-in node, Q6), and agents are treated as untrusted — agents run user-controlled code, and if an agent is compromised, it should not be able to control the controller. Jenkins enables agent → controller access control by default, limiting what an agent can invoke or read on the controller via remoting.
In-depth answer
- Agents must also be isolated from one another: builds of different trust levels do not share agents (Q20, Q33), and ephemeral agents are destroyed after use.
- If old plugins rely on agent → controller callbacks, they may need updating rather than the protection being turned off.
- The controller's filesystem holds all secrets, so isolate the controller from agents on the network, and do not expose port 50000 of the controller to the public internet (#28).
Common follow-up
- Can an agent read other jobs' credentials? It can only read the credentials for builds sent to it, plus leftover workspaces on the same agent — this is why ephemeral agents are used.
Bonus points
Cite the official documentation's “Controller Isolation” point: distributed builds are a security requirement, not merely a performance optimization.
Common wrong answer
“The agent is on the internal network, so it is trusted.”
See Lesson 6 Module 6.
Q42. How do you govern plugin security? What do you do when a security advisory arrives?Intermediate
30-second answer
Prevention: the fewest plugins possible, actively maintained plugins, plugin manifests as code, regular upgrade windows; monitoring: subscribe to Jenkins security advisories, watch the security warnings on the management page (#43),jenkins-plugin-cli --view-security-warnings in CI; response: assess by severity and affected functionality → if a fix exists, verify it in staging and upgrade as soon as possible → if no fix exists, apply the mitigations in the advisory (disable features, restrict permissions) or uninstall and replace → record it.
In-depth answer
- There have been several advisories so far in 2026 (for example 06-10, 06-24, 08-05, 09-02, 09-16, 10-28), which shows the need for a routine process.
- Deprecated or suspended-from-distribution plugins (such as azure-cli, kubernetes-cd) need a replacement plan: usually switch to calling the official CLI from within
sha pipeline step.
Common follow-up
- How do you get security fixes for core? Fixes only go into the latest LTS and weekly, so you cannot stay on an old LTS for long.
Bonus points
Record an “owner and purpose” for each plugin, and remove plugins that have no owner.
Common wrong answer
“Hide the warnings.”
See Lesson 6 Module 5.
Q43. How do you connect Jenkins to Entra ID (Azure AD) SSO and do group authorization?Intermediate
30-second answer
Two plugin options: the Microsoft Entra ID plugin (azure-ad) or the generic OpenID Connect plugin (oic-auth); the SAML plugin also works. Steps: register an application in Entra and configure the callback URI (based on the correct Jenkins URL, #41) → emit group claims from the application → configure the Security Realm in Jenkins → authorize by group in the matrix/roles → keep a break-glass local administrator. Manage everything with JCasC, and inject the client secret from a secrets store.
In-depth answer
- Group claims: Entra emits group object IDs by default; a user in a large number of groups can trigger group overage, requiring a Graph query or emitting only the groups assigned to the application.
- Automation accounts do not use SSO: use API tokens (service accounts) or generate tokens under an SSO user.
- When switching the Security Realm, you need a migration plan for old users' API tokens and permission mappings.
Common follow-up
- How do you log in if SSO goes down? Use the break-glass account or the recovery procedure from #40.
Bonus points
Mention that conditional access (MFA, device compliance) is enforced by Entra, so Jenkins does not need to implement it.
Common wrong answer
“Create a local Jenkins user for every employee.”
See Lesson 6 Module 2.
Q44. How does Jenkins meet audit and compliance requirements?Intermediate
30-second answer
Record “who changed what and when, and who deployed what”: the Audit Trail plugin records HTTP operations (logins, configuration changes, build triggers) and ships them to a SIEM; Job Configuration History keeps the history of configuration changes; configuration as code means all changes go through Git PR review; deployment approvals (input submitter) are linked with build records to image digests and tickets; logs and build records are retained according to compliance requirements and protected against tampering (external storage).
In-depth answer
- Separation of duties: developers cannot directly modify production deployment pipelines and credentials; the approver and the submitter must be different people.
- Evidence chain: commit SHA → build number → image digest → SBOM/signature → deployment record (Q45, Q23).
Common follow-up
- How do you audit manual changes made in the UI? Audit Trail + configuration history; better still, forbid manual changes.
Bonus points
Ship audit logs externally and correlate them with the Git platform's audit logs and cloud audit logs (Activity Log / CloudTrail).
Common wrong answer
“Build logs are the audit log.”
See Lesson 6 Module 7 Auditing, Compliance & Supply Chain Security.
Q45. How do you implement software supply chain security with Jenkins?Advanced
30-second answer
Protect both the “build system itself” and the “build outputs”: build system — pin Jenkins, plugin and agent image versions and digests, use the fewest plugins, use ephemeral isolated agents, a protected shared library repository, and least-privilege credentials; outputs — dependency locking and vulnerability scanning, SBOM generation, image signing (such as cosign) and build provenance attestations, with deployment accepting only images that are signed and come from trusted pipelines.
In-depth answer
stage('supply-chain') {
steps {
sh 'syft "$IMAGE@$DIGEST" -o spdx-json > sbom.spdx.json'
sh 'grype "$IMAGE@$DIGEST" --fail-on high'
sh 'cosign sign --yes "$IMAGE@$DIGEST"' // key-based or keyless signing, according to the organization's scheme
}
post { always { archiveArtifacts 'sbom.spdx.json' } }
}
- Assess the maturity of the build platform against frameworks such as SLSA: isolation, tamper-evident provenance, and two-person review.
- Follow official sources for tool versions; this course does not hard-code version numbers.
Common follow-up
- What if Jenkins itself is compromised? That is why signing must happen under a controlled identity, with verification on the deployment side.
Bonus points
Point out that fork PRs, cache poisoning and trusted shared libraries are all supply chain attack surfaces (Q20, Q35, Q15).
Common wrong answer
“Scanning images for vulnerabilities is supply chain security.”
See Lesson 6 Module 7.
Q46. How do you integrate Jenkins credentials with external secrets management (Vault, Key Vault, AWS Secrets Manager)?Intermediate
30-second answer
Two approaches: ① credentials providers— plugins such as Azure Key Vault, AWS Secrets Manager Credentials Provider and Kubernetes Credentials Provider present external secrets as Jenkins credentials, and pipelines use them as usual; withCredentials; ② fetch at runtime— the HashiCorp Vault plugin's withVault, or in sh a step, use cloud identity to call a CLI to read secrets. The benefit is that secrets do not land in JENKINS_HOME, and rotation is centralized.
In-depth answer
- Jenkins itself needs an identity to access the external store: prefer managed identity or workload identity, rather than yet another long-lived token.
- Isolate secret paths and permissions by folder or team; auditing is done on the secrets store side.
- In JCasC,
${VAR}can be resolved from the environment, files, or a secrets source.
Common follow-up
- What should a build do when the external store is unavailable? Fail and raise an alert; do not fall back to plaintext.
Bonus points
Compare “syncing into Jenkins credentials” (cached, Jenkins has read access) with “fetching on demand within a step” (finer-grained permissions, but dependent on availability).
Common wrong answer
“Put the secrets in an environment file mounted into the controller.”
See Lesson 6 Module 3.
Q47. Scenario design: design a Jenkins-based CI/CD platform for 50 teams.Advanced
30-second answer
Design it as a “platform as a product”: on Kubernetes, 2–4 controllers split by business domain (same Helm template, Q26, Q28); everything as code (JCasC, plugin manifests, Job DSL/Organization Folder, Q30); SSO + folder-level RBAC (Q39, Q43); teams write only a few lines of Jenkinsfile that call a versioned shared library (Q15); Pod agents get SAs and node pools by trust level (Q33); no long-lived cloud keys (Q31); monitoring, backups and an upgrade cadence (Q34, Q29, Q38).
In-depth answer
- Clarify: language stacks, deployment targets, compliance requirements, peak concurrency, and whether SaaS is allowed.
- Onboarding process: new teams request folders, credential paths and resource quotas via PR; the platform creates them automatically.
- SLOs: availability, queue wait P95, build duration; review every quarter.
- Risks: single point of failure in the controller (fast rebuild), plugin vulnerabilities (governance process), and the blast radius of shared library changes (versioning + staged rollout).
Common follow-up
- A team requires a special plugin to be installed? Evaluation process + prefer
shcalling the CLI as an alternative.
Bonus points
Give metrics and costs: monthly build minutes, node costs, platform team staffing.
Common wrong answer
“One huge Jenkins where everyone is an administrator.”
Synthesizes Lessons 5, 6 and 7.
Q48. Scenario: on Monday morning Jenkins will not open and all releases are blocked. How do you handle it?Advanced
30-second answer
Stop the bleeding first, then find the root cause: confirm the scope of impact and communicate it → look at the first scene (Pod/container status, the last error in the controller log, disk, memory) → quickly judge the most likely cause: full disk (#46), OOM (#44), plugin load failure or an accidental upgrade over the weekend (#3, #10), JCasC error (#48), PVC mount problem (#50) → the fastest recovery path (expand capacity / roll back the image / restore the snapshot) → after recovery, check running pipelines and data integrity → review.
In-depth answer
kubectl -n jenkins get pod,pvc,events --sort-by=.lastTimestamp | tail -20 kubectl -n jenkins logs jenkins-0 -c jenkins --previous | tail -50 kubectl -n jenkins exec jenkins-0 -c jenkins -- df -h /var/jenkins_home
- Preserve evidence: before recovering, save logs, events, and thread or heap dumps (if available).
- Temporary workaround: for emergency releases, use a prepared “emergency deployment process” (for example GitOps or a manual runbook).
Common follow-up
- How do you prevent it from happening again? Pinned images, disk and heap alerts, an upgrade process, and recovery drills.
Bonus points
Proactively mention the communication cadence (updates every 30 minutes) and a blameless postmortem.
Common wrong answer
“Try restarting first” without preserving any evidence.
See Lesson 7 Module 1 Troubleshooting Methodology,Module 8 Mixed Fault Blind Box.
Q49. Scenario: someone finds a plaintext production database password in build logs. What do you do?Intermediate
30-second answer
Handle it as a security incident: ① immediately rotate that password (assume it has leaked); ② restrict access and delete or clean up the affected build logs (and any copies shipped to the log platform); ③ find the leak path: Groovy interpolation (#18),set -x printed a variant, a script wrote the secret to a file or artifact, or the secret was never bound through the credentials binding at all; ④ check who can access these logs and whether there were any unusual logins; ⑤ fix the pipeline and add guardrails (review rules, scanning logs for secret patterns); ⑥ review.
In-depth answer
- Masking only matches full strings (Q22); encoded secrets must be prevented through process and design.
- Long-term plan: the database uses short-lived credentials (managed identity, IAM database authentication, Vault dynamic secrets), so pipelines never touch long-lived passwords.
Common follow-up
- Is deleting the logs alone enough? No — the secret must be rotated.
Bonus points
Check historical builds of the same pipeline and other branches; a leak usually happened more than once.
Common wrong answer
“Deleting that build is enough.”
See Lesson 6 Module 3.
Q50. How do you choose between Jenkins, GitHub Actions and Azure Pipelines? When would you still choose Jenkins?Advanced
30-second answer
When code is on GitHub and workloads are mainly in the cloud, GitHub Actions has the lowest operating cost and the best PR/OIDC integration; organizations centered on Azure DevOps (Boards, Repos, environment approvals) choose Azure Pipelines; Jenkins' strengths are full self-hosting and control (internal networks, offline use, special hardware, compliance requirements), its plugin ecosystem, and high customizability, at the cost of running the controller, plugins and security yourself. The choice depends on where the code is hosted, compliance and network constraints, team skills and total cost of ownership.
In-depth answer
| Dimension | Jenkins | GitHub Actions | Azure Pipelines |
|---|---|---|---|
| Hosted | Self-hosted | SaaS + self-hosted runner | SaaS + self-hosted agent |
| Configuration | Jenkinsfile (Groovy) | YAML | YAML |
| Cloud identity | identity of the runtime location / oidc-provider plugin | native OIDC | workload identity federation (service connections) |
| Operations | controller, plugins, upgrades, backups | runner (when self-hosted) | agent (when self-hosted) |
Common follow-up
- What if we already have a lot of Jenkins? See Q37: assess → batch → run in parallel → keep the Jenkins scenarios that make sense.
Bonus points
Don't take sides; argue with constraints and data, and offer a hybrid (for example GitHub Actions for CI, Jenkins for internal-network deployments).
Common wrong answer
“Jenkins is outdated” or “Jenkins can do everything, so it's the best.”
Scenario 8-1: audit finds 40 approved dangerous script signatures
A security audit found that In-process Script Approval has approved Jenkins getInstance,File,Runtime exec and 40 signatures in total, and the pipelines of several teams depend on them. How do you remediate without breaking every build?
Key points of a reference answer
- Inventory: which pipelines use them (search Jenkinsfiles and libraries, or revoke on a test instance and run regression tests).
- Replacement: substitute with standard steps or controlled steps in trusted shared libraries (Q40); agree on a deadline with the teams.
- Revoke signatures in batches and monitor failures; include approval records in JCasC and set up a review process.
- At the same time, check who can modify Jenkinsfiles and who has write access to the trusted library repository.
Scenario 8-2: an agent is compromised
Monitoring shows that a static Linux agent is making unusual outbound connections to the internet in the early morning. How do you respond? How do you improve the architecture afterwards?
Key points of a reference answer
- Isolate: take the node offline in Jenkins, network-isolate the host, and preserve disk and memory evidence.
- Impact assessment: which jobs ran on that agent and which credentials it was bound to → rotate all of them; check whether any tampered artifacts were published (compare digests and signatures).
- Controller risk: confirm that agent → controller access control is enabled (Q41), and review the controller's audit logs.
- Improvements: ephemeral agents, isolation by trust level, outbound network policies, and artifact signature verification (Q33, Q45).
Scenario 8-3: compliance requires “production deployments need two-person approval and must be traceable”
How do you implement this in Jenkins and present evidence to an auditor?
Key points of a reference answer
- Pipeline:
input submitter: 'release-approvers', and verify that the approver is not the same person as the trigger user; or approve in the change management system and let Jenkins check the ticket status. - Evidence chain: commit → build → image digest → signature → approver and time → deployment record (Q44, Q23).
- Prevent bypass: production credentials are available only to deployment jobs in a protected folder; changes to the Jenkinsfile require review; the Audit Trail is shipped externally.
Instructional video (title and channel verified via YouTube oEmbed)
No verified video specifically covering Jenkins supply chain security or Entra ID SSO configuration was found; refer to Lesson 6 and the official documentation.
Issue Cheat Sheet + Interview Flashcards
A · Cheat sheet for 50 production issues
Filter by keyword (for example label,credentials,plugin,crumb). Click a number to jump to the detailed entry in the corresponding module.
B · Flashcards for 50 interview questions
Look at the question first and recall your answer, then expand to compare with the one-line key point; for details, return to the “Interview Question Details” of the corresponding module.
General command card
Controller and logs
docker compose logs jenkins --since 30m # Compose kubectl -n jenkins logs jenkins-0 -c jenkins --previous curl -sI $JENKINS_URL/login | grep -i x-jenkins curl -u $U:$T $JENKINS_URL/threadDump # thread dump curl -u $U:$T $JENKINS_URL/scriptText --data-urlencode 'script=…' # Manage Jenkins → System Log / System Information / Support
Queue, nodes and builds
curl -u $U:$T "$JENKINS_URL/queue/api/json?tree=items[id,why]" curl -u $U:$T "$JENKINS_URL/computer/api/json?tree=computer[displayName,offline,offlineCauseReason]" curl -u $U:$T "$JENKINS_URL/job/F/job/J/lastBuild/consoleText" curl -u $U:$T -X POST "$JENKINS_URL/queue/cancelItem?id=N" # /label/<expression>/ view matching nodes and clouds
Pipeline debugging
curl -u $U:$T -X POST -F "jenkinsfile=<Jenkinsfile" $JENKINS_URL/pipeline-model-converter/validate # Build page → Replay / Restart from Stage / Pipeline Steps # /job/J/pipeline-syntax/ step generator and full step reference sh 'id; echo $PATH; command -v docker' # agent environment sh(script: '…', returnStatus: true)
Plugins, JCasC & upgrades
jenkins-plugin-cli --plugin-file plugins.txt --list --no-download jenkins-plugin-cli --plugin-file plugins.txt --view-security-warnings curl -u $U:$T -X POST --data-binary @jenkins.yaml $JENKINS_URL/configuration-as-code/check curl -u $U:$T -X POST $JENKINS_URL/quietDown image: jenkins/jenkins:2.580.2-jdk21 # pinned tag helm upgrade jenkins jenkins/jenkins --version 5.13.3 -f values.yaml
Comprehensive Drill + Mock Interview
I. Comprehensive fault drill
Each scenario combines several issues from Part A. Write down your first diagnostic command and your judgment before expanding the answer.
Scenario 1: After a weekend node rebuild, all pipelines using Docker agents fail on Monday
$ curl -sI https://jenkins.example.com/login | grep X-Jenkins X-Jenkins: 2.590 WorkflowScript: 2: Invalid agent type "docker" specified. Must be one of [any, kubernetes, label, none] SEVERE … Failed Loading plugin Docker Pipeline … - Update required: Docker Commons Plugin …
Answer: The image uses latest, and after the node was rebuilt it pulled weekly (#10); after the core upgrade, plugin dependencies were unsatisfied (#3), and the Docker Pipeline plugin did not load, so the agent type disappeared (#17). Immediate fix: change the image tag back to 2.580.2-jdk21 (when rolling back the core, check whether a new plugin version has already rewritten the configuration; restore the snapshot if necessary); afterwards, upgrade the plugins as a group following the upgrade process.
Scenario 2: A newly created Multibranch project does not build after a push; after a manual scan, builds sit in the queue without moving
Gitea Webhook: webhook can only call allowed HTTP servers (check your webhook.ALLOWED_HOST_LIST setting) … Scan Repository Log: Checking branch main … ‘Jenkinsfile’ found … Scheduled build Queue: There are no nodes with the label ‘Linux’
Answer: Three problems stacked: Gitea forbids callbacks to private addresses (#24); the label case is wrong Linux ≠ linux (#26). Fix ALLOWED_HOST_LIST and the Jenkinsfile label; add a timeout to the pipeline to prevent endless queuing.
Scenario 3: After upgrading workflow-cps, an old pipeline fails at the sleep step
[Pipeline] sleep Caused: java.io.NotSerializableException: groovy.json.internal.LazyMap … expected to call Helper.load but wound up catching readFile
Answer: The JsonSlurper result is kept across steps (#13), and a step was called inside a @NonCPS method (#19). Switch to readJSON or JsonSlurperClassic in the @NonCPS @NonCPS helper only parse; move the step calls back into CPS code.
Scenario 4: After migrating to AKS, image pushes fail and some builds queue indefinitely
ERROR: Unable to create pod kubernetes jenkins/… pods is forbidden: … cannot create resource "pods" … in the namespace "jenkins-agents" (other builds) ERROR: AADSTS70021: No matching federated identity record found … Assertion Subject: 'system:serviceaccount:jenkins-agents:default'
Answer: The agent namespace lacks the RBAC for the controller SA (#35); the Pod template does not specify an SA matching the federated credential (#37). In the Helm values agent.namespace + rbac.create; the Pod template must set serviceAccountName to match the Workload Identity label.
Scenario 5: Overnight builds fail widely, and agents are marked offline
Making agent1 offline temporarily due to the lack of disk space wrapper script does not seem to be touching the log file in /home/jenkins/agent/workspace/…@tmp/durable-… cron: 0 2 * * * (× 180 jobs)
Answer: At exactly 2:00, 180 jobs bunch up (#47); workspace and image caches fill the disk (#31), and running durable tasks lose their heartbeat because the disk is full (#21). Clean up the disk, change the cron to H,cleanWs(), and switch to ephemeral agents.
Scenario 6: After enabling Entra ID login, nobody can access Jenkins, and API scripts also start getting 403
AADSTS50011: The redirect URI 'http://jenkins.internal:8080/securityRealm/finishLogin' … does not match … (the administrator running the script with the old password) <title>Error 403 No valid crumb was included in the request</title>
Answer: The Jenkins URL is an internal http address (#12, #41); the script uses password session authentication without a crumb (#39) — and after switching the Security Realm, the local password no longer works. Use the procedure in #40 to restore access, correct the Jenkins URL and proxy headers, and switch the script to an API token.
Scenario 7: After changing the controller to 2 replicas for “high availability”, build records become a mess
SEVERE hudson.util.DoubleLaunchChecker#execute: Collision detected. timestamp=…, expected=… Two builds both show #128; some job configurations reverted to old values
Answer: Two controllers sharing JENKINS_HOME (#50). Immediately scale back to 1 replica and restore the damaged jobs from the most recent consistent snapshot; replace the high-availability approach with “fast rebuild + backups + sharding” (Q29).
Scenario 8: After restoring from backup to a new cluster, the controller fails to start; after fixing that, all Git pulls fail
io.jenkins.plugins.casc.ConfiguratorException: No configurator found for the following root element: kubernetes … (after the fix) WARNING hudson.util.Secret#decrypt: Failed to decrypt secret … BadPaddingException stderr: fatal: Authentication failed for 'http://gitea:3000/lab/myapp.git/'
Answer: The plugin manifest of the new environment lacks the Kubernetes plugin, so the JCasC root element is not recognized (#48); the backup did not include secrets/, so credentials cannot be decrypted (#49). Complete the plugin manifest and restore from the same backup point secrets/; afterwards, write the restore drill into the runbook.
II. Full mock interview (10 questions randomly drawn from 50)
A 2-minute countdown per question: answer orally first (you may write key points in the text box), then expand the reference answer and self-assess “got it / partial / didn't know”. At the end, the score for the round is shown, along with cumulative mastery rates by module. Self-assessment results are saved in this browser.
III. Open-ended self-test (6 questions)
- Draw the flow of a build from trigger to completion, and mark at which step #20, #26, #27, #28, #29, #31 and #35 occur.
- Explain how CPS and persistence together give both “recoverable after a controller restart” and “NotSerializableException”.
- Why can “whoever can modify the Jenkinsfile obtain the pipeline's credentials”? List at least 4 mitigations.
- For a 403 request, how do you tell within 1 minute whether it is a crumb problem, an authentication problem, or an authorization problem?
- Design a checklist for a Jenkins LTS upgrade (at least 8 items) covering Java, plugins, JCasC, backup and rollback.
- Give your organization's rationale for choosing among Jenkins, GitHub Actions and Azure Pipelines, and your migration strategy.
IV. Final quiz (12 questions)
Sources & Version Notes
Version facts
| Item | Facts used in this lesson | Sources (accessed 2026-11-16) |
|---|---|---|
| Jenkins LTS / weekly | LTS 2.580.2 (2026-10-28), weekly 2.590 (2026-11-09; GitHub release 11-10 UTC) | updates.jenkins.io/stable/latestCore.txt · LTS changelog · GitHub releases |
| Java | From 2.555.1 LTS, only Java 21 and 25 are supported; the last LTS for Java 17 is 2.541.3; Java 21 is planned to be supported until 2027-09, and Java 25 until 2029-09 | Java Support Policy |
| Docker images | jenkins/jenkins:2.580.2-jdk21,2.580.2-lts-jdk21,2.580.2-jdk25 and other tags exist; the image runs as UID 1000 | Docker Hub tags API · jenkinsci/docker |
| Helm chart | jenkins 5.13.3 (appVersion 2.580.2, 2026-11-15) | jenkinsci/helm-charts |
| Plugins (update center, 2026-11-16) | workflow-cps 4403.v471713a_cea_19 · pipeline-model-definition 2.2293.v6e7193cec599 · git 5.11.0 · github-branch-source 1986.v801e40614d00 · gitea 286.v0740a_413c1eb_ · docker-workflow 653.v2f2c08eff0ec · kubernetes 4560.vc25b_83890c34 · configuration-as-code 2147.v8a_8d38668c72 · job-dsl 3732.v9a_c49a_61a_313 · credentials-binding 728.v902a_273b_8947 · matrix-auth 3.3 · role-strategy 928.vc60b_edb_fea_e1 · oic-auth 4.737.vb_3d1a_0e7cf0b_ · saml 4.623.v7875d61cd9f5 · azure-ad 723.v212c114e2fb_f · azure-credentials 426.v5627e6a_4c7a_7 · aws-credentials 265.v8422a_f384cd9 · pipeline-aws 767.v48d5c10b_1899 · ec2-fleet 4.5.2.571.v0932f9cd1039 · prometheus 873.v054598e6e84d · opentelemetry 3.1605.v37c3e29857e5 · oidc-provider 234.vca_b_26b_f4b_dda_ · script-security 1436.v1082791135e4 | update-center.actual.json · plugins.jenkins.io |
| Plugin status | azure-cli,kubernetes-cd and others are on the update center's deprecated/suspended list; the Amazon ECR plugin is in “awaiting adoption” status (see Lesson 4); the original Kaniko repository GoogleContainerTools/kaniko has been archived. | update center deprecations · Plugin security · GitHub |
| OIDC | Jenkins core does not issue OIDC tokens; the OpenID Connect Provider plugin can let Jenkins act as an issuer (cloud-side trust must be configured yourself) | OpenID Connect Provider plugin |
| Security advisories | 2026 advisories: 06-10, 06-24, 08-05, 09-02, 09-16, 10-28, and others | Security advisories |
Sources of the error texts (strings checked against source)
| Error / message | Source location (default branch of each jenkinsci repository, 2026-11-16) |
|---|---|
| Running with Java %d from %s, which is older than the minimum required version (Java %d). Supported Java versions are: %s | jenkins: war/src/main/java/executable/Main.java |
| Can not write to … Wrong volume permissions? | docker: jenkins.sh |
| Failed to load: … · Update required: … to be updated to … or higher · Plugin is missing · Required plugin is disabled · Jenkins (…) or higher required | jenkins: core/…/hudson/Messages.properties (PluginWrapper.*) |
| There are no nodes with the label ‘…’ · All nodes of label ‘…’ are offline · ‘…’ is offline · ‘…’ doesn’t have label ‘…’ · Waiting for next available executor on ‘…’ | jenkins: core/…/hudson/model/Messages.properties (Queue.* / Node.*) |
| Still waiting to schedule task | workflow-durable-task-step: ExecutorStepExecution.java |
| script returned exit code | workflow-durable-task-step: DurableTaskStep.java |
| wrapper script does not seem to be touching the log file in · process apparently never started in | durable-task: BourneShellScript.java |
| No such DSL method '…' found among steps · A secret was passed to "…" using Groovy String interpolation, which is insecure. | workflow-cps: DSL.java |
| expected to call … but wound up catching … | workflow-cps: CpsVmExecutorService.java |
| Scripts not permitted to use … | script-security: RejectedAccessException.java |
| Invalid agent type "…" specified. Must be one of … · Missing required section · Unknown stage section · Expected a stage | pipeline-model-definition: Messages.properties |
| Could not find credentials entry with ID '…' · Credentials '…' is of type '…' where '…' was expected | credentials-binding: MultiBinding.java |
| Library … expected to contain at least one of src or vars directories | pipeline-groovy-lib: LibraryAdder.java |
| Couldn't find any revision to build. Verify the repository and branch configuration for this job. | git: GitSCM.java |
| … provided port:… is not reachable on host … | remoting: JnlpAgentEndpointResolver.java |
| Unable to create pod … · Created Pod: … · Container … was terminated. · Pod failed to start due to image pull failure | kubernetes: KubernetesLauncher.java, pod/retention/Reaper.java, Messages.properties |
| Disk space is below threshold of … · Making … offline temporarily due to the lack of disk space | jenkins: core/…/hudson/node_monitors/Messages.properties |
| No valid crumb was included in the request | jenkins: CrumbFilter.java |
| … is missing the … permission | jenkins: core/…/hudson/security/Messages.properties |
| It appears that your reverse proxy set up is broken. · Jenkins URL is empty but is required … · Building on the built-in node can be a security issue. · Warnings have been published for the following currently installed components: | jenkins: message.properties of each administrative monitor |
| Spread load evenly by using ‘…’ rather than ‘…’ | jenkins: hudson/scheduler/Messages.properties |
| Collision detected. timestamp=…, expected=… | jenkins: DoubleLaunchChecker.java |
| Invalid configuration elements for type: … Available attributes : … · No configurator found for the following root element(s) | configuration-as-code: BaseConfigurator.java, ConfigurationAsCode.java |
| depends on …, but there is an older version defined on the top level - … | plugin-installation-manager-tool: PluginManager.java |
Video verification notes
All videos were verified on 2026-11-16 through the YouTube oEmbed interface (https://www.youtube.com/oembed?url=…&format=json) verified the titles and channels; oEmbed does not return durations or publish dates, so they are not listed. Verified: Sakshi Gautam, “Master Jenkins Plugin Management: Installation, Upgrades & Build Failure Fixes” (nPSHSWfaz24), “Jenkins Pipeline Failures Troubleshooting Part 1” (-Ul7dmm_wvo), “DevOps: Jenkins Interview Questions Based on Real Scenarios” (yc-FXCceqVs); LearnTeachShare, “Jenkins Tutorial 10 - Upgrade Jenkins and Java + Update Plugins” (yjllMwQz5B4); CloudBeesTV, “The Correct Way to Handle Credentials in a Jenkins Pipeline” (yfjtMIDgmfs), “Getting Started With Shared Libraries in Jenkins” (Wj-weFEsTb0), “How to Use Kubernetes Pods As Jenkins Agents” (ZXaorni-icg), “Effectively Using Kubernetes Plugin with Jenkins” (0dbUQYDUXbw), “Common Pitfalls in Jenkins Security and How to Avoid Them” (YufZHjO0hd4), “Jenkins Performance: Avoiding Pitfalls, Diagnosing Issues & Scaling for Growth” (yTafQ-e84eY), “What Is the Difference Between Scripted and Declarative Pipeline” (GJBlskiaRrI), “Jenkins Multibranch Pipeline With Git Tutorial” (B_2FXWI6CWg); DevOpsCertification, “Mastering Jenkins as Code: A Comprehensive Tutorial with Full Demo | JCasC | Jenkins Configuration” (ReAqFY4dyic); MindMajix, “Jenkins Interview Questions 2026 | Jenkins Interview Questions and Answers | MindMajix” (SsN0ILXq5Lw); Rajeev Ranjan - Linux & DevOps, “Jenkins Architecture Explained: Controller vs Agent for 500 Builds” (Ll_iHKZf9QY); TechWorld with Nana, “Complete Jenkins Pipeline Tutorial | Jenkinsfile explained” (7KCS70sCoK0); LinuxTechi, “How to Configure Jenkins to Use Kubernetes Pods as Build Agents” (IwRa_qLywvg); DGR Uploads, “Mastering Jenkins: Scenario-Based Interview Questions & Answers | Jenkins Interview Prep” (xOS6xGRHRzM). Not found: a verified video specifically covering Jenkins startup-failure troubleshooting, CPS serialization and sandboxing, queue-blocking causes, CSRF and lockout recovery, or Azure workload identity / AWS Pod Identity integration with Jenkins. The related tabs provide storyboard scripts. Answers in third-party interview videos are for reference only.
Audio notes
The “Audio” tab uses the browser's built-in Web Speech API and uploads no data. It requires a Chinese (zh-CN) voice pack installed on the system; if none is available, you can simply read the script.
Known limitations
- Strings marked “source verified” were checked against the default-branch source of each jenkinsci repository as of 2026-11-16; if your plugin versions are older, the wording may differ slightly. The outer wrapping in logs (timestamps, logger names, exception chains) is illustrative.
- Parts marked “check against actual output” come from the JVM, OpenSSH/Git, the Docker CLI, Gitea, Microsoft Entra ID, the AWS CLI and the Kubernetes API server, and change between versions: for example the method-name suffix for Method too large, the full format of ChannelClosedException, Gitea's ALLOWED_HOST_LIST hint, and the full text of AADSTS messages.
- All “expected output” shown is sample; the lab steps are written from the current documentation and source, and have not actually been run in this environment. In Declarative, the list of available types after
Invalid agent typedepends on the installed plugins;jenkins-plugin-cli --no-downloadbehavior in dependency resolution mode and the return format of the JCasC/configuration-as-code/checkendpoint are inferred from the source and may change between versions. - The lab environment matches Lesson 1 (agent1 is an inbound agent with 2 executors, the built-in node has 0 executors, and the Gitea user
lab); for the exact contents of the Compose file, follow Lesson 1. - Handled conservatively (follow the official documentation): system properties related to Pipeline “script splitting”, remoting ping parameters, the callback paths of the Entra ID / OIDC plugins, the maintenance status of Kaniko alternatives, and tool versions such as cosign/syft/grype (not hard-coded).
- Self-assessment records from mock interviews are stored only in this browser's localStorage, and will be lost if site data is cleared.