jenkinsci / jenkinsci/configuration-as-code-plugin

Warn or Prevent Jenkins Restart When UI-Based Config Differs from CasC YAML

Open
#2,689 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.8k
Forks
756
Avg merge
9h 47m
Merged PRs (30d)
10

Description

### What feature do you want to see added?

### Feature Request: Warn or Prevent Jenkins Restart When UI-Based Config Differs from CasC YAML

#### Describe the feature

We are using the Jenkins **Configuration as Code (CasC)** plugin to manage our Jenkins configuration via YAML files. Although the plugin allows exporting the current configuration, Jenkins still permits a restart even when configuration changes have been made directly through the UI and not yet synced back to the CasC YAML.

This behavior can result in **accidental configuration loss**, as Jenkins will reload only what's defined in the CasC file upon restart—discarding any UI-based updates.

#### Proposed enhancement

Introduce a mechanism in the CasC plugin to:

1. Detect differences between the current live Jenkins configuration and the CasC YAML.
2. Warn the user or block Jenkins restart if unsynced UI changes are detected.
3. Optionally, display a diff or prompt users to export changes before proceeding.

#### Use case example

- A user modifies global configuration or credentials directly via the UI.
- Before exporting these changes back to YAML, Jenkins is restarted.
- The UI-based changes are lost because Jenkins reloads from the CasC-defined state.

#### Why this matters

- Helps prevent accidental loss of configuration.
- Encourages teams to maintain sync between UI changes and CasC YAML.
- Improves overall safety and predictability in hybrid CasC + UI usage workflows.
- Especially useful in environments where restarts are automated or frequent.

#### Additional context

Export functionality exists and works well, but there's currently no safeguard against restarts when unsynced changes are present. This feature would be a valuable enhancement for maintaining configuration integrity.

### Upstream changes

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.