Library Configuration Schema¶
This page outlines the schema for Library Configuration Files.
Library Configuration Validation¶
Schema¶
fields{ // (1)
required{} // (2)
optional{} // (3)
}
- The
fields{}
block is used to declare what properties are expected in a library configuration. - The
required{}
block is used to declare required fields. - The
optional{}
block is used to declare optional fields.
Within the required
and optional
blocks, list the parameters the library supports in a parameterName = <Validation Type>
format.
Note
If a library doesn't include a library configuration file, then users can supply arbitrary parameters to the library from the Pipeline Configuration.
If a library does include a library configuration file, then users will only be able to supply parameters that are listed within the required
and optional
blocks.
The presence of extraneous parameters will fail the build.
Supported Validations¶
The library configuration supports several different validation types for library parameters.
Type Validation¶
Type validation confirms that a library parameter is an instance of a particular type.
The current options for data types to test for are:
- Boolean / boolean
- String
- Integer / int
- Double
- BigDecimal
- Float
- Number
- List
- ArrayList
Type Validation Example
fields{
required{
parameterA = String // (1)
parameterB = Number // (2)
parameterC = Boolean // (3)
}
optional{
parameterD = String // (4)
parameterE = Boolean // (5)
parameterF = List // (6)
parameterG = ArrayList // (7)
}
}
- ensures that
parameterA
was configured and is an instance of a String - ensures that
parameterB
was configured and is an instance of a Number - ensures that
parameterC
was configured and is an instance of a Boolean - if
parameterD
was configured, ensures it's a String - if
parameterE
was configured, ensures it's a Boolean - if
parameterF
was configured, ensures it's a List - if
parameterG
was configured, ensures it's an ArrayList
Enum Validation¶
Enum validation ensures that a library parameter value is one of the options defined by a list in the library configuration.
Enum Validation Example
fields{
required{
parameterA = [ "a", "b", 11 ] // (1)
}
}
- ensures that
parameterA
was configured and is set to either 'a', 'b', or 11
Regular Expression Validation¶
Regular expression validation uses Groovy's match operator to determine if the parameter value is matched by the regular expression.
Regular Expression Example
fields{
required{
parameterA = ~/^s.*/ // (1)
}
}
- ensures that
parameterA
starts withs
Nested Parameters¶
Library parameters can be arbitrarily nested within the Pipeline Configuration.
For example, the following Pipeline Configuration would be valid to pass the example.nestedParameter
parameter to a library named testing
.
libraries{
testing{
example{
nestedParameter = 11
}
}
}
fields{
required{
example{
nestedParameter = Number
}
}
}
Tip
To validate nested library parameters in the library configuration, nest their validation in the same structure within the required
or optional
blocks.