private static BuildFileSpec toBuildFileSpec(
      Path buildFilePath, Map<String, String> templateParameters) throws IOException {
    ObjectMapper yamlObjectMapper = new ObjectMapper(new YAMLFactory());
    StringSubstitutor templater =
        new StringSubstitutor(templateParameters).setEnableUndefinedVariableException(true);
    try (StringSubstitutorReader reader =
        new StringSubstitutorReader(
            Files.newBufferedReader(buildFilePath, Charsets.UTF_8), templater)) {
      return yamlObjectMapper.readValue(reader, BuildFileSpec.class);
    }
  }
Read a build file from disk and apply templating parameters.
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/buildfile/BuildFiles.java