Skip to content

Add strict export mode to propagate export failures as exceptions#2836

Open
somiljain2006 wants to merge 5 commits intojenkinsci:masterfrom
somiljain2006:Error-signaling-in-export
Open

Add strict export mode to propagate export failures as exceptions#2836
somiljain2006 wants to merge 5 commits intojenkinsci:masterfrom
somiljain2006:Error-signaling-in-export

Conversation

@somiljain2006
Copy link
Copy Markdown
Contributor

@somiljain2006 somiljain2006 commented Apr 18, 2026

Introduce a strict export mode in ConfigurationAsCode that propagates export failures as ConfiguratorException instead of embedding "FAILED TO EXPORT" markers in the generated YAML.

  • Add export(OutputStream, boolean strict) API
  • Preserve existing behavior by default (non-strict mode)
  • Update Attribute.describe() to throw in strict mode
  • Add unit tests covering strict and non-strict behavior
  • Add API test to verify strict export on a valid Jenkins instance

This improves error visibility while maintaining backward compatibility.

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 18, 2026 06:53
Comment thread plugin/src/test/java/io/jenkins/plugins/casc/AttributeTest.java Outdated
Comment thread plugin/src/main/java/io/jenkins/plugins/casc/ConfigurationAsCode.java Outdated
@somiljain2006 somiljain2006 requested a review from timja April 18, 2026 16:50
Comment thread plugin/src/main/java/io/jenkins/plugins/casc/ConfigurationContext.java Outdated
@somiljain2006 somiljain2006 requested a review from timja April 19, 2026 04:00
public class CasCGlobalConfig extends GlobalConfiguration {

private String configurationPath;
private boolean strictExport = false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do you need this in the global config? just get it from the context.

Copy link
Copy Markdown
Contributor Author

@somiljain2006 somiljain2006 Apr 19, 2026

Choose a reason for hiding this comment

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

I initially added strictExport to CasCGlobalConfig to allow configuring it via YAML, but that effectively makes it a persistent server setting.
Based on your suggestion, I plan to completely remove it from the global config (which means intentionally dropping the YAML configurability) and overload the export method to accept a ConfigurationContext directly.
This decouples the export logic from the global database. Let me know if you agree with this, and I’ll go ahead and update the implementation accordingly.

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.

2 participants