I have a Jenkinsfile with some properties, for example
trace = false
userNotifications = [
build_master : [name : 'name',
email : 'email',
slackid: 'slack id',
slackchannel: 'slack channel']
]
env.aProperty = "aValue"
node('COMPILE')
{
...
}
I want to parse the above Jenkinsfile inside groovy code in order to access some of the property values.
When I use GroovyShell like this
Binding binding = new Binding()
GroovyShell shell = new GroovyShell(binding)
Object groovyDsl = shell.evaluate(clean)
I get this error
groovy.lang.MissingMethodException: No signature of method: Script1.node() is applicable for argument types: (String, Script1$_run_closure1) values: [COMPILE, Script1$_run_closure1@7d804e7]
I might be able to get around the particular error with some Groovy meta-programming, however, I am unsure if this is the right direction. My question is what is the best way to parse a Jenkinsfile in Groovy code? This is Groovy DSL at the end of the day and I would expect it to be more straightforward.