class ToolchainValidator extends Object
Validates the contents of a toolchains file and provides quick access to supported matrices.
To run this example, clone Jervis and execute ./gradlew console to bring up a Groovy Console with the classpath set up.
Please note, if you are writing Job DSL plugin groovy scripts you should not use the relative file paths to access files in the repository where your DSL scripts reside. Instead, use the readFileFromWorkspace method provided by the Job DSL plugin in Jenkins.
import net.gleske.jervis.lang.ToolchainValidator
def toolchains = new ToolchainValidator()
toolchains.loadYamlFile('resources/toolchains-ubuntu2204-stable.yaml')
println 'Does the file validate? ' + toolchains.validate()
println 'Supported build matrices by language include:'
toolchains.languages.each { language ->
print " ${language}:\n "
println toolchains.toolchain_list.findAll { tool ->
(tool == 'toolchains')? false : toolchains.supportedMatrix(language, tool)
}.join('\n ')
}
null
| Type | Name and description |
|---|---|
String[] |
languagesA String Array which contains a list of supported languages in the lifecycles file. |
List |
matrix_toolchain_listA String Array which contains a list of toolchains in the toolchains file which are capable of matrix building. |
String[] |
toolchain_listA String Array which contains a list of toolchains in the toolchains file. |
Map |
toolchainsA Map of the parsed toolchains file. |
String[] |
unstable_languagesA String Array which contains a list of supported languages in the unstable toolchains file. |
List |
unstable_matrix_toolchain_listA String Array which contains a list of toolchains in the toolchains file which are capable of matrix building. |
String[] |
unstable_toolchain_listA String Array which contains a list of toolchains in the unstable toolchains file. |
Map |
unstable_toolchainsA Map of the parsed unstable toolchains file. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
String[] |
getLanguages(Boolean unstable = false)A String Array which contains a list of supported languages in the lifecycles file. |
|
List |
getMatrix_toolchain_list(Boolean unstable = false)A String Array which contains a list of toolchains in the toolchains file which are capable of matrix building. |
|
String[] |
getToolchain_list(Boolean unstable = false)A String Array which contains a list of toolchains in the toolchains file. |
|
Map |
getToolchains(Boolean unstable = false)Returns a copy of a parsed toolchains file for either stable toolchains or unstable toolchains. |
|
boolean |
isFriendlyLabel(String toolchain, Boolean unstable = false)Can a toolchain be used with a friendly label when Jenkins matrix axes are used? |
|
void |
loadYamlFile(String file, Boolean unstable = false)Load the YAML of a toolchains file and parse it. |
|
void |
loadYamlString(String yaml, Boolean unstable = false)Parse the YAML which is the contents of a toolchains file. |
|
Boolean |
supportedLanguage(String lang, Boolean unstable = false)Checks to see if a language is a supported language based on the toolchains file. |
|
Boolean |
supportedMatrix(String lang, String toolchain, Boolean unstable = false)Checks to see if a toolchain is a supported build matrix based on a specific language. |
|
Boolean |
supportedTool(String toolchain, String tool, Boolean unstable = false)Check to see if a given tool is supported in the toolchain. |
|
Boolean |
supportedToolchain(String toolchain, Boolean unstable = false)Checks to see if a value is a supported toolchain based on the toolchains file. |
|
List |
toolValues(String toolchain, Boolean unstable = false)Get a list of values for a given toolchain. |
|
String |
toolchainType(String toolchain, Boolean unstable = false)Checks to see what type a toolchain is. |
|
Boolean |
validate()Validates the toolchains file. |
|
Boolean |
validate(Boolean unstable)Validates the toolchains file. |
|
Boolean |
validate_asBool()Executes the validate() function but always returns a Boolean instead of throwing an exception upon failed validation. |
A String Array which contains a list of supported languages in the lifecycles file. This is just a list of the keys in lifecycles.
A String Array which contains a list of toolchains in the toolchains file which are capable of matrix building. This is just a list of the keys in toolchains.
A String Array which contains a list of toolchains in the toolchains file. This is just a list of the keys in toolchains.
A String Array which contains a list of supported languages in the unstable toolchains file. This is just a list of the keys in unstable_toolchains.
A String Array which contains a list of toolchains in the toolchains file which are capable of matrix building. This is just a list of the keys in toolchains.
A String Array which contains a list of toolchains in the unstable toolchains file. This is just a list of the keys in unstable_toolchains.
A String Array which contains a list of supported languages in the lifecycles file. This is just a list of the keys in lifecycles.
unstable - Request unstable instead of stable.A String Array which contains a list of toolchains in the toolchains file which are capable of matrix building. This is just a list of the keys in toolchains.
unstable - Request unstable instead of stable.A String Array which contains a list of toolchains in the toolchains file. This is just a list of the keys in toolchains.
unstable - Request unstable instead of stable.Returns a copy of a parsed toolchains file for either stable toolchains or unstable toolchains.
unstable - Request unstable toolchains instead of stable.Can a toolchain be used with a friendly label when Jenkins matrix axes are used? This answers that question.
Load the YAML of a toolchains file and parse it. This should be the first function called after class instantiation. It populates toolchains, toolchain_list, and languages.
file - A String which is a path to a toolchains file.Parse the YAML which is the contents of a toolchains file. It populates toolchains, toolchain_list, and languages. This is required in order to use the readFileFromWorkspace method from the Jenkins Job. DSL Plugin.
yaml - A String the contents of a toolchains file.Checks to see if a language is a supported language based on the toolchains file.
lang - A String which is a language to look up based on the keys in the toolchains file.Checks to see if a toolchain is a supported build matrix based on a specific language.
lang - A String which is a language to look up in the toolchains file.toolchain - A String which is a toolchain to look up based on the lang to see if it is a matrix building attribute.Check to see if a given tool is supported in the toolchain. A tool is supported if there is a key for it in the toolchains file. If there is no key for it then it is still supported if there is a * key. If there is no key for it and no * key for that toolchain then the tool is not supported. There is no checking to see if a toolchain is actually valid.
toolchain - A String which is a toolchain to look up based on the
keys in the toolchains file.tool - A value intended for the existing toolchain to check against
allowed values for support.Checks to see if a value is a supported toolchain based on the toolchains file.
toolchain - A String which is a toolchain to look up based on the
keys in the toolchains file.Get a list of values for a given toolchain. If the returns List is empty, then it is likely allows any value due to wildcard *.
toolchain - A String which is a toolchain to look up based on the
keys in the toolchains file.Checks to see what type a toolchain is. This function assumes successful validation and will not throw an exeption for a toolchain which does not exist. If the toolchain does not exist it will return simple.
Validates the toolchains file.
Validates the toolchains file.
Executes the validate() function but always returns a Boolean instead of throwing an exception upon failed validation.