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.load_JSON('resources/toolchains-ubuntu1604-stable.json') 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[] |
languages A String Array which contains a list of supported languages in the lifecycles file. |
String[] |
toolchain_list A String Array which contains a list of toolchains in the toolchains file. |
Map |
toolchains A Map of the parsed toolchains file. |
Type Params | Return Type | Name and description |
---|---|---|
|
boolean |
isFriendlyLabel(String toolchain) Can a toolchain be used with a friendly label when Jenkins matrix axes are used? |
|
void |
load_JSON(String file) Load the JSON of a toolchains file and parse it. |
|
void |
load_JSONString(String json) Parse the JSON which is the contents of a toolchains file. |
|
Boolean |
supportedLanguage(String lang) Checks to see if a language is a supported language based on the toolchains file. |
|
Boolean |
supportedMatrix(String lang, String toolchain) Checks to see if a toolchain is a supported build matrix based on a specific language. |
|
Boolean |
supportedTool(String toolchain, String tool) Check to see if a given tool is supported in the toolchain. |
|
Boolean |
supportedToolchain(String toolchain) Checks to see if a value is a supported toolchain based on the toolchains file. |
|
String |
toolchainType(String toolchain) Checks to see what type a toolchain is. |
|
Boolean |
validate() 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. This is just a list of the keys in toolchains.
Can a toolchain be used with a friendly label when Jenkins matrix axes are used? This answers that question.
Load the JSON 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 JSON 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.
json
- 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.
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.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.
Executes the validate() function but always returns a Boolean instead of throwing an exception upon failed validation.