| Big help thanks David, thought I was going mad with my sample JSON refusing to parse. NB to others, same issue when using readJSON() in the Pipeline Utility plugin: https://jenkins.io/doc/pipeline/steps/pipeline-utility-steps/ Instead of trusting others' JSON to come pre-trimmed, just read it in and trim it as David suggests;
def configString = readFile("userfile.json")
configString = configString.trim()
def configJSON = readJSON text: configString
The "file" version of readJSON is unusable unless you can guarantee no top/tail whitespace and/or you don't care if it breaks the pipeline Cheers Alex |