-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration-as-Code compatibility #23
Conversation
- add migration routine from previous ATXPublisher configuration - fix serialization of custom settings - adapted tests
Thanks for using the GitHub tracking issue. Means I can avoid JIRA 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the updated docs on JCasC testing
https://github.com/jenkinsci/configuration-as-code-plugin/blob/master/docs/PLUGINS.md#how-to-test
pom.xml
Outdated
<dependency> | ||
<groupId>io.jenkins</groupId> | ||
<artifactId>configuration-as-code</artifactId> | ||
<version>1.7</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider updating the version and include the tests
classifer
ConfigurationAsCode.get().export(outputStream); | ||
|
||
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); | ||
Map<String, Object> yamlConfig = new Yaml().load(inputStream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void testImportConfiguration() throws Exception { | ||
final URL yamlConfig = this.getClass().getResource("configuration-as-code.yml"); | ||
System.out.println(yamlConfig); | ||
ConfigurationAsCode.get().configure(yamlConfig.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using the annotation @ConfiguredWithCode("configuration-as-code.yml")
which the tests
classifier includes.
- use settings list and deprecate config map due to incompatibility with CasC - save name-value pairs for each setting only - group association, descriptions and default values are synchronized with config.xml at plugin startup - ensure backward compatibility with previous configuration
Tests are looking good! A lot cleaner now that you are not using the YAML load method 😅 |
Yep thanks for your hints! |
public void testExportConfiguration() throws Exception { | ||
final ETInstallation.DescriptorImpl etDescriptor = jenkins.jenkins | ||
.getDescriptorByType(ETInstallation.DescriptorImpl.class); | ||
etDescriptor.setInstallations(new ETInstallation("ECU-TEST", "C:\\ECU-TEST", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure you need to override the configuration, could validate the config loaded in from @ConfiguredWithCode("configuration-as-code.yml")
🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right! I'll fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great now your fully validating the YAML config 🐑
- bump to casc-plugin 1.15
Resolves #20