class LifecycleValidator extends Object
Validates the contents of a lifecycle file and provides quick access to supported languages.
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.LifecycleValidator
def lifecycles = new LifecycleValidator()
lifecycles.loadYamlFile('resources/lifecycles-ubuntu2204-stable.yaml')
println 'Does the file validate? ' + lifecycles.validate()
print 'Supported languages include:\n '
println lifecycles.languages.collect {
lifecycles.lifecycles[it]['friendlyName']
}.sort().join('\n ')
| Type | Name and description |
|---|---|
String[] |
languagesA String Array which contains a list of supported languages in the lifecycles file. |
Map |
lifecyclesA Map of the parsed lifecycles file. |
String[] |
unstable_languagesA String Array which contains a list of supported languages in the unstable lifecycles file. |
Map |
unstable_lifecyclesA Map of the parsed unstable lifecycles 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. |
|
Map |
getLifecycles(Boolean unstable = false)Get lifecycles or optionally unstable lifecycles. |
|
void |
loadYamlFile(String file, Boolean unstable = false)Load the YAML of a lifecycles file and parse it. |
|
void |
loadYamlString(String yaml, Boolean unstable = false)Parse the YAML which is the contents of a lifecycles file. |
|
Boolean |
supportedLanguage(String lang, Boolean unstable = false)Checks to see if a language is a supported language based on the lifecycles file. |
|
Boolean |
validate()Validates the lifecycles file. |
|
Boolean |
validate(Boolean unstable)Validates the lifecycles 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 supported languages in the unstable lifecycles file. This is just a list of the keys in unstable_lifecycles.
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 languages instead of stable.Get lifecycles or optionally unstable lifecycles.
unstable - Request unstable instead of stable.Load the YAML of a lifecycles file and parse it. This should be the first function called after class instantiation. Alternately, loadYamlString() can be called instead. It populates lifecycles and languages.
file - A String which is a path to a lifecycles file.Parse the YAML which is the contents of a lifecycles file. It populates lifecycles and languages. This is required in order to use the readFileFromWorkspace method from the Jenkins Job DSL Plugin.
yaml - A String containing the contents of a lifecycles file.Checks to see if a language is a supported language based on the lifecycles file.
lang - A String which is a language to look up based on the keys in the lifecycles file.Validates the lifecycles file. Covers both unstable and stable.
Validates the lifecycles file.
unstable - Validate as an unstable instead of stable.Executes the validate() function but always returns a Boolean instead of throwing an exception upon failed validation.