Skip to main content
Jenkins Configuration as Code (JCasC) lets you define Jenkins master and plugin settings in human-readable YAML. By treating configuration as declarative code you make Jenkins setups reproducible, auditable, and easier to automate across environments.
JCasC is ideal for automating Jenkins bootstrap and day‑to‑day configuration. Use YAML files to manage core settings, tool installations, credentials (via encrypted values), and many plugin configurations.
In this walkthrough you’ll:

Install and open Configuration as Code

  1. Install the Configuration as Code plugin from Manage Jenkins → Manage Plugins. Note: installing the plugin requires a Jenkins restart.
  2. After restart, log back in and navigate to Manage Jenkins → Configuration as Code.
The Configuration as Code page allows you to:
  • View the effective configuration (a generated YAML file representing the current running instance).
  • Load or replace configuration from a local file, URL, or Git repository.
  • Download or reload the current configuration.
  • Access JCasC documentation and the JSON schema.
A screenshot of the Jenkins web UI on the "Download progress" plugins page, showing preparation steps and plugin install statuses (success/failure) for items like SnakeYAML, Prism API, and Configuration as Code. The left sidebar shows plugin navigation (Updates, Available plugins, Installed plugins) and a restart option is visible.

Inspect the effective configuration (YAML)

Click “View Configuration” (or equivalent) to generate the effective configuration YAML. It is a comprehensive document that maps Jenkins core and plugin settings to a declarative structure. Below are trimmed, representative excerpts to illustrate common sections. Example — global and UI-related settings:
Example — tool installations (Maven, Node.js, SonarQube scanner):
Example — credentials section (sensitive values appear as encrypted/encoded strings):
Notes about common top-level JCasC keys:
Never store plain-text secrets or private keys in a public repository. If you keep configuration files in Git, use a secrets manager or Jenkins credentials provider (and avoid committing the raw secret values).

Persist a JCasC YAML file on the controller and apply it

To have Jenkins load a persistent JCasC file from disk:
  1. Choose a location accessible by the Jenkins process. Example:
  1. Create the YAML file and paste your JCasC content:
  1. In Manage Jenkins → Configuration as Code, set the configuration path to the file you created (for example):
  1. Click “Apply new configuration”. JCasC will validate the YAML and report any validation errors. On success, the configuration is applied and the UI shows a timestamp and source path indicating where the config was loaded from.
After applying your file, refresh the Jenkins UI to confirm changes (system message, tool installations, plugin settings, etc.).

JSON schema and documentation

JCasC publishes a JSON schema useful for editor validation and tooling. Use the schema when authoring or validating complex configurations. Example (trimmed):
Consult the repository for the full schema and plugin-specific fragments to enable robust linting and IDE autocompletion.

Conclusion

Jenkins Configuration as Code simplifies managing Jenkins at scale. With JCasC you can:
  • Capture your running instance as YAML,
  • Persist reusable, versionable configuration files,
  • Apply configuration deterministically across controllers and environments.
Next steps: practice authoring smaller JCasC fragments for plugins you use, integrate JCasC files into your Git workflows, and adopt secrets management practices to keep credentials safe.

Watch Video