added the Missing information on how to generate/create yaml file (#2471)

Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com>
This commit is contained in:
Sudhanshu Rai 2024-03-28 04:35:51 +05:30 committed by GitHub
parent 6a2b0d7b70
commit 5603ec68ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 3 deletions

View File

@ -245,6 +245,15 @@ public class ConfigurationAsCodeTest {
Doing so, you will confirm JCasC is able to introspect your plugin and build the expected configuration data model, but also detect
some changes made to your plugin break this configuration model.
**Location of configuration-as-code.yml:**
The `configuration-as-code.yml` file should be located within the test resources directory (`src/test/resources`) of your project repository. Specifically, it should be placed in the same directory where your test classes reside.
You can find some examples here
1. [kubernetes-plugin](https://github.com/jenkinsci/kubernetes-plugin/blob/master/src/test/resources/org/csanchez/jenkins/plugins/kubernetes/casc/configuration-as-code.yaml)
2. [azure-cosmosdb-plugin](https://github.com/jenkinsci/azure-cosmosdb-plugin/blob/main/src/test/resources/io/jenkins/plugins/azurecosmosdb/configuration-as-code.yml)
### Backward compatibility test
About the latter, in case you need to introduce some breaking changes, you can define a backward compatibility test case:
@ -297,12 +306,12 @@ public class ConfigurationAsCodeTest {
@ClassRule
@ConfiguredWithCode("configuration-as-code.yml")
public static JenkinsConfiguredWithCodeRule j = new JenkinsConfiguredWithCodeRule();
@Test
public void should_support_configuration_as_code() throws Exception {
...
}
@Test
public void should_support_configuration_export() throws Exception {
...
@ -311,7 +320,8 @@ public class ConfigurationAsCodeTest {
```
### JSON Schema Test (Beta)
We generate a JSON schema that users can use to validate their changes and provide IDE assistance,
We generate a JSON schema that users can use to validate their changes and provide IDE assistance,
you can test that your plugin's example yaml file validates correctly by implementing the below test:
`SchemaGenerationTest` provides a abstraction layer to test out the plugins YAML file against the generated schema.
@ -321,6 +331,7 @@ Step 1
Create a YAML file for the configurators corresponding to the developed plugin.
For eg: `validJenkinsConfigurator.yml`
```yaml
jenkins:
systemMessage: "Configured by Configuration as Code plugin"