public static JibContainerBuilder toJibContainerBuilder(
      Path projectRoot,
      Path buildFilePath,
      Build buildCommandOptions,
      CommonCliOptions commonCliOptions,
      ConsoleLogger logger)
      throws InvalidImageReferenceException, IOException {
    BuildFileSpec buildFile =
        toBuildFileSpec(buildFilePath, buildCommandOptions.getTemplateParameters());
    Optional<BaseImageSpec> baseImageSpec = buildFile.getFrom();
    JibContainerBuilder containerBuilder =
        baseImageSpec.isPresent()
            ? createJibContainerBuilder(baseImageSpec.get(), commonCliOptions, logger)
            : Jib.fromScratch();

    buildFile.getCreationTime().ifPresent(containerBuilder::setCreationTime);
    buildFile.getFormat().ifPresent(containerBuilder::setFormat);
    containerBuilder.setEnvironment(buildFile.getEnvironment());
    containerBuilder.setLabels(buildFile.getLabels());
    containerBuilder.setVolumes(buildFile.getVolumes());
    containerBuilder.setExposedPorts(buildFile.getExposedPorts());
    buildFile.getUser().ifPresent(containerBuilder::setUser);
    buildFile.getWorkingDirectory().ifPresent(containerBuilder::setWorkingDirectory);
    buildFile.getEntrypoint().ifPresent(containerBuilder::setEntrypoint);
    buildFile.getCmd().ifPresent(containerBuilder::setProgramArguments);

    Optional<LayersSpec> layersSpec = buildFile.getLayers();
    if (layersSpec.isPresent()) {
      containerBuilder.setFileEntriesLayers(Layers.toLayers(projectRoot, layersSpec.get()));
    }
    return containerBuilder;
  }
@Test
  public void testToBuildFileSpec_templateMultiLineBehavior()
      throws URISyntaxException, InvalidImageReferenceException, IOException {
    Path buildfile =
        Paths.get(Resources.getResource("buildfiles/projects/templating/multiLine.yaml").toURI());

    Mockito.when(buildCli.getTemplateParameters())
        .thenReturn(ImmutableMap.of("replace" + "\n" + "this", "creationTime: 1234"));
    JibContainerBuilder jibContainerBuilder =
        BuildFiles.toJibContainerBuilder(
            buildfile.getParent(), buildfile, buildCli, commonCliOptions, consoleLogger);
    ContainerBuildPlan resolved = jibContainerBuilder.toContainerBuildPlan();
    Assert.assertEquals(Instant.ofEpochMilli(1234), resolved.getCreationTime());
  }