Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48430

Provided config file is sometimes not complete

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor 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")
            }
          }
        }
      }
      

            domi Dominik Bartholdi
            abeben Adam Beben
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: