private static Optional<Credential> retrieve(
      ImageConfiguration imageConfiguration, EventHandlers eventHandlers)
      throws CredentialRetrievalException {
    for (CredentialRetriever retriever : imageConfiguration.getCredentialRetrievers()) {
      Optional<Credential> credential = retriever.retrieve();
      if (credential.isPresent()) {
        return credential;
      }
    }

    String registry = imageConfiguration.getImageRegistry();
    String repository = imageConfiguration.getImageRepository();
    eventHandlers.dispatch(
        LogEvent.info("No credentials could be retrieved for " + registry + "/" + repository));
    return Optional.empty();
  }
Retrieves credentials for the target image.
jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/RegistryCredentialRetriever.java