Skip to content

Add support for YAML configuration inheritance#2817

Draft
somiljain2006 wants to merge 6 commits intojenkinsci:masterfrom
somiljain2006:Inheritance-support
Draft

Add support for YAML configuration inheritance#2817
somiljain2006 wants to merge 6 commits intojenkinsci:masterfrom
somiljain2006:Inheritance-support

Conversation

@somiljain2006
Copy link
Copy Markdown
Contributor

@somiljain2006 somiljain2006 commented Apr 6, 2026

Fixes #1066

This change introduces _extends support in JCasC YAML configurations, allowing users to compose configurations across multiple files.

Features:

  • Supports single and multiple _extends
  • Resolves relative paths based on the current source
  • Performs deep merge of mapping nodes
  • Replaces sequences instead of merging them
  • Detects circular dependencies in _extends chains
  • Validates invalid usage (empty values, type mismatches)

Implementation:

  • Added recursive resolution of _extends during YAML parsing
  • Introduced caching to avoid re-parsing the same parent files
  • Ensured immutability via node cloning during merge

Tests: Added unit tests covering inheritance, overrides, circular dependencies, invalid inputs, and edge cases

Your checklist for this pull request

🚨 Please review the guidelines for contributing to this repository.

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side) and not your master branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or in Jenkins JIRA
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Did you provide a test-case? That demonstrates feature works or fixes the issue.

@somiljain2006 somiljain2006 requested a review from a team as a code owner April 6, 2026 15:54
@somiljain2006 somiljain2006 marked this pull request as draft April 6, 2026 16:23
@somiljain2006 somiljain2006 marked this pull request as ready for review April 6, 2026 19:39
Copy link
Copy Markdown
Member

@timja timja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed when we have folders, other tools that can merge yaml e.g. kustomize, and yaml anchors?

@somiljain2006
Copy link
Copy Markdown
Contributor Author

The goal of this is to provide a simple, native inheritance mechanism directly within JCasC without requiring external preprocessing or complex YAML constructs, unlike multiple files, which lack clear override semantics, or anchors, which are limited to a single file. This approach provides a very intuitive way to manage layered configurations.

@timja
Copy link
Copy Markdown
Member

timja commented Apr 7, 2026

Yes but do people actually need it, there's a bunch of code there to maintain, limited interest in it recently on the issue.

I think there's probably more important issues to solve unless this is something you have a need for?

@somiljain2006
Copy link
Copy Markdown
Contributor Author

I think it's better to convert this pr to a draft for now unless any meaningful use case appears for it.

@somiljain2006 somiljain2006 marked this pull request as draft April 7, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JCasC templating and inheritance support

2 participants