Bootstrap

jenkins pipeline 读取json file

jenkins pipeline 读取json 文件

groovy 解决方案(失败)

import groovy.json.JsonSlurper
def json = new JsonSlurper().parse(new File("${env.WORKSPACE}/allure-report/widgets/summary.json"))
结果报fileNotFoundExecption

java.io.FileNotFoundException: xxxxx/allure-report/widgets/summary.json (No such file or directory)

jenkins 自带读取文件api (成功)

https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/

def json = readJSON file: "${env.WORKSPACE}/allure-report/widgets/summary.json"
;