Chapter 26Lesson 03~170 minutes

Jenkins Configuration as Code, YAML Bundles, Secrets, Reloading, Validation, and Git-Managed Controller State: Configuration, Design Choices, and Tradeoffs

Choose deliberately between one YAML file and supplementary fragments, local files and external secret providers, reload and restart, UI ownership and JCasC ownership, and colocated versus dedicated configuration repositories. Each choice changes reviewability, privilege, portability, failure isolation and rollback.

TradeoffsSupplementary YAMLSecret sourcesReload vs restartGit policyPortability

Learning objectives

  • Choose one YAML file versus supplementary fragments without relying on hidden precedence.
  • Choose secret sources according to exposure, lifecycle and portability.
  • Distinguish reloadable configuration from changes that deserve a clean restart.
  • Define ownership between JCasC-managed and intentionally UI-managed settings.
  • Design repository permissions, versioning and rollback around admin-equivalent configuration.

1. One YAML file versus supplementary files

A single file is easy to understand and gives one review unit. It becomes unwieldy when many platform domains have independent ownership. Supplementary files can separate security, clouds, tools and credentials-provider configuration—but they must not conflict.

Pattern Benefit Risk Evidence
Single jenkins.yaml Simple ordering/review Large blast radius and ownership bottleneck one commit/hash
Directory of supplementary YAML Domain ownership and smaller diffs conflicting keys; cross-file reasoning manifest of file hashes + conflict check
Remote URL source central delivery network dependency, mutable content if unpinned URL plus immutable revision/digest and retrieval log

Do not use filename prefixes as an override mechanism. JCasC deliberately rejects conflicting assignments rather than making traversal order a configuration language.

2. Environment secret versus file/external provider

Environment substitution is convenient, especially for non-secret provenance values. For sensitive material, use the narrowest available source. File/Docker/Kubernetes secret mounts keep values out of YAML and can be permissioned read-only. External providers add centralized rotation/audit but also add network and authentication dependencies.

Source Strength Main caution
Environment variable Simple, portable often visible to process/container inspection; lifecycle tied to process
Read-only secret file Good local/container boundary host/runtime file permissions still matter
External SecretSource/provider central rotation/audit and short-lived access provider outage/auth path becomes startup/reload dependency
Jenkins encrypted string not clear text at rest in YAML bound to controller secret key; not portable between instances

Use CASC_STRICT_SECRET_RESOLUTION=true when a missing value must fail closed.

3. Reload versus restart

Reload is attractive because it avoids full controller downtime, but it should not become an excuse to mix runtime generations. Prefer reload for well-understood, tested global settings supported by current configurators. Prefer restart when core/Java/plugins changed, when startup initialization is part of the acceptance criteria, or when documentation says a setting requires restart.

Production rollouts often use: validate candidate source → apply to a clone → clean restart → smoke tests → promote same plugin/config pair → controlled reload only for later settings known to be reload-safe.

4. UI-managed versus JCasC-owned settings

Ownership must be explicit. If a field is JCasC-owned, UI edits are temporary drift and should be blocked by process/review, then reconciled. If a field is intentionally UI-managed because the plugin has no stable JCasC model, document that exception and back it up separately.

Useful policy. “UI is for inspection and emergency break-glass; Git is the source of truth for all supported global settings.” Break-glass changes require an incident/change record and a follow-up Git reconciliation.

5. Dedicated config repository versus colocated config

Controller configuration is admin-equivalent. A change to authorization strategy, security realm, clouds or credentials provider can change who controls the platform. A dedicated repository therefore often deserves tighter branch protection and a smaller reviewer group than an application repository.

Colocation can be reasonable for a single-team disposable controller, but do not grant every application contributor the ability to alter controller security merely because Jenkins consumes their Jenkinsfile.

6. Treat config and plugin set as a release unit

Tag a controller release with at least: Jenkins core/Java, plugin manifest, JCasC commit, secret-source contract and migration notes. Plugin schema and YAML evolve together. A Git commit that worked against plugin version A may fail against plugin version B even when YAML syntax is unchanged.

7. Schema and compatibility migration

Before a plugin upgrade, compare the target controller’s JCasC reference and test the existing YAML on a clone. If a key was renamed or a data model changed, create a migration commit that is reviewed together with the plugin update. Avoid silent “best effort” mutations of production YAML during startup.

8. Export as discovery, not blind round-trip

Export can help discover the current model and bootstrap authored config. It may include defaults, generated state and encrypted strings tied to the current controller. A good workflow is: export from a clone → isolate the intended section → compare against reference docs → author minimal YAML → validate on clean controller → commit the reviewed source.

9. Worked design scenario

A platform team runs three controllers: development, staging and production. Security realm and authorization are common; cloud capacity differs; production secrets come from an external provider.

Decision Chosen pattern Prerequisites Observable evidence
Shared security policy reviewed common fragment copied/versioned per release, not runtime override same compatible plugin schema Git hashes + clean validation
Environment-specific clouds separate supplementary fragment per controller non-overlapping keys source manifest and cloud inspection
Secrets provider/file references only provider auth and strict resolution secret source audit, no value in Git/export
Rollout staging restart before production snapshot and smoke tests startup log + test record

10. Decision table

Choice Prefer when Tradeoff
Single YAML small controller/team simpler but larger review surface
Supplementary directory multiple platform domains needs conflict discipline
File secret local/container lab or managed mount host/runtime lifecycle responsibility
External provider centralized production secret lifecycle network/provider dependency
Reload tested reload-safe setting only runtime remains continuously live
Restart plugin/core/schema transition maintenance window but cleaner boundary
Next lesson

Diagnostics, Failure Modes, Security, and Performance

Preserve the first JCasC error, separate source conflicts from plugin/schema and secret failures, and recover without destroying the controller state you are trying to diagnose.

Knowledge check

Answer before revealing the explanation.

1. When are supplementary YAML files useful?

2. Why is an environment variable a weaker place for a long-lived secret than a dedicated secret source?

3. When should a restart be preferred over reload?

4. Why should one setting have one operational owner?

5. What is the main advantage of a dedicated controller-configuration repository?

Official references and version notes

Verified baseline — 17 September 2026. Labs use Jenkins 2.568.3 LTS with Java 21; Jenkins 2.568.3 is tested with Java 21 and 25. Configuration as Code is 2121.v86fe99d4b_b_a_b_, released 30 August 2026 and requiring Jenkins 2.541.1. Credentials is 1511.v2e3cb_0008ef0, also requiring Jenkins 2.541.1. The disposable image starts from jenkins/jenkins:2.568.3-lts-jdk21; record its platform-specific image digest before execution. Re-check versions, security advisories and configurator reference output before reusing the lab because plugin schemas can change independently of Jenkins core.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.