Class PropertiesFileContentExtractor

java.lang.Object
org.jenkinsci.plugins.ivytrigger.util.PropertiesFileContentExtractor

public class PropertiesFileContentExtractor extends Object
Author:
Mike McLean
  • Constructor Details

    • PropertiesFileContentExtractor

      public PropertiesFileContentExtractor(FilePathFactory filePathFactory)
  • Method Details

    • extractPropertiesFileContents

      public String extractPropertiesFileContents(String propertiesFilePath, AbstractProject job, Node pollingNode, org.jenkinsci.plugins.xtriggerapi.XTriggerLog log, Map<String,String> envVars) throws org.jenkinsci.plugins.xtriggerapi.XTriggerException
      Given a propertiesFilePath value, will split that value into multiple paths, read the content from the resolved file names and return the content.

      The content of the property files is assumed to be in properties file format. e.g.: prop1=1 prop2=2 prop3=3

      As an example, if the propertiesFilePath is "a.properties;b.properties", that a.properties contains prop1=2 and that b.properties contains prop2=3, the method will return: prop1=2 prop2=3

      Parameters:
      propertiesFilePath - If this value is empty or null, the method will return an empty string.
      job - The job whose workspace is used to resolve the property files.
      pollingNode - Jenkins agent used to resolve the property files on. If not provided, Jenkins master is used.
      log - Used for logging.
      envVars - Environment variables used to resolve in the file paths.
      Returns:
      The aggregated content of the properties files.
      Throws:
      org.jenkinsci.plugins.xtriggerapi.XTriggerException - On error.
    • splitFilePaths

      public List<String> splitFilePaths(String propertiesFilePath)
      Splits the value on semi-colon and trims each path.

      Right now, the separator is a hard coded value. It could probably be refactored to use a configurable value.

      Parameters:
      propertiesFilePath - The semi-colon separated value to split.
      Returns:
      The list of paths.