Community Bridge Introduction
Community Bridge is an initiative by the Linux Foundation to accelerate the adoption, innovation and sustainability of open source projects. I came across this initiative in a blog post. I had been contributing to Jenkins at the time and decided to have a chat with Oleg Nenashev and Tracy Miranda regarding the possibility of a project under the Community Bridge initiative. Fortunately for me JCasC ( Jenkins Configuration as Code) had the mentors as well as the project idea in place to start a project. After a few regular meetings we ironed out the details of the programme and on August 7th I began with my journey!
JCasC Developer Tools — JSON Schema
JSON files when submitted to a server undergo a validation to determine whether the values and the format are correct and that they conform to a well defined schema, this schema is known as a JSON Schema. A YAML file can also be validated using a JSON Schema.
The main premise of JCasC is to load YAML files written by developers into the Jenkins instance. An example of a JCasC YAML file is:
---
jenkins:
systemMessage: “Hello World”
numExecutors:2
---
The above YAML configuration will configure Jenkins to display a message Hello world with the number of executors set to two. In order to validate the YAML we have a schema. This schema is written using jelly files (Executable XML files) and currently it is not a valid schema. The first phase of the project is based around rewriting the schema generation to java and developing a better test framework for it, because currently the schema is not testable.
Phase 1 — JCasC Dev Tools
The first week I got into studying how the schema was generated.With the support of two of my awesome mentors Tim Jacomb and Joseph Peterson
I finally got an understanding of the current schema.
So JCasC has a set of configurators for describing a YAML file.
They are:
a) Base Configurators
b) Hetero Describable Configurators
c) Data Bound Configurators
These configurators together successfully describe a YAML file.
We proceeded to generate the schema with the help of individual description of each of these configurators.
The JSON Schema has a set of components, consider the above yaml file as an example:
---
{
"jenkins": {
"type": "object",
"properties": {
"systemMessage": {
"type": "string"
},
"numExecutors": {
"type": "integer"
}
}
}
}
---
So here Jenkins is the base configurator and it has a set of attributes viz systemMessage and numExecutors, so our schema needs to be able to describe a set of attributes for every field in the schema. Some of the fields that our JSON Schema uses to describe the YAML are:
1) type : String, int, Boolean etc.
2) properties : A set of fields describing the part field.
3) id: Unique Identifier for the field
Thus the above schema successfully verifies the YAML configuration.
JAVA Rewrite
We used JSON Objects to build components of the schema.The basic flow that is followed to generate the schema is as follows:
a) Iterate through the Base Configurators.
b) Iterate over the list of Base Configurator.Attributes and add each attribute to the schema.
c) Iterate over the HeteroDescribable Configurators and add each configurator to the schema along with its required properties.
The set of PR’s Resolved during Phase 1 are as follows:
a) Basic Schema
b) Schema Doc Page
c) Test Framework
d) Nested Schema
That is all from me guys, I am currently preparing for phase 2 and working towards fixing any pending issues of Phase 1. Thanks for reading.
Phase 2 Goals:
We would primarily target VSCode integration in phase 2 with the aim of:
a)Validation of JCasC YAML files with the schema
b)Autocompletion
c)Integration with a live Jenkins instance.
Contributions
We would love to get feedback from you on the stuff we are working on. Contributions to the project would be highly appreciated.
a) Gitter Chat
b) Github Repository
c) Project Introduction