-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Jenkins LTS 2.83.1
Config File Provider Plugin 2.16.4
Sometimes when I tried to parse JSON config file I encountered following exception:
net.sf.json.JSONException: Found starting '{' but missing '}' at the end. at character 0 of null
It turns out that returned file was not complete. I reproduced the issue this way:
node { for (int i = 0; i < 40; i++) { configFileProvider([configFile(fileId: 'file-id', variable: 'configfile')]) { readJSON(text: readFile(file: configfile)) } } }
Printing file content to console proves that it is readed to early. Adding file existance check helps:
node { for (int i = 0; i < 40; i++) { configFileProvider([configFile(fileId: 'file-id', variable: 'configfile')]) { if (fileExists(file: configfile)) { readJSON(text: readFile(file: configfile)) } else { error("File '$configfile' not found") } } } }
- is blocked by
-
JENKINS-51750 Config file provider doesn't always copy file to pipeline
- Closed