Nathan Nathan - 1 year ago 343
Groovy Question

Recommended way of loading config file from jenkins pipeline groovy script

I want to load a config value (something like json, yaml, xml or ini) from a jenkins pipeline script. When I try to use

I get

Scripts not permitted to use new org.yaml.snakeyaml.Yaml

I know I can unlock
, but the message tells me that this does not seem to be the standard way of loading config files.

Is there a way of loading config files that is already unlocked?

Answer Source

Try using the JsonSlurper:

def config = new JsonSlurper().parse(new File("config.json"))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download