code: public String buildImageId() {
      // stream messages end with new line, so call trim to remove it
      final String stream = stream();
      return stream != null && stream.startsWith("Successfully built")
             ? stream.substring(stream.lastIndexOf(' ') + 1).trim()
             : null;
    }
docs: Checks if the stream field contains a string a like "Successfully built 2d6e00052167", and if
  so, returns the image id. Otherwise null is returned. This string is expected when an image is
  built successfully.
  
  @return The image id if this is a build success message, otherwise null.