code: public static List<DockerImage> getAndDiscardImagesByBuildId(int buildInfoId) {
          List<DockerImage> list = new ArrayList<DockerImage>();
          synchronized(images) {
              Iterator<DockerImage> it = images.iterator();
              while (it.hasNext()) {
                  DockerImage image = it.next();
                  if (image.getBuildInfoId() == buildInfoId) {
                      if (image.hasManifest()) {
                          list.add(image);
                      }
                      it.remove();
                  } else // Remove old images from the cache, for which build-info hasn't been published to Artifactory:
                  if (image.isExpired()) {
                      it.remove();
                  }
              }
          }
          return list;
      }
docs: Gets a list of registered docker images from the images cache, if it has been
  registered to the cache for a specific build-info ID and if a docker manifest has been captured for it
  by the build-info proxy.
  Additionally, the methods also removes the returned images from the cache.
  @param buildInfoId
  @return