我想从jenkins管道脚本加载一个配置值(类似json, yaml, xml或ini)。当我尝试使用org.yaml.snakeyaml.Yaml
时,我得到
脚本不允许使用新的org.yaml.snakeyaml
我知道我可以解锁org.yaml.snakeyaml.Yam
,但是消息告诉我这似乎不是加载配置文件的标准方式。
是否有一种方式加载配置文件,已经解锁?
如果有人在jenkinsfile中寻找yaml解析器,我推荐以下
def yamlData = readYaml file: 'cae.yaml'
参考:https://jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#code-readyaml-code-read-yaml-from-files-in-the-workspace-or-text
尝试使用JsonSlurper:
def config = new JsonSlurper().parse(new File("config.json"))