Nathan Nathan - 6 months ago 111
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?


Try using the JsonSlurper:

def config = new JsonSlurper().parse(new File("config.json"))