Class JsonConfigLoader

java.lang.Object
org.jenkinsci.plugins.vmanager.charts.util.JsonConfigLoader

public final class JsonConfigLoader extends Object
Builds a VManagerChartsJobProperty from a JSON configuration (typically exported from the job-property UI and dropped into the build's workspace). The loader intentionally ignores any credentialsId field that may be present in the JSON: credentials are never imported, they always come from the GUI.
  • Field Details

    • DEFAULT_CONFIG_FILE_NAME

      public static final String DEFAULT_CONFIG_FILE_NAME
      Canonical filename used when the build listener mirrors the JSON config into the run dir on the controller. The view layer always looks here first regardless of the user's configured path on the agent side.
      See Also:
  • Method Details

    • toJson

      public static String toJson(VManagerChartsJobProperty p)
      Serializes a VManagerChartsJobProperty into the canonical JSON shape that load(String) can read back (round-trippable). The following fields are intentionally NEVER exported and NEVER imported — they always come from the GUI at build time:
      • credentialsId
      • serverUrl
      • sessionSource / sessionInputFile
    • load

      public static VManagerChartsJobProperty load(String jsonText)
      Parses jsonText and returns a populated property (no credentials).
    • effectiveForRun

      public static VManagerChartsJobProperty effectiveForRun(Run<?,?> run, VManagerChartsJobProperty gui)
      Returns the effective property to use for view/data purposes given a Run. When the GUI property has configSource = FILE, the JSON mirrored next to the build log is parsed and used to overlay the GUI booleans / customCharts. The GUI-only fields (server URL, credentials, session source/file, verbose-logging) are always taken from the saved GUI property. When the mirrored file cannot be located or parsed, the GUI property is returned unchanged.
    • effectiveForJob

      public static VManagerChartsJobProperty effectiveForJob(Job<?,?> job, VManagerChartsJobProperty gui)
      Returns the effective property for job-level views (the job-sidebar "vManager Charts" page). When configSource = FILE, the JSON file from the latest completed build (falling back to the latest build) is used.
    • locateConfigFile

      public static File locateConfigFile(Run<?,?> run, String userPath)
      Resolves the controller-side File that should be read for the JSON config of a given run. The build-completion listener mirrors the loaded JSON into run.getRootDir() under DEFAULT_CONFIG_FILE_NAME, which is preferred. Falls back to the user-configured path (absolute, or relative to the run dir) for legacy builds where the mirror is not yet present.