Nat*_*han 5 groovy jenkins-pipeline
我想从jenkins管道脚本加载配置值(类似于json,yaml,xml或ini).当我尝试使用时,org.yaml.snakeyaml.Yaml我得到了
脚本不允许使用新的org.yaml.snakeyaml.Yaml
我知道我可以解锁org.yaml.snakeyaml.Yam,但是消息告诉我这似乎不是加载配置文件的标准方法.
有没有办法加载已经解锁的配置文件?
如果有人在jenkinsfile中寻找yaml解析器,我推荐以下内容
def yamlData = readYaml file: 'cae.yaml'
Run Code Online (Sandbox Code Playgroud)
参考: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"))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7014 次 |
| 最近记录: |