Recommended way to load config file from jenkins groovy script pipeline

I want to load the configuration value (something like json, yaml, xml or ini) from the jenkins script pipeline. When I try to use org.yaml.snakeyaml.Yaml, I get

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

I know that I can unlock org.yaml.snakeyaml.Yam, but the message tells me that this is not like the standard way to download configuration files.

Is there a way to download configuration files that are already unlocked?

+4
source share
2 answers

Try using JsonSlurper :

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

Source: https://habr.com/ru/post/1658774/


All Articles